[Bf-extensions-cvs] [b3f7398f] blender2.8: UI Translate: update to 2.8

Ines Almeida noreply at git.blender.org
Sun Nov 11 15:05:37 CET 2018


Commit: b3f7398f28756551efbc9fcb8b64b83a81401f88
Author: Ines Almeida
Date:   Sun Nov 11 15:01:36 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBAb3f7398f28756551efbc9fcb8b64b83a81401f88

UI Translate: update to 2.8

Make operator properties into variable annotations.
Cleanup includes and descriptions.
PEP-8 compliance pass.

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

M	ui_translate/__init__.py
M	ui_translate/edit_translation.py
M	ui_translate/settings.py
M	ui_translate/update_addon.py
M	ui_translate/update_svn.py
M	ui_translate/update_ui.py

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

diff --git a/ui_translate/__init__.py b/ui_translate/__init__.py
index 5ac0db95..4029bae1 100644
--- a/ui_translate/__init__.py
+++ b/ui_translate/__init__.py
@@ -21,11 +21,11 @@
 bl_info = {
     "name": "Manage UI translations",
     "author": "Bastien Montagne",
-    "version": (1, 1, 4),
-    "blender": (2, 79, 0),
+    "version": (1, 1, 5),
+    "blender": (2, 80, 0),
     "location": "Main \"File\" menu, text editor, any UI control",
-    "description": "Allow to manage UI translations directly from Blender "
-        "(update main po files, update scripts' translations, etc.)",
+    "description": "Allows managing UI translations directly from Blender "
+        "(update main .po files, update scripts' translations, etc.)",
     "warning": "Still in development, not all features are fully implemented yet!",
     "wiki_url": "http://wiki.blender.org/index.php/Dev:Doc/How_to/Translate_Blender",
     "support": 'OFFICIAL',
@@ -42,15 +42,12 @@ if "bpy" in locals():
 else:
     import bpy
     from . import (
-            settings,
-            edit_translation,
-            update_svn,
-            update_addon,
-            update_ui,
-            )
-
-
-import os
+        settings,
+        edit_translation,
+        update_svn,
+        update_addon,
+        update_ui,
+    )
 
 
 classes = settings.classes + edit_translation.classes + update_svn.classes + update_addon.classes + update_ui.classes
@@ -59,18 +56,21 @@ classes = settings.classes + edit_translation.classes + update_svn.classes + upd
 def register():
     for cls in classes:
         bpy.utils.register_class(cls)
+
     bpy.types.WindowManager.i18n_update_svn_settings = \
-                    bpy.props.PointerProperty(type=update_ui.I18nUpdateTranslationSettings)
+        bpy.props.PointerProperty(type=update_ui.I18nUpdateTranslationSettings)
 
     # Init addon's preferences (unfortunately, as we are using an external storage for the properties,
     # the load/save user preferences process has no effect on them :( ).
     if __name__ in bpy.context.user_preferences.addons:
         pref = bpy.context.user_preferences.addons[__name__].preferences
+        import os
         if os.path.isfile(pref.persistent_data_path):
             pref._settings.load(pref.persistent_data_path, reset=True)
 
 
 def unregister():
-    del bpy.types.WindowManager.i18n_update_svn_settings
     for cls in classes:
         bpy.utils.unregister_class(cls)
+
+    del bpy.types.WindowManager.i18n_update_svn_settings
diff --git a/ui_translate/edit_translation.py b/ui_translate/edit_translation.py
index c66e2fac..8fdf676a 100644
--- a/ui_translate/edit_translation.py
+++ b/ui_translate/edit_translation.py
@@ -18,30 +18,24 @@
 
 # <pep8 compliant>
 
+import os
+import shutil
 if "bpy" in locals():
     import importlib
     importlib.reload(settings)
     importlib.reload(utils_i18n)
 else:
     import bpy
+    from bpy.types import Operator
     from bpy.props import (
-            BoolProperty,
-            CollectionProperty,
-            EnumProperty,
-            FloatProperty,
-            FloatVectorProperty,
-            IntProperty,
-            PointerProperty,
-            StringProperty,
-            )
+        BoolProperty,
+        EnumProperty,
+        StringProperty,
+    )
     from . import settings
     from bl_i18n_utils import utils as utils_i18n
 
 
-import os
-import shutil
-
-
 # A global cache for I18nMessages objects, as parsing po files takes a few seconds.
 PO_CACHE = {}
 
@@ -52,21 +46,30 @@ def _get_messages(lang, fname):
     return PO_CACHE[fname]
 
 
-class UI_OT_i18n_edittranslation_update_mo(bpy.types.Operator):
-    """Try to "compile" given po file into relevant blender.mo file """ \
-    """(WARNING: it will replace the official mo file in your user dir!)"""
+class UI_OT_i18n_edittranslation_update_mo(Operator):
+    """Try to "compile" given po file into relevant blender.mo file
+    (WARNING: it will replace the official mo file in your user dir!)"""
     bl_idname = "ui.i18n_edittranslation_update_mo"
     bl_label = "Edit Translation Update Mo"
 
-    # "Parameters"
-    lang = StringProperty(description="Current (translated) language",
-                          options={'SKIP_SAVE'})
-    po_file = StringProperty(description="Path to the matching po file",
-                             subtype='FILE_PATH', options={'SKIP_SAVE'})
-    clean_mo = BoolProperty(description="Clean up (remove) all local "
-                                        "translation files, to be able to use "
-                                        "all system's ones again",
-                            default=False, options={'SKIP_SAVE'})
+    # Operator Arguments
+    lang: StringProperty(
+        description="Current (translated) language",
+        options={'SKIP_SAVE'},
+    )
+
+    po_file: StringProperty(
+        description="Path to the matching po file",
+        subtype='FILE_PATH',
+        options={'SKIP_SAVE'},
+    )
+
+    clean_mo: BoolProperty(
+        description="Remove all local translation files, to be able to use the system ones again",
+        default=False,
+        options={'SKIP_SAVE'}
+    )
+    # /End Operator Arguments
 
     def execute(self, context):
         if self.clean_mo:
@@ -85,65 +88,169 @@ class UI_OT_i18n_edittranslation_update_mo(bpy.types.Operator):
         return {'FINISHED'}
 
 
-class UI_OT_i18n_edittranslation(bpy.types.Operator):
-    """Translate the label and tooltip of the property defined by given 'parameters'"""
+class UI_OT_i18n_edittranslation(Operator):
+    """Translate the label and tooltip of the given property"""
     bl_idname = "ui.edittranslation"
     bl_label = "Edit Translation"
 
-    # "Parameters"
-    but_label = StringProperty(description="Label of the control", options={'SKIP_SAVE'})
-    rna_label = StringProperty(description="RNA-defined label of the control, if any", options={'SKIP_SAVE'})
-    enum_label = StringProperty(description="Label of the enum item of the control, if any", options={'SKIP_SAVE'})
-    but_tip = StringProperty(description="Tip of the control", options={'SKIP_SAVE'})
-    rna_tip = StringProperty(description="RNA-defined tip of the control, if any", options={'SKIP_SAVE'})
-    enum_tip = StringProperty(description="Tip of the enum item of the control, if any", options={'SKIP_SAVE'})
-    rna_struct = StringProperty(description="Identifier of the RNA struct, if any", options={'SKIP_SAVE'})
-    rna_prop = StringProperty(description="Identifier of the RNA property, if any", options={'SKIP_SAVE'})
-    rna_enum = StringProperty(description="Identifier of the RNA enum item, if any", options={'SKIP_SAVE'})
-    rna_ctxt = StringProperty(description="RNA context for label", options={'SKIP_SAVE'})
-
-    lang = StringProperty(description="Current (translated) language", options={'SKIP_SAVE'})
-    po_file = StringProperty(description="Path to the matching po file", subtype='FILE_PATH', options={'SKIP_SAVE'})
+    # Operator Arguments
+    but_label: StringProperty(
+        description="Label of the control",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_label: StringProperty(
+        description="RNA-defined label of the control, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    enum_label: StringProperty(
+        description="Label of the enum item of the control, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    but_tip: StringProperty(
+        description="Tip of the control",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_tip: StringProperty(
+        description="RNA-defined tip of the control, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    enum_tip: StringProperty(
+        description="Tip of the enum item of the control, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_struct: StringProperty(
+        description="Identifier of the RNA struct, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_prop: StringProperty(
+        description="Identifier of the RNA property, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_enum: StringProperty(
+        description="Identifier of the RNA enum item, if any",
+        options={'SKIP_SAVE'},
+    )
+
+    rna_ctxt: StringProperty(
+        description="RNA context for label",
+        options={'SKIP_SAVE'},
+    )
+
+    lang: StringProperty(
+        description="Current (translated) language",
+        options={'SKIP_SAVE'},
+    )
+
+    po_file: StringProperty(
+        description="Path to the matching po file",
+        subtype='FILE_PATH',
+        options={'SKIP_SAVE'},
+    )
 
     # Found in po file.
-    org_but_label = StringProperty(description="Original label of the control", options={'SKIP_SAVE'})
-    org_rna_label = StringProperty(description="Original RNA-defined label of the control, if any",
-                                   options={'SKIP_SAVE'})
-    org_enum_label = StringProperty(description="Original label of the enum item of the control, if any",
-                                    options={'SKIP_SAVE'})
-    org_but_tip = StringProperty(description="Original tip of the control", options={'SKIP_SAVE'})
-    org_rna_tip = StringProperty(description="Original RNA-defined tip of the control, if any", options={'SKIP_SAVE'})
-    org_enum_tip = StringProperty(description="Original tip of the enum item of the control, if any",
-                                  options={'SKIP_SAVE'})
-
-    flag_items = (('FUZZY', "Fuzzy", "Message is marked as fuzzy in po file"),
-                  ('ERROR', "Error", "Some error occurred with this message"),
-                 )
-    but_label_flags = EnumProperty(items=flag_items, description="Flags about the label of the button",
-                                   options={'SKIP_SAVE', 'ENUM_FLAG'})
-    rna_label_flags = EnumProperty(items=flag_items, description="Flags about the RNA-defined label of the button",
-                                   options={'SKIP_SAVE', 'ENUM_FLAG'})
-    enum_label_flags = EnumProperty(items=flag_items, description="Flags about the RNA enum item label of the button",
-                                    options={'SKIP_SAVE', 'ENUM_FLAG'})
-    but_tip_flags = EnumProperty(items=flag_items, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list