Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
| Show First 20 Lines • Show All 847 Lines • ▼ Show 20 Lines | for root, dirs, files in os.walk(settings.POTFILES_SOURCE_DIR): | ||||
| elif rel_path not in forced: | elif rel_path not in forced: | ||||
| forced.add(rel_path) | forced.add(rel_path) | ||||
| for rel_path in sorted(forced): | for rel_path in sorted(forced): | ||||
| path = os.path.join(settings.SOURCE_DIR, rel_path) | path = os.path.join(settings.SOURCE_DIR, rel_path) | ||||
| if os.path.exists(path): | if os.path.exists(path): | ||||
| dump_src_file(path, rel_path, 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! ##### | ##### Main functions! ##### | ||||
| def dump_messages(do_messages, do_checks, settings): | def dump_messages(do_messages, do_checks, settings): | ||||
| bl_ver = "Blender " + bpy.app.version_string | bl_ver = "Blender " + bpy.app.version_string | ||||
| bl_hash = bpy.app.build_hash | bl_hash = bpy.app.build_hash | ||||
| bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), | bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), | ||||
| "%Y-%m-%dT%H:%M:%S") | "%Y-%m-%dT%H:%M:%S") | ||||
| pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_hash, bl_date, bl_date.year, | pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_hash, bl_date, bl_date.year, | ||||
| settings=settings) | settings=settings) | ||||
| Show All 16 Lines | def dump_messages(do_messages, do_checks, settings): | ||||
| dump_rna_messages(msgs, reports, settings) | dump_rna_messages(msgs, reports, settings) | ||||
| # Get strings from UI layout definitions text="..." args. | # Get strings from UI layout definitions text="..." args. | ||||
| dump_py_messages(msgs, reports, addons, settings) | dump_py_messages(msgs, reports, addons, settings) | ||||
| # Get strings from C source code. | # Get strings from C source code. | ||||
| dump_src_messages(msgs, reports, settings) | dump_src_messages(msgs, reports, settings) | ||||
| # Get strings from presets. | |||||
| dump_preset_messages(msgs, reports, settings) | |||||
| # Get strings from addons' categories. | # Get strings from addons' categories. | ||||
| for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items']( | for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items']( | ||||
| bpy.context.window_manager, | bpy.context.window_manager, | ||||
| bpy.context, | bpy.context, | ||||
| ): | ): | ||||
| process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings) | process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings) | ||||
| if tip: | if tip: | ||||
| process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings) | process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings) | ||||
| ▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines | |||||