Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
| Show First 20 Lines • Show All 901 Lines • ▼ Show 20 Lines | def dump_template_messages(msgs, reports, settings): | ||||
| msgctxt = i18n_contexts.id_workspace | msgctxt = i18n_contexts.id_workspace | ||||
| for workspace_name in sorted(workspace_names): | for workspace_name in sorted(workspace_names): | ||||
| for msgsrc in sorted(workspace_names[workspace_name]): | for msgsrc in sorted(workspace_names[workspace_name]): | ||||
| msgsrc = "Workspace from template " + msgsrc | msgsrc = "Workspace from template " + msgsrc | ||||
| process_msg(msgs, msgctxt, workspace_name, msgsrc, | process_msg(msgs, msgctxt, workspace_name, msgsrc, | ||||
| reports, None, settings) | reports, None, settings) | ||||
| def dump_addon_bl_info(msgs, reports, module, settings): | |||||
| for prop in ('name', 'location', 'description'): | |||||
| process_msg(msgs, settings.DEFAULT_CONTEXT, module.bl_info[prop], "Add-on " + module.bl_info['name'] + " info: " + prop, 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 22 Lines | def dump_messages(do_messages, do_checks, settings): | ||||
| dump_src_messages(msgs, reports, settings) | dump_src_messages(msgs, reports, settings) | ||||
| # Get strings from presets. | # Get strings from presets. | ||||
| dump_preset_messages(msgs, reports, settings) | dump_preset_messages(msgs, reports, settings) | ||||
| # Get strings from startup templates. | # Get strings from startup templates. | ||||
| dump_template_messages(msgs, reports, settings) | dump_template_messages(msgs, reports, settings) | ||||
| # Get strings from addons' bl_info. | |||||
| import addon_utils | |||||
| for module in addon_utils.modules(): | |||||
| if module.bl_info['support'] != 'OFFICIAL': | |||||
| continue | |||||
mont29: Would be a bit more specific here, something like this maybe?
`Add-on " + module.bl_info… | |||||
| dump_addon_bl_info(msgs, reports, module, 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 80 Lines • ▼ Show 20 Lines | def dump_addon_messages(module_name, do_checks, settings): | ||||
| del minus_pot | del minus_pot | ||||
| del minus_msgs | del minus_msgs | ||||
| del minus_check_ctxt | del minus_check_ctxt | ||||
| # get strings from UI layout definitions text="..." args | # get strings from UI layout definitions text="..." args | ||||
| reports["check_ctxt"] = check_ctxt | reports["check_ctxt"] = check_ctxt | ||||
| dump_py_messages(msgs, reports, {addon}, settings, addons_only=True) | dump_py_messages(msgs, reports, {addon}, settings, addons_only=True) | ||||
| # Get strings from the addon's bl_info | |||||
| dump_addon_bl_info(msgs, reports, addon, settings) | |||||
| pot.unescape() # Strings gathered in py/C source code may contain escaped chars... | pot.unescape() # Strings gathered in py/C source code may contain escaped chars... | ||||
| print_info(reports, pot) | print_info(reports, pot) | ||||
| print("Finished extracting UI messages!") | print("Finished extracting UI messages!") | ||||
| return pot | return pot | ||||
| Show All 33 Lines | |||||
Would be a bit more specific here, something like this maybe?
Add-on " + module.bl_info['name'] + "info: " + prop