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
This commit is contained in:
Damien Picard
2022-08-01 14:09:41 +02:00
committed by Bastien Montagne
parent 543b47f162
commit 3239cea726
3 changed files with 29 additions and 1 deletions

View File

@@ -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,