diff options
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/bl_extract_messages.py | 27 | ||||
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/settings.py | 5 |
2 files changed, 32 insertions, 0 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 9f22b2417ed..f6dc2ae7ca0 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -8,6 +8,7 @@ import datetime import os import re import sys +import glob # XXX Relative import does not work here when used from Blender... from bl_i18n_utils import settings as settings_i18n, utils @@ -883,6 +884,29 @@ def dump_preset_messages(msgs, reports, settings): process_msg(msgs, settings.DEFAULT_CONTEXT, msgid, msgsrc, reports, None, settings) +def dump_template_messages(msgs, reports, settings): + bfiles = [""] # General template, no name needed + bfiles += glob.glob(settings.TEMPLATES_DIR + "/**/*.blend", recursive=True) + + workspace_names = {} + + for bfile in bfiles: + template = os.path.dirname(bfile) + template = os.path.basename(template) + bpy.ops.wm.read_homefile(use_factory_startup=True, app_template=template) + for ws in bpy.data.workspaces: + names = workspace_names.setdefault(ws.name, []) + names.append(template or "General") + + from bpy.app.translations import contexts as i18n_contexts + msgctxt = i18n_contexts.id_workspace + for workspace_name in sorted(workspace_names): + for msgsrc in sorted(workspace_names[workspace_name]): + msgsrc = "Workspace from template " + msgsrc + process_msg(msgs, msgctxt, workspace_name, msgsrc, + reports, None, settings) + + ##### Main functions! ##### def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string @@ -918,6 +942,9 @@ def dump_messages(do_messages, do_checks, settings): # Get strings from presets. dump_preset_messages(msgs, reports, settings) + # Get strings from startup templates. + dump_template_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 fb60b07a657..05db4df7cd2 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -519,6 +519,10 @@ 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") +# Where to search for templates (relative to SOURCE_DIR). +REL_TEMPLATES_DIR = os.path.join("release", "scripts", "startup", + "bl_app_templates_system") + # The template messages file (relative to I18N_DIR). REL_FILE_NAME_POT = os.path.join(REL_BRANCHES_DIR, DOMAIN + ".pot") @@ -678,6 +682,7 @@ class I18nSettings: 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"))) + TEMPLATES_DIR = property(*(_gen_get_set_path("SOURCE_DIR", "REL_TEMPLATES_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"))) |