[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4391] trunk/py/scripts/addons/ ui_translate: Some renaming/cleanup in i18n tools.

Bastien Montagne montagne29 at wanadoo.fr
Tue Mar 19 09:33:58 CET 2013


Revision: 4391
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4391
Author:   mont29
Date:     2013-03-19 08:33:58 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
Some renaming/cleanup in  i18n tools.

Modified Paths:
--------------
    trunk/py/scripts/addons/ui_translate/edit_translation.py
    trunk/py/scripts/addons/ui_translate/settings.py
    trunk/py/scripts/addons/ui_translate/update_svn.py

Modified: trunk/py/scripts/addons/ui_translate/edit_translation.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/edit_translation.py	2013-03-18 23:44:01 UTC (rev 4390)
+++ trunk/py/scripts/addons/ui_translate/edit_translation.py	2013-03-19 08:33:58 UTC (rev 4391)
@@ -21,7 +21,7 @@
 if "bpy" in locals():
     import imp
     imp.reload(settings)
-    imp.reload(i18n_utils)
+    imp.reload(utils_i18n)
 else:
     import bpy
     from bpy.props import (BoolProperty,
@@ -34,7 +34,7 @@
                            StringProperty,
                            )
     from . import settings
-    from bl_i18n_utils import utils as i18n_utils
+    from bl_i18n_utils import utils as utils_i18n
 
 
 import os
@@ -47,7 +47,7 @@
 
 def _get_messages(lang, fname):
     if fname not in PO_CACHE:
-        PO_CACHE[fname] = i18n_utils.I18nMessages(uid=lang, kind='PO', key=fname, src=fname, settings=settings.settings)
+        PO_CACHE[fname] = utils_i18n.I18nMessages(uid=lang, kind='PO', key=fname, src=fname, settings=settings.settings)
     return PO_CACHE[fname]
 
 

Modified: trunk/py/scripts/addons/ui_translate/settings.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/settings.py	2013-03-18 23:44:01 UTC (rev 4390)
+++ trunk/py/scripts/addons/ui_translate/settings.py	2013-03-19 08:33:58 UTC (rev 4391)
@@ -20,7 +20,7 @@
 
 if "bpy" in locals():
     import imp
-    imp.reload(i18n_settings)
+    imp.reload(settings_i18n)
 else:
     import bpy
     from bpy.props import (BoolProperty,
@@ -32,18 +32,18 @@
                            PointerProperty,
                            StringProperty,
                            )
-    from bl_i18n_utils import settings as i18n_settings
+    from bl_i18n_utils import settings as settings_i18n
 
 
 import os
 
 
-settings = i18n_settings.I18nSettings()
+settings = settings_i18n.I18nSettings()
 
 
-class UI_OT_i18n_settings_load(bpy.types.Operator):
+class UI_OT_settings_i18n_load(bpy.types.Operator):
     """Load translations' settings from a persistent JSon file"""
-    bl_idname = "ui.i18n_settings_load"
+    bl_idname = "ui.settings_i18n_load"
     bl_label = "I18n Load Settings"
     bl_option = {'REGISTER'}
 
@@ -66,9 +66,9 @@
         return {'FINISHED'}
 
 
-class UI_OT_i18n_settings_save(bpy.types.Operator):
+class UI_OT_settings_i18n_save(bpy.types.Operator):
     """Save translations' settings in a persistent JSon file"""
-    bl_idname = "ui.i18n_settings_save"
+    bl_idname = "ui.settings_i18n_save"
     bl_label = "I18n Save Settings"
     bl_option = {'REGISTER'}
 
@@ -95,7 +95,7 @@
     print(self, name, val)
     setattr(self, name, val)
 
-class UI_AP_i18n_settings(bpy.types.AddonPreferences):
+class UI_AP_settings_i18n(bpy.types.AddonPreferences):
     bl_idname = __name__.split(".")[0]  # We want "top" module name!
     bl_option = {'REGISTER'}
 
@@ -189,8 +189,8 @@
         col = split.column()
         col.prop(self, "persistent_data_path")
         row = col.row()
-        row.operator("UI_OT_i18n_settings_save", text="Save").filepath = self.persistent_data_path
-        row.operator("UI_OT_i18n_settings_load", text="Load").filepath = self.persistent_data_path
+        row.operator("UI_OT_settings_i18n_save", text="Save").filepath = self.persistent_data_path
+        row.operator("UI_OT_settings_i18n_load", text="Load").filepath = self.persistent_data_path
         col = split.column()
-        col.operator("UI_OT_i18n_settings_save", text="Save Persistent To...")
-        col.operator("UI_OT_i18n_settings_load", text="Load Persistent From...")
+        col.operator("UI_OT_settings_i18n_save", text="Save Persistent To...")
+        col.operator("UI_OT_settings_i18n_load", text="Load Persistent From...")

Modified: trunk/py/scripts/addons/ui_translate/update_svn.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/update_svn.py	2013-03-18 23:44:01 UTC (rev 4390)
+++ trunk/py/scripts/addons/ui_translate/update_svn.py	2013-03-19 08:33:58 UTC (rev 4391)
@@ -21,8 +21,8 @@
 if "bpy" in locals():
     import imp
     imp.reload(settings)
-    imp.reload(i18n_utils)
-    imp.reload(languages_menu_utils)
+    imp.reload(utils_i18n)
+    imp.reload(utils_languages_menu)
 else:
     import bpy
     from bpy.props import (BoolProperty,
@@ -35,8 +35,8 @@
                            StringProperty,
                            )
     from . import settings
-    from bl_i18n_utils import utils as i18n_utils
-    from bl_i18n_utils import languages_menu_utils
+    from bl_i18n_utils import utils as utils_i18n
+    from bl_i18n_utils import utils_languages_menu
 
 from bpy.app.translations import pgettext_iface as iface_
 
@@ -47,14 +47,14 @@
 
 ##### Helpers #####
 def find_best_isocode_matches(uid, iso_codes):
-    tmp = ((e, i18n_utils.locale_match(e, uid)) for e in iso_codes)
+    tmp = ((e, utils_i18n.locale_match(e, uid)) for e in iso_codes)
     return tuple(e[0] for e in sorted((e for e in tmp if e[1] is not ... and e[1] >= 0), key=lambda e: e[1]))
 
 
 ##### Data #####
 class I18nUpdateTranslationLanguage(bpy.types.PropertyGroup):
     """Settings/info about a language"""
-    uid = StringProperty(name="Language ID", default="", description="Iso code, like fr_FR")
+    uid = StringProperty(name="Language ID", default="", description="ISO code, like fr_FR")
     num_id = IntProperty(name="Numeric ID", default=0, min=0, description="Numeric ID (readonly!)")
     name = StringProperty(name="Language Name", default="",
                           description="English language name/label (like \"French (Français)\")")
@@ -173,7 +173,7 @@
                 lng.mo_path_trunk = root_tr_mo.format(isocode)
             else:
                 lng.use = False
-                language, _1, _2, language_country, language_variant = i18n_utils.locale_explode(uid)
+                language, _1, _2, language_country, language_variant = utils_i18n.locale_explode(uid)
                 for isocode in (language, language_variant, language_country, uid):
                     p = os.path.join(root_br, isocode, isocode + ".po")
                     if not os.path.exists(p):
@@ -223,7 +223,7 @@
             "--background",
             "--factory-startup",
             "--python",
-            os.path.join(os.path.dirname(i18n_utils.__file__), "bl_extract_messages.py"),
+            os.path.join(os.path.dirname(utils_i18n.__file__), "bl_extract_messages.py"),
             "--",
             "bl_extract_messages.py",  # arg parser expects first arg to be prog name!
             "--settings",
@@ -233,12 +233,12 @@
             self.report({'ERROR'}, "Message extraction process failed!")
             return {'CANCELLED'}
         # Now we should have a valid POT file, we have to merge it in all languages po's...
-        pot = i18n_utils.I18nMessages(kind='PO', src=self.settings.FILE_NAME_POT, settings=self.settings)
+        pot = utils_i18n.I18nMessages(kind='PO', src=self.settings.FILE_NAME_POT, settings=self.settings)
         for lng in i18n_sett.langs:
             if not lng.use:
                 continue
             if os.path.isfile(lng.po_path):
-                po = i18n_utils.I18nMessages(uid=lng.uid, kind='PO', src=lng.po_path, settings=self.settings)
+                po = utils_i18n.I18nMessages(uid=lng.uid, kind='PO', src=lng.po_path, settings=self.settings)
                 po.update(pot)
             else:
                 po = pot
@@ -267,7 +267,7 @@
                 print("Skipping {} language ({}).".format(lng.name, lng.uid))
                 continue
             print("Processing {} language ({}).".format(lng.name, lng.uid))
-            po = i18n_utils.I18nMessages(uid=lng.uid, kind='PO', src=lng.po_path, settings=self.settings)
+            po = utils_i18n.I18nMessages(uid=lng.uid, kind='PO', src=lng.po_path, settings=self.settings)
             print("Cleaned up {} commented messages.".format(po.clean_commented()))
             errs = po.check(fix=True)
             if errs:
@@ -292,8 +292,8 @@
             uid = po_to_uid.get(po_path, None)
             po_path = os.path.join(self.settings.TRUNK_PO_DIR, po_path)
             if uid and uid not in stats:
-                po = i18n_utils.I18nMessages(uid=uid, kind='PO', src=po_path, settings=self.settings)
+                po = utils_i18n.I18nMessages(uid=uid, kind='PO', src=po_path, settings=self.settings)
                 stats[uid] = po.nbr_trans_msgs / po.nbr_msgs
-        languages_menu_utils.gen_menu_file(stats, self.settings)
+        utils_languages_menu.gen_menu_file(stats, self.settings)
 
         return {'FINISHED'}



More information about the Bf-extensions-cvs mailing list