[Bf-blender-cvs] [968619d0362] master: UI: Language Selection Changes

Harley Acheson noreply at git.blender.org
Tue Apr 7 22:35:30 CEST 2020


Commit: 968619d03626c7e4d92d4cb383ac304b72595af3
Author: Harley Acheson
Date:   Tue Apr 7 13:25:49 2020 -0700
Branches: master
https://developer.blender.org/rB968619d03626c7e4d92d4cb383ac304b72595af3

UI: Language Selection Changes

Removal of 'Translation' checkbox. Enable translation options when selecting non-English languages.

Differential Revision: https://developer.blender.org/D7210

Reviewed by Brecht Van Lommel

===================================================================

M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_userdef.c
M	source/blender/blentranslation/BLT_translation.h
M	source/blender/blentranslation/intern/blt_lang.c
M	source/blender/blentranslation/intern/blt_translation.c
M	source/blender/makesdna/DNA_userdef_types.h
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 165761254d0..76e80fdb414 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -242,21 +242,14 @@ class USERPREF_PT_interface_translation(InterfacePanel, CenterAlignMixIn, Panel)
     def poll(cls, context):
         return bpy.app.build_options.international
 
-    def draw_header(self, context):
-        prefs = context.preferences
-        view = prefs.view
-
-        self.layout.prop(view, "use_international_fonts", text="")
-
     def draw_centered(self, context, layout):
         prefs = context.preferences
         view = prefs.view
 
-        layout.active = view.use_international_fonts
-
         layout.prop(view, "language")
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
+        flow.active = (bpy.app.translations.locale != 'en_US')
 
         flow.prop(view, "use_translate_tooltips", text="Tooltips")
         flow.prop(view, "use_translate_interface", text="Interface")
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 794313ecf62..b9eab004ddf 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 283
-#define BLENDER_SUBVERSION 12
+#define BLENDER_SUBVERSION 13
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c
index 28118d6e87a..a426e49dd77 100644
--- a/source/blender/blenloader/intern/versioning_userdef.c
+++ b/source/blender/blenloader/intern/versioning_userdef.c
@@ -26,6 +26,10 @@
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
 
+#ifdef WITH_INTERNATIONAL
+#  include "BLT_translation.h"
+#endif
+
 #include "DNA_anim_types.h"
 #include "DNA_curve_types.h"
 #include "DNA_scene_types.h"
@@ -740,6 +744,15 @@ void BLO_version_defaults_userpref_blend(Main *bmain, UserDef *userdef)
     userdef->gpu_flag |= USER_GPU_FLAG_OVERLAY_SMOOTH_WIRE;
   }
 
+  if (!USER_VERSION_ATLEAST(283, 13)) {
+    /* If Translations is off then language should default to English. */
+    if ((userdef->transopts & USER_DOTRANSLATE_DEPRECATED) == 0) {
+      userdef->language = ULANGUAGE_ENGLISH;
+    }
+    /* Clear this deprecated flag. */
+    userdef->transopts &= ~USER_DOTRANSLATE_DEPRECATED;
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/blentranslation/BLT_translation.h b/source/blender/blentranslation/BLT_translation.h
index 74c46b1cf3e..01e32c3f71a 100644
--- a/source/blender/blentranslation/BLT_translation.h
+++ b/source/blender/blentranslation/BLT_translation.h
@@ -32,6 +32,10 @@
 extern "C" {
 #endif
 
+/* Locale Ids. Auto will try to get local from OS. Our default is English though. */
+#define ULANGUAGE_AUTO 0
+#define ULANGUAGE_ENGLISH 1
+
 bool BLT_is_default_context(const char *msgctxt);
 const char *BLT_pgettext(const char *msgctxt, const char *msgid);
 
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c
index 112c615fac2..a533d29b188 100644
--- a/source/blender/blentranslation/intern/blt_lang.c
+++ b/source/blender/blentranslation/intern/blt_lang.c
@@ -253,7 +253,8 @@ void BLT_lang_free(void)
 }
 
 #ifdef WITH_INTERNATIONAL
-#  define ULANGUAGE ((U.language >= 0 && U.language < num_locales) ? U.language : 0)
+#  define ULANGUAGE \
+    ((U.language >= ULANGUAGE_AUTO && U.language < num_locales) ? U.language : ULANGUAGE_ENGLISH)
 #  define LOCALE(_id) (locales ? locales[(_id)] : "")
 #endif
 
@@ -264,7 +265,7 @@ void BLT_lang_set(const char *str)
   const char *short_locale = str ? str : LOCALE(ulang);
   const char *short_locale_utf8 = NULL;
 
-  if ((U.transopts & USER_DOTRANSLATE) == 0) {
+  if (U.language == ULANGUAGE_ENGLISH) {
     return;
   }
 
@@ -388,13 +389,7 @@ static void blt_lang_check_ime_supported(void)
 {
 #ifdef WITH_INPUT_IME
   const char *uilng = BLT_lang_get();
-  if (U.transopts & USER_DOTRANSLATE) {
-    ime_is_lang_supported = STREQ(uilng, "zh_CN") || STREQ(uilng, "zh_TW") ||
-                            STREQ(uilng, "ja_JP");
-  }
-  else {
-    ime_is_lang_supported = false;
-  }
+  ime_is_lang_supported = STREQ(uilng, "zh_CN") || STREQ(uilng, "zh_TW") || STREQ(uilng, "ja_JP");
 #else
   ime_is_lang_supported = false;
 #endif
diff --git a/source/blender/blentranslation/intern/blt_translation.c b/source/blender/blentranslation/intern/blt_translation.c
index 64e14522aca..0ca068d4263 100644
--- a/source/blender/blentranslation/intern/blt_translation.c
+++ b/source/blender/blentranslation/intern/blt_translation.c
@@ -81,7 +81,7 @@ const char *BLT_pgettext(const char *msgctxt, const char *msgid)
 bool BLT_translate(void)
 {
 #ifdef WITH_INTERNATIONAL
-  return BLI_thread_is_main() && (U.transopts & USER_DOTRANSLATE);
+  return BLI_thread_is_main() && (U.language != ULANGUAGE_ENGLISH);
 #else
   return false;
 #endif
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 54470dc59fc..667b6bbf33c 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -1124,7 +1124,7 @@ typedef enum eUserpref_Translation_Flags {
   USER_TR_UNUSED_2 = (1 << 2), /* cleared */
   USER_TR_UNUSED_3 = (1 << 3), /* cleared */
   USER_TR_UNUSED_4 = (1 << 4), /* cleared */
-  USER_DOTRANSLATE = (1 << 5),
+  USER_DOTRANSLATE_DEPRECATED = (1 << 5), /* Deprecated in 2.83. */
   USER_TR_UNUSED_6 = (1 << 6), /* cleared */
   USER_TR_UNUSED_7 = (1 << 7), /* cleared */
   USER_TR_NEWDATANAME = (1 << 8),
diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c
index f52307355c2..514d7428ff8 100644
--- a/source/blender/makesrna/intern/rna_userdef.c
+++ b/source/blender/makesrna/intern/rna_userdef.c
@@ -307,14 +307,27 @@ static void rna_userdef_screen_update_header_default(Main *bmain, Scene *scene,
   USERDEF_TAG_DIRTY;
 }
 
+static void rna_userdef_font_update(Main *UNUSED(bmain),
+                                    Scene *UNUSED(scene),
+                                    PointerRNA *UNUSED(ptr))
+{
+  BLF_cache_clear();
+  UI_reinit_font();
+}
+
 static void rna_userdef_language_update(Main *UNUSED(bmain),
                                         Scene *UNUSED(scene),
                                         PointerRNA *UNUSED(ptr))
 {
-  BLF_cache_clear();
   BLT_lang_set(NULL);
-  UI_reinit_font();
-  USERDEF_TAG_DIRTY;
+
+  const char *uilng = BLT_lang_get();
+  if (STREQ(uilng, "en_US")) {
+    U.transopts &= ~(USER_TR_IFACE | USER_TR_TOOLTIPS | USER_TR_NEWDATANAME);
+  }
+  else {
+    U.transopts |= (USER_TR_IFACE | USER_TR_TOOLTIPS | USER_TR_NEWDATANAME);
+  }
 }
 
 static void rna_userdef_script_autoexec_update(Main *UNUSED(bmain),
@@ -4716,21 +4729,15 @@ static void rna_def_userdef_view(BlenderRNA *brna)
   prop = RNA_def_property(srna, "font_path_ui", PROP_STRING, PROP_FILEPATH);
   RNA_def_property_string_sdna(prop, NULL, "font_path_ui");
   RNA_def_property_ui_text(prop, "Interface Font", "Path to interface font");
-  RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update");
+  RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_font_update");
 
   prop = RNA_def_property(srna, "font_path_ui_mono", PROP_STRING, PROP_FILEPATH);
   RNA_def_property_string_sdna(prop, NULL, "font_path_ui_mono");
   RNA_def_property_ui_text(prop, "Mono-space Font", "Path to interface mono-space Font");
-  RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update");
+  RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_font_update");
 
   /* Language. */
 
-  prop = RNA_def_property(srna, "use_international_fonts", PROP_BOOLEAN, PROP_NONE);
-  RNA_def_property_boolean_sdna(prop, NULL, "transopts", USER_DOTRANSLATE);
-  RNA_def_property_ui_text(
-      prop, "Translate UI", "Enable UI translation and use international fonts");
-  RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update");
-
   prop = RNA_def_property(srna, "language", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(prop, rna_enum_language_default_items);
 #  ifdef WITH_INTERNATIONAL



More information about the Bf-blender-cvs mailing list