diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-29 18:10:42 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-06-29 18:10:42 +0300 |
commit | 58d6cbba6da31db8dc8a2b42d528b9a353081904 (patch) | |
tree | 04b57a2f809c6f08d84a082edf061f3ece631860 /release/scripts/modules/bl_i18n_utils | |
parent | 94549adec4b6857fb6ec4cf77606da51ff7c26b7 (diff) | |
parent | 295d0c52a26730edc6d4ed1276e4051cce006be5 (diff) |
Merge branch 'master' into temp-ghash-setopstemp-ghash-setops
Diffstat (limited to 'release/scripts/modules/bl_i18n_utils')
5 files changed, 49 insertions, 30 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py index c3b2ae9908b..43a09a1acbd 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -64,7 +64,7 @@ def _gen_check_ctxt(settings): def _diff_check_ctxt(check_ctxt, minus_check_ctxt): - """Returns check_ctxt - minus_check_ctxt""" + """Removes minus_check_ctxt from check_ctxt""" for key in check_ctxt: if isinstance(check_ctxt[key], set): for warning in minus_check_ctxt[key]: @@ -576,8 +576,9 @@ def dump_py_messages_from_files(msgs, reports, files, settings): #print(func_translate_args) # Break recursive nodes look up on some kind of nodes. - # E.g. we don’t want to get strings inside subscripts (blah["foo"])! - stopper_nodes = {ast.Subscript} + # E.g. we don't want to get strings inside subscripts (blah["foo"])! + # we don't want to get strings from comparisons (foo.type == 'BAR'). + stopper_nodes = {ast.Subscript, ast.Compare} # Consider strings separate: ("a" if test else "b") separate_nodes = {ast.IfExp} @@ -897,7 +898,7 @@ def dump_addon_messages(module_name, do_checks, settings): del msgs[key] if check_ctxt: - check_ctxt = _diff_check_ctxt(check_ctxt, minus_check_ctxt) + _diff_check_ctxt(check_ctxt, minus_check_ctxt) # and we are done with those! del minus_pot @@ -924,18 +925,18 @@ def main(): return import sys - back_argv = sys.argv + import argparse + # Get rid of Blender args! - sys.argv = sys.argv[sys.argv.index("--") + 1:] + argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [] - import argparse parser = argparse.ArgumentParser(description="Process UI messages from inside Blender.") parser.add_argument('-c', '--no_checks', default=True, action="store_false", help="No checks over UI messages.") parser.add_argument('-m', '--no_messages', default=True, action="store_false", help="No export of UI messages.") parser.add_argument('-o', '--output', default=None, help="Output POT file path.") parser.add_argument('-s', '--settings', default=None, help="Override (some) default settings. Either a JSon file name, or a JSon string.") - args = parser.parse_args() + args = parser.parse_args(argv) settings = settings_i18n.I18nSettings() settings.from_json(args.settings) @@ -945,8 +946,6 @@ def main(): dump_messages(do_messages=args.no_messages, do_checks=args.no_checks, settings=settings) - sys.argv = back_argv - if __name__ == "__main__": print("\n\n *** Running {} *** \n".format(__file__)) diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 920a56a628b..1c960a217de 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -88,6 +88,7 @@ LANGUAGES = ( (38, "Uzbek (Oʻzbek)", "uz_UZ"), (39, "Uzbek Cyrillic (Ўзбек)", "uz_UZ@cyrillic"), (40, "Hindi (मानक हिन्दी)", "hi_IN"), + (41, "Vietnamese (tiếng Việt)", "vi_VN"), ) # Default context, in py! @@ -324,6 +325,7 @@ WARN_MSGID_NOT_CAPITALIZED_ALLOWED = { "y", # Sub-strings. "available with", + "brown fox", "can't save image while rendering", "expected a timeline/animation area to be active", "expected a view3d region", @@ -332,6 +334,8 @@ WARN_MSGID_NOT_CAPITALIZED_ALLOWED = { "image file not found", "image path can't be written to", "in memory to enable editing!", + "jumps over", + "the lazy dog", "unable to load movie clip", "unable to load text", "unable to open the file", @@ -412,6 +416,15 @@ REL_TRUNK_PO_DIR = os.path.join(REL_TRUNK_DIR, "po") # The /trunk/mo path (relative to I18N_DIR). REL_TRUNK_MO_DIR = os.path.join(REL_TRUNK_DIR, "locale") + +# The path to the *git* translation repository (relative to SOURCE_DIR). +REL_GIT_I18N_DIR = os.path.join("release/datafiles/locale") + + +# The /po path of the *git* translation repository (relative to REL_GIT_I18N_DIR). +REL_GIT_I18N_PO_DIR = os.path.join("po") + + # The Blender source path to check for i18n macros (relative to SOURCE_DIR). REL_POTFILES_SOURCE_DIR = os.path.join("source") @@ -493,14 +506,6 @@ def _gen_get_set_path(ref, name): return _get, _set -def _gen_get_set_paths(ref, name): - def _get(self): - return [_do_get(getattr(self, ref), p) for p in getattr(self, name)] - def _set(self, value): - setattr(self, name, [_do_set(getattr(self, ref), p) for p in value]) - return _get, _set - - class I18nSettings: """ Class allowing persistence of our settings! @@ -552,6 +557,8 @@ class I18nSettings: TRUNK_DIR = property(*(_gen_get_set_path("I18N_DIR", "REL_TRUNK_DIR"))) TRUNK_PO_DIR = property(*(_gen_get_set_path("I18N_DIR", "REL_TRUNK_PO_DIR"))) TRUNK_MO_DIR = property(*(_gen_get_set_path("I18N_DIR", "REL_TRUNK_MO_DIR"))) + GIT_I18N_ROOT = property(*(_gen_get_set_path("SOURCE_DIR", "REL_GIT_I18N_DIR"))) + GIT_I18N_PO_DIR = property(*(_gen_get_set_path("GIT_I18N_ROOT", "REL_GIT_I18N_PO_DIR"))) POTFILES_SOURCE_DIR = property(*(_gen_get_set_path("SOURCE_DIR", "REL_POTFILES_SOURCE_DIR"))) FILE_NAME_POT = property(*(_gen_get_set_path("I18N_DIR", "REL_FILE_NAME_POT"))) MO_PATH_ROOT = property(*(_gen_get_set_path("I18N_DIR", "REL_MO_PATH_ROOT"))) diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 524fef909e8..5fdb6b88cbf 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -162,7 +162,7 @@ def get_po_files_from_dir(root_dir, langs=set()): yield uid, po_file -def enable_addons(addons={}, support={}, disable=False, check_only=False): +def enable_addons(addons=None, support=None, disable=False, check_only=False): """ Enable (or disable) addons based either on a set of names, or a set of 'support' types. Returns the list of all affected addons (as fake modules)! @@ -170,6 +170,11 @@ def enable_addons(addons={}, support={}, disable=False, check_only=False): """ import addon_utils + if addons is None: + addons = {} + if support is None: + support = {} + userpref = bpy.context.user_preferences used_ext = {ext.module for ext in userpref.addons} @@ -212,13 +217,13 @@ class I18nMessage: __slots__ = ("msgctxt_lines", "msgid_lines", "msgstr_lines", "comment_lines", "is_fuzzy", "is_commented", "settings") - def __init__(self, msgctxt_lines=[], msgid_lines=[], msgstr_lines=[], comment_lines=[], + def __init__(self, msgctxt_lines=None, msgid_lines=None, msgstr_lines=None, comment_lines=None, is_commented=False, is_fuzzy=False, settings=settings): self.settings = settings - self.msgctxt_lines = msgctxt_lines - self.msgid_lines = msgid_lines - self.msgstr_lines = msgstr_lines - self.comment_lines = comment_lines + self.msgctxt_lines = msgctxt_lines or [] + self.msgid_lines = msgid_lines or [] + self.msgstr_lines = msgstr_lines or [] + self.comment_lines = comment_lines or [] self.is_fuzzy = is_fuzzy self.is_commented = is_commented @@ -976,13 +981,13 @@ class I18nMessages: def write(self, kind, dest): self.writers[kind](self, dest) - def write_messages_to_po(self, fname): + def write_messages_to_po(self, fname, compact=False): """ Write messages in fname po file. """ default_context = self.settings.DEFAULT_CONTEXT - def _write(self, f): + def _write(self, f, compact): _msgctxt = self.settings.PO_MSGCTXT _msgid = self.settings.PO_MSGID _msgstr = self.settings.PO_MSGSTR @@ -991,9 +996,12 @@ class I18nMessages: self.escape() for num, msg in enumerate(self.msgs.values()): - f.write("\n".join(msg.comment_lines)) + if compact and (msg.is_commented or msg.is_fuzzy or not msg.msgstr_lines): + continue + if not compact: + f.write("\n".join(msg.comment_lines)) # Only mark as fuzzy if msgstr is not empty! - if msg.is_fuzzy and msg.msgstr: + if msg.is_fuzzy and msg.msgstr_lines: f.write("\n" + self.settings.PO_COMMENT_FUZZY) _p = _comm if msg.is_commented else "" chunks = [] @@ -1030,10 +1038,10 @@ class I18nMessages: self.normalize(max_len=0) # No wrapping for now... if isinstance(fname, str): with open(fname, 'w', encoding="utf-8") as f: - _write(self, f) + _write(self, f, compact) # Else assume fname is already a file(like) object! else: - _write(self, fname) + _write(self, fname, compact) def write_messages_to_mo(self, fname): """ @@ -1112,6 +1120,7 @@ class I18nMessages: writers = { "PO": write_messages_to_po, + "PO_COMPACT": lambda s, fn: s.write_messages_to_po(fn, True), "MO": write_messages_to_mo, } diff --git a/release/scripts/modules/bl_i18n_utils/utils_languages_menu.py b/release/scripts/modules/bl_i18n_utils/utils_languages_menu.py index 24255d9be61..4f499476ad9 100755 --- a/release/scripts/modules/bl_i18n_utils/utils_languages_menu.py +++ b/release/scripts/modules/bl_i18n_utils/utils_languages_menu.py @@ -95,3 +95,5 @@ def gen_menu_file(stats, settings): data_lines.append("# {} #{}:{}:{}".format(FLAG_MESSAGES[flag], uid_num, label, uid)) with open(os.path.join(settings.TRUNK_MO_DIR, settings.LANGUAGES_FILE), 'w') as f: f.write("\n".join(data_lines)) + with open(os.path.join(settings.GIT_I18N_ROOT, settings.LANGUAGES_FILE), 'w') as f: + f.write("\n".join(data_lines)) diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py index cdb3a3fedb5..42a23c8c041 100644 --- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py +++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py @@ -125,6 +125,7 @@ class SpellChecker: "multisampling", "multitexture", "multiuser", + "multiview", "namespace", "keyconfig", "online", @@ -186,6 +187,7 @@ class SpellChecker: "unhide", "unindent", "unkeyed", + "unmute", "unpremultiply", "unprojected", "unreacted", |