Skip to content
Snippets Groups Projects
Commit bedce097 authored by Bastien Montagne's avatar Bastien Montagne
Browse files

UI Translate: add operator & button to cleanup branches.

parent e3c9be92
Branches
Tags
No related merge requests found
......@@ -21,7 +21,7 @@
bl_info = {
"name": "Manage UI translations",
"author": "Bastien Montagne",
"version": (1, 1, 5),
"version": (1, 2, 0),
"blender": (2, 80, 0),
"location": "Main \"File\" menu, text editor, any UI control",
"description": "Allows managing UI translations directly from Blender "
......
......@@ -48,13 +48,11 @@ class UI_OT_i18n_updatetranslation_svn_branches(Operator):
bl_idname = "ui.i18n_updatetranslation_svn_branches"
bl_label = "Update I18n Branches"
# Operator Arguments
use_skip_pot_gen: BoolProperty(
name="Skip POT",
description="Skip POT file generation",
default=False,
)
# /End Operator Arguments
def execute(self, context):
if not hasattr(self, "settings"):
......@@ -110,6 +108,40 @@ class UI_OT_i18n_updatetranslation_svn_branches(Operator):
return wm.invoke_props_dialog(self)
class UI_OT_i18n_cleanuptranslation_svn_branches(Operator):
"""Clean up i18n svn's branches (po files)"""
bl_idname = "ui.i18n_cleanuptranslation_svn_branches"
bl_label = "Clean up I18n Branches"
def execute(self, context):
if not hasattr(self, "settings"):
self.settings = settings.settings
i18n_sett = context.window_manager.i18n_update_svn_settings
# 'DEFAULT' and en_US are always valid, fully-translated "languages"!
stats = {"DEFAULT": 1.0, "en_US": 1.0}
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 not lng.use:
print("Skipping {} language ({}).".format(lng.name, lng.uid))
continue
print("Processing {} language ({}).".format(lng.name, lng.uid))
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:
print("Errors in this po, solved as best as possible!")
print("\t" + "\n\t".join(errs))
po.write(kind="PO", dest=lng.po_path)
print("\n")
context.window_manager.progress_end()
return {'FINISHED'}
class UI_OT_i18n_updatetranslation_svn_trunk(Operator):
"""Update i18n svn's branches (po files)"""
bl_idname = "ui.i18n_updatetranslation_svn_trunk"
......@@ -176,7 +208,6 @@ class UI_OT_i18n_updatetranslation_svn_statistics(Operator):
bl_idname = "ui.i18n_updatetranslation_svn_statistics"
bl_label = "Update I18n Statistics"
# Operator Arguments
use_branches: BoolProperty(
name="Check Branches",
description="Check po files in branches",
......@@ -188,7 +219,6 @@ class UI_OT_i18n_updatetranslation_svn_statistics(Operator):
description="Check po files in trunk",
default=False,
)
# /End Operator Arguments
report_name = "i18n_info.txt"
......@@ -242,6 +272,7 @@ class UI_OT_i18n_updatetranslation_svn_statistics(Operator):
classes = (
UI_OT_i18n_updatetranslation_svn_branches,
UI_OT_i18n_cleanuptranslation_svn_branches,
UI_OT_i18n_updatetranslation_svn_trunk,
UI_OT_i18n_updatetranslation_svn_statistics,
)
......@@ -178,6 +178,8 @@ class UI_PT_i18n_update_translations_settings(Panel):
col.separator()
col.operator("ui.i18n_updatetranslation_svn_branches", text="Update Branches")
col.operator("ui.i18n_updatetranslation_svn_trunk", text="Update Trunk")
col.separator()
col.operator("ui.i18n_cleanuptranslation_svn_branches", text="Clean up Branches")
col.operator("ui.i18n_updatetranslation_svn_statistics", text="Statistics")
if i18n_sett.active_lang >= 0 and i18n_sett.active_lang < len(i18n_sett.langs):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment