[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [4483] trunk/py/scripts/addons/ ui_translate: Some cleanups and fixes, and use new "progressbar" api for main translation operators (which can be rather long), thanks Gaia! :)
Bastien Montagne
montagne29 at wanadoo.fr
Fri Apr 19 18:24:18 CEST 2013
Revision: 4483
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=4483
Author: mont29
Date: 2013-04-19 16:24:18 +0000 (Fri, 19 Apr 2013)
Log Message:
-----------
Some cleanups and fixes, and use new "progressbar" api for main translation operators (which can be rather long), thanks Gaia! :)
Modified Paths:
--------------
trunk/py/scripts/addons/ui_translate/__init__.py
trunk/py/scripts/addons/ui_translate/settings.py
trunk/py/scripts/addons/ui_translate/update_addon.py
trunk/py/scripts/addons/ui_translate/update_svn.py
Modified: trunk/py/scripts/addons/ui_translate/__init__.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/__init__.py 2013-04-18 15:41:01 UTC (rev 4482)
+++ trunk/py/scripts/addons/ui_translate/__init__.py 2013-04-19 16:24:18 UTC (rev 4483)
@@ -21,13 +21,13 @@
bl_info = {
"name": "Manage UI translations",
"author": "Bastien Montagne",
- "version": (1, 1, 0),
- "blender": (2, 66, 5),
+ "version": (1, 1, 1),
+ "blender": (2, 66, 6),
"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.)",
"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/Addon",
+ "wiki_url": "http://wiki.blender.org/index.php/Dev:Doc/How_to/Translate_Blender",
"tracker_url": "http://projects.blender.org/tracker/?atid=498&group_id=9&func=browse",
"support": 'OFFICIAL',
"category": "System"}
Modified: trunk/py/scripts/addons/ui_translate/settings.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/settings.py 2013-04-18 15:41:01 UTC (rev 4482)
+++ trunk/py/scripts/addons/ui_translate/settings.py 2013-04-19 16:24:18 UTC (rev 4483)
@@ -41,9 +41,9 @@
settings = settings_i18n.I18nSettings()
-class UI_OT_settings_i18n_load(bpy.types.Operator):
+class UI_OT_i18n_settings_load(bpy.types.Operator):
"""Load translations' settings from a persistent JSon file"""
- bl_idname = "ui.settings_i18n_load"
+ bl_idname = "ui.i18n_settings_load"
bl_label = "I18n Load Settings"
bl_option = {'REGISTER'}
@@ -66,9 +66,9 @@
return {'FINISHED'}
-class UI_OT_settings_i18n_save(bpy.types.Operator):
+class UI_OT_i18n_settings_save(bpy.types.Operator):
"""Save translations' settings in a persistent JSon file"""
- bl_idname = "ui.settings_i18n_save"
+ bl_idname = "ui.i18n_settings_save"
bl_label = "I18n Save Settings"
bl_option = {'REGISTER'}
@@ -95,7 +95,7 @@
print(self, name, val)
setattr(self, name, val)
-class UI_AP_settings_i18n(bpy.types.AddonPreferences):
+class UI_AP_i18n_settings(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_settings_i18n_save", text="Save").filepath = self.persistent_data_path
- row.operator("UI_OT_settings_i18n_load", text="Load").filepath = self.persistent_data_path
+ row.operator("ui.i18n_settings_save", text="Save").filepath = self.persistent_data_path
+ row.operator("ui.i18n_settings_load", text="Load").filepath = self.persistent_data_path
col = split.column()
- col.operator("UI_OT_settings_i18n_save", text="Save Persistent To...")
- col.operator("UI_OT_settings_i18n_load", text="Load Persistent From...")
+ col.operator("ui.i18n_settings_save", text="Save Persistent To...")
+ col.operator("ui.i18n_settings_load", text="Load Persistent From...")
Modified: trunk/py/scripts/addons/ui_translate/update_addon.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/update_addon.py 2013-04-18 15:41:01 UTC (rev 4482)
+++ trunk/py/scripts/addons/ui_translate/update_addon.py 2013-04-19 16:24:18 UTC (rev 4483)
@@ -89,55 +89,6 @@
return items
-##### Data #####
-
-
-##### UI #####
-#class UI_PT_i18n_update_translations_settings(bpy.types.Panel):
- #bl_label = "I18n Update Translation Main"
- #bl_space_type = "PROPERTIES"
- #bl_region_type = "WINDOW"
- #bl_context = "render"
-#
- #def draw(self, context):
- #layout = self.layout
- #i18n_sett = context.window_manager.i18n_update_svn_settings
-#
- #if not i18n_sett.is_init and bpy.ops.ui.i18n_updatetranslation_svn_init_settings.poll():
- #bpy.ops.ui.i18n_updatetranslation_svn_init_settings()
-#
- #if not i18n_sett.is_init:
- #layout.label(text="Could not init languages data!")
- #layout.label(text="Please edit the preferences of the UI Translate addon")
- #else:
- #split = layout.split(0.75)
- #split.template_list("UI_UL_i18n_languages", "", i18n_sett, "langs", i18n_sett, "active_lang", rows=8)
- #col = split.column()
- #col.operator("ui.i18n_updatetranslation_svn_init_settings", text="Reset Settings")
- #if any(l.use for l in i18n_sett.langs):
- #col.operator("ui.i18n_updatetranslation_svn_settings_select", text="Deselect All").use_select = False
- #else:
- #col.operator("ui.i18n_updatetranslation_svn_settings_select", text="Select All").use_select = True
- #col.operator("ui.i18n_updatetranslation_svn_settings_select", text="Invert Selection").use_invert = True
- #col.separator()
- #col.operator("ui.i18n_updatetranslation_svn_branches", text="Update Branches")
- #col.operator("ui.i18n_updatetranslation_svn_trunk", text="Update Trunk")
- #col.operator("ui.i18n_updatetranslation_svn_statistics", text="Statistics")
-#
- #if i18n_sett.active_lang >= 0 and i18n_sett.active_lang < len(i18n_sett.langs):
- #lng = i18n_sett.langs[i18n_sett.active_lang]
- #col = layout.column()
- #col.active = lng.use
- #row = col.row()
- #row.label(text="[{}]: \"{}\" ({})".format(lng.uid, iface_(lng.name), lng.num_id), translate=False)
- #row.prop(lng, "use", text="")
- #col.prop(lng, "po_path")
- #col.prop(lng, "po_path_trunk")
- #col.prop(lng, "mo_path_trunk")
- #layout.separator()
- #layout.prop(i18n_sett, "pot_path")
-
-
##### Operators #####
# This one is a helper one, as we sometimes need another invoke function (like e.g. file selection)...
class UI_OT_i18n_addon_translation_invoke(bpy.types.Operator):
@@ -182,7 +133,7 @@
# influence over the final result).
pot = bl_extract_messages.dump_addon_messages(module_name, True, self.settings)
- # Now (try do) get current i18n data from the addon...
+ # Now (try to) get current i18n data from the addon...
path = mod.__file__
if path.endswith("__init__.py"):
path = os.path.dirname(path)
Modified: trunk/py/scripts/addons/ui_translate/update_svn.py
===================================================================
--- trunk/py/scripts/addons/ui_translate/update_svn.py 2013-04-18 15:41:01 UTC (rev 4482)
+++ trunk/py/scripts/addons/ui_translate/update_svn.py 2013-04-19 16:24:18 UTC (rev 4483)
@@ -59,6 +59,8 @@
i18n_sett = context.window_manager.i18n_update_svn_settings
self.settings.FILE_NAME_POT = i18n_sett.pot_path
+ context.window_manager.progress_begin(0, len(i18n_sett.langs) + 1)
+ context.window_manager.progress_update(0)
if not self.use_skip_pot_gen:
# Generate base pot from RNA messages (we use another blender instance here, to be able to perfectly
# control our environment (factory startup, specific addons enabled/disabled...)).
@@ -74,13 +76,18 @@
"--settings",
self.settings.to_json(),
)
+ # Not working (UI is not refreshed...).
+ #self.report({'INFO'}, "Extracting messages, this will take some time...")
+ context.window_manager.progress_update(1)
if subprocess.call(cmmd):
self.report({'ERROR'}, "Message extraction process failed!")
+ context.window_manager.progress_end()
return {'CANCELLED'}
# Now we should have a valid POT file, we have to merge it in all languages po's...
pot = utils_i18n.I18nMessages(kind='PO', src=self.settings.FILE_NAME_POT, settings=self.settings)
- for lng in i18n_sett.langs:
+ for progress, lng in enumerate(i18n_sett.langs):
+ context.window_manager.progress_update(progress + 2)
if not lng.use:
continue
if os.path.isfile(lng.po_path):
@@ -90,6 +97,7 @@
po = pot
po.write(kind="PO", dest=lng.po_path)
print("{} PO written!".format(lng.uid))
+ context.window_manager.progress_end()
return {'FINISHED'}
def invoke(self, context, event):
@@ -109,7 +117,10 @@
# 'DEFAULT' and en_US are always valid, fully-translated "languages"!
stats = {"DEFAULT": 1.0, "en_US": 1.0}
- for lng in i18n_sett.langs:
+ context.window_manager.progress_begin(0, len(i18n_sett.langs) + 1)
+ context.window_manager.progress_update(0)
+ for progress, lng in enumerate(i18n_sett.langs):
+ context.window_manager.progress_update(progress + 1)
if lng.uid in self.settings.IMPORT_LANGUAGES_SKIP:
print("Skipping {} language ({}), edit settings if you want to enable it.".format(lng.name, lng.uid))
continue
@@ -136,6 +147,7 @@
shutil.copy2(self.settings.FILE_NAME_POT, self.settings.TRUNK_PO_DIR)
print("Generating languages' menu...")
+ context.window_manager.progress_update(progress + 2)
# First complete our statistics by checking po files we did not touch this time!
po_to_uid = {os.path.basename(lng.po_path): lng.uid for lng in i18n_sett.langs}
for po_path in os.listdir(self.settings.TRUNK_PO_DIR):
@@ -145,6 +157,7 @@
po = utils_i18n.I18nMessages(uid=uid, kind='PO', src=po_path, settings=self.settings)
stats[uid] = po.nbr_trans_msgs / po.nbr_msgs
utils_languages_menu.gen_menu_file(stats, self.settings)
+ context.window_manager.progress_end()
return {'FINISHED'}
@@ -173,7 +186,10 @@
lst += [(lng, lng.po_path_trunk) for lng in i18n_sett.langs
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list