From 3239cea726c7409f9fc6be53c078c3087a76c233 Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Mon, 1 Aug 2022 14:09:41 +0200 Subject: I18n: make presets translatable Presets are used all over the Blender UI, but were so far untranslatable. This adds the translation code as well as a new `dump_preset_messages()` function in the message extraction. This goes over all bundled preset file names and extracts them. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15570 --- .../modules/bl_i18n_utils/bl_extract_messages.py | 22 ++++++++++++++++++++++ release/scripts/modules/bl_i18n_utils/settings.py | 4 ++++ release/scripts/modules/bpy_types.py | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'release') 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 bfc111dd3c1..d7755532614 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -853,6 +853,25 @@ def dump_src_messages(msgs, reports, settings): dump_src_file(path, rel_path, msgs, reports, settings) +def dump_preset_messages(msgs, reports, settings): + files = [] + for dpath, _, fnames in os.walk(settings.PRESETS_DIR): + for fname in fnames: + if fname.startswith("_") or not fname.endswith(".py"): + continue + path = os.path.join(dpath, fname) + try: # can't always find the relative path (between drive letters on windows) + rel_path = os.path.relpath(path, settings.PRESETS_DIR) + except ValueError: + rel_path = path + files.append(rel_path) + for rel_path in files: + msgsrc, msgid = os.path.split(rel_path) + msgsrc = "Preset from " + msgsrc + msgid = bpy.path.display_name(msgid, title_case=False) + process_msg(msgs, settings.DEFAULT_CONTEXT, msgid, msgsrc, reports, None, settings) + + ##### Main functions! ##### def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string @@ -885,6 +904,9 @@ def dump_messages(do_messages, do_checks, settings): # Get strings from C source code. dump_src_messages(msgs, reports, settings) + # Get strings from presets. + dump_preset_messages(msgs, reports, settings) + # Get strings from addons' categories. for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items']( bpy.context.window_manager, diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 3b69f8a6bf7..8d6d4fb5d3b 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -514,6 +514,9 @@ 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") +# Where to search for preset names (relative to SOURCE_DIR). +REL_PRESETS_DIR = os.path.join("release", "scripts", "presets") + # The template messages file (relative to I18N_DIR). REL_FILE_NAME_POT = os.path.join(REL_BRANCHES_DIR, DOMAIN + ".pot") @@ -672,6 +675,7 @@ class I18nSettings: 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"))) + PRESETS_DIR = property(*(_gen_get_set_path("SOURCE_DIR", "REL_PRESETS_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"))) MO_PATH_TEMPLATE = property(*(_gen_get_set_path("I18N_DIR", "REL_MO_PATH_TEMPLATE"))) diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index df0631ec26d..87b32eb1f40 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -1074,6 +1074,7 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): - preset_operator_defaults (dict of keyword args) """ import bpy + from bpy.app.translations import pgettext_iface as iface_ ext_valid = getattr(self, "preset_extensions", {".py", ".xml"}) props_default = getattr(self, "preset_operator_defaults", None) add_operator = getattr(self, "preset_add_operator", None) @@ -1083,7 +1084,8 @@ class Menu(StructRNA, _GenericUI, metaclass=RNAMeta): props_default=props_default, filter_ext=lambda ext: ext.lower() in ext_valid, add_operator=add_operator, - display_name=lambda name: bpy.path.display_name(name, title_case=False) + display_name=lambda name: iface_( + bpy.path.display_name(name, title_case=False)) ) @classmethod -- cgit v1.2.3 From afd1357aa8c5dbfa15fedc79abe2fecb6f630fec Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 1 Aug 2022 14:36:06 +0200 Subject: tweaks & fixes to UI messages. --- release/scripts/modules/bl_i18n_utils/settings.py | 4 +++- release/scripts/modules/bl_i18n_utils/utils_spell_check.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'release') diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 8d6d4fb5d3b..fb60b07a657 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -366,7 +366,7 @@ WARN_MSGID_NOT_CAPITALIZED_ALLOWED = { "all and invert unselected", "and AMD driver version 22.10 or newer", "and AMD Radeon Pro 21.Q4 driver or newer", - "and Linux driver version xx.xx.28000 or newer", + "and Linux driver version xx.xx.23570 or newer", "and NVIDIA driver version 470 or newer", "and Windows driver version 101.1660 or newer", "available with", @@ -396,11 +396,13 @@ WARN_MSGID_NOT_CAPITALIZED_ALLOWED = { "jumps over", "left", "local", + "matrices", "no matrices", "multi-res modifier", "non-triangle face", "normal", "or AMD with macOS 12.3 or newer", "performance impact!", + "positions", "no positions", "read", "remove", "right", 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 462c954d54a..a2fe2dd42ba 100644 --- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py +++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py @@ -533,6 +533,7 @@ class SpellChecker: "tonemap", "toon", "transmissive", + "uvproject", "vividlight", "volumetrics", "voronoi", -- cgit v1.2.3