diff options
-rw-r--r-- | ui_translate/__init__.py | 6 | ||||
-rw-r--r-- | ui_translate/settings.py | 18 | ||||
-rw-r--r-- | ui_translate/update_addon.py | 51 | ||||
-rw-r--r-- | ui_translate/update_svn.py | 23 |
4 files changed, 33 insertions, 65 deletions
diff --git a/ui_translate/__init__.py b/ui_translate/__init__.py index 8c7e66c8..99f608b4 100644 --- a/ui_translate/__init__.py +++ b/ui_translate/__init__.py @@ -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"} diff --git a/ui_translate/settings.py b/ui_translate/settings.py index 34195e68..07479f08 100644 --- a/ui_translate/settings.py +++ b/ui_translate/settings.py @@ -41,9 +41,9 @@ import os 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 @@ class UI_OT_settings_i18n_load(bpy.types.Operator): 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 @@ def _setattr(self, name, val): 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 @@ class UI_AP_settings_i18n(bpy.types.AddonPreferences): 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...") diff --git a/ui_translate/update_addon.py b/ui_translate/update_addon.py index d2626735..217d9bdf 100644 --- a/ui_translate/update_addon.py +++ b/ui_translate/update_addon.py @@ -89,55 +89,6 @@ def enum_addons(self, context): 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 @@ class UI_OT_i18n_addon_translation_update(bpy.types.Operator): # 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) diff --git a/ui_translate/update_svn.py b/ui_translate/update_svn.py index bb9bbdb2..ef148c5a 100644 --- a/ui_translate/update_svn.py +++ b/ui_translate/update_svn.py @@ -59,6 +59,8 @@ class UI_OT_i18n_updatetranslation_svn_branches(bpy.types.Operator): 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 @@ class UI_OT_i18n_updatetranslation_svn_branches(bpy.types.Operator): "--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 @@ class UI_OT_i18n_updatetranslation_svn_branches(bpy.types.Operator): 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 @@ class UI_OT_i18n_updatetranslation_svn_trunk(bpy.types.Operator): # '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 @@ class UI_OT_i18n_updatetranslation_svn_trunk(bpy.types.Operator): 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 @@ class UI_OT_i18n_updatetranslation_svn_trunk(bpy.types.Operator): 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 @@ class UI_OT_i18n_updatetranslation_svn_statistics(bpy.types.Operator): lst += [(lng, lng.po_path_trunk) for lng in i18n_sett.langs if lng.uid not in self.settings.IMPORT_LANGUAGES_SKIP] - for lng, path in lst: + context.window_manager.progress_begin(0, len(lst)) + context.window_manager.progress_update(0) + for progress, (lng, path) in enumerate(lst): + context.window_manager.progress_update(progress + 1) if not lng.use: print("Skipping {} language ({}).".format(lng.name, lng.uid)) continue @@ -196,6 +212,7 @@ class UI_OT_i18n_updatetranslation_svn_statistics(bpy.types.Operator): data = data + "\n" + buff.getvalue() text.from_string(data) self.report({'INFO'}, "Info written to {} text datablock!".format(self.report_name)) + context.window_manager.progress_end() return {'FINISHED'} |