def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string bl_hash = bpy.app.build_hash bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), "%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, settings=settings) msgs = pot.msgs # Enable all wanted addons. # For now, enable all official addons, before extracting msgids. addons = utils.enable_addons(support={"OFFICIAL"}) # Note this is not needed if we have been started with factory settings, but just in case... utils.enable_addons(support={"COMMUNITY", "TESTING"}, disable=True) reports = _gen_reports(_gen_check_ctxt(settings) if do_checks else None) # Get strings from RNA. dump_rna_messages(msgs, reports, settings) # Get strings from UI layout definitions text="..." args. dump_py_messages(msgs, reports, addons, settings) # Get strings from C source code. dump_src_messages(msgs, reports, settings) # Get strings from addons' categories. for uid, label, tip in bpy.types.WindowManager.addon_filter[1]['items'](bpy.context.window_manager, bpy.context): process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings) if tip: process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings) # Get strings specific to translations' menu. for lng in settings.LANGUAGES: process_msg(msgs, settings.DEFAULT_CONTEXT, lng[1], "Languages’ labels from bl_i18n_utils/settings.py", reports, None, settings) for cat in settings.LANGUAGES_CATEGORIES: process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1], "Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings) # pot.check() pot.unescape() # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) # pot.check() if do_messages: print("Writing messages…") pot.write('PO', settings.FILE_NAME_POT) print("Finished extracting UI messages!") return pot # Not used currently, but may be useful later (and to be consistent with dump_addon_messages!).
def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string bl_rev = bpy.app.build_revision bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), "%Y-%m-%dT%H:%M:%S") pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, bl_ver, bl_rev, bl_date, bl_date.year, settings=settings) msgs = pot.msgs # Enable all wanted addons. # For now, enable all official addons, before extracting msgids. addons = utils.enable_addons(support={"OFFICIAL"}) # Note this is not needed if we have been started with factory settings, but just in case... utils.enable_addons(support={"COMMUNITY", "TESTING"}, disable=True) reports = _gen_reports(_gen_check_ctxt(settings) if do_checks else None) # Get strings from RNA. dump_rna_messages(msgs, reports, settings) # Get strings from UI layout definitions text="..." args. dump_py_messages(msgs, reports, addons, settings) # Get strings from C source code. dump_src_messages(msgs, reports, settings) # Get strings from addons' categories. for uid, label, tip in bpy.types.WindowManager.addon_filter[1]['items'](bpy.context.window_manager, bpy.context): process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Addons' categories", reports, None, settings) if tip: process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Addons' categories", reports, None, settings) # Get strings specific to translations' menu. for lng in settings.LANGUAGES: process_msg(msgs, settings.DEFAULT_CONTEXT, lng[1], "Languages’ labels from bl_i18n_utils/settings.py", reports, None, settings) for cat in settings.LANGUAGES_CATEGORIES: process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1], "Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings) #pot.check() pot.unescape() # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) #pot.check() if do_messages: print("Writing messages…") pot.write('PO', settings.FILE_NAME_POT) print("Finished extracting UI messages!") return pot # Not used currently, but may be useful later (and to be consistent with dump_addon_messages!).
def dump_messages(do_messages, do_checks, settings): bl_ver = "Blender " + bpy.app.version_string bl_hash = bpy.app.build_hash bl_date = datetime.datetime.strptime(bpy.app.build_date.decode() + "T" + bpy.app.build_time.decode(), "%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, settings=settings) msgs = pot.msgs # Enable all wanted addons. # For now, enable all official addons, before extracting msgids. addons = utils.enable_addons(support={"OFFICIAL"}) # Note this is not needed if we have been started with factory settings, but just in case... # XXX This is not working well, spent a whole day trying to understand *why* we still have references of # those removed calsses in things like `bpy.types.OperatorProperties.__subclasses__()` # (could not even reproduce it from regular py console in Blender with UI...). # For some reasons, cleanup does not happen properly, *and* we have no way to tell which class is valid # and which has been unregistered. So for now, just go for the dirty, easy way: do not disable add-ons. :( # ~ utils.enable_addons(support={"COMMUNITY", "TESTING"}, disable=True) reports = _gen_reports(_gen_check_ctxt(settings) if do_checks else None) # Get strings from RNA. dump_rna_messages(msgs, reports, settings) # Get strings from UI layout definitions text="..." args. dump_py_messages(msgs, reports, addons, settings) # Get strings from C source code. dump_src_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, bpy.context, ): process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings) if tip: process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings) # Get strings specific to translations' menu. for lng in settings.LANGUAGES: process_msg(msgs, settings.DEFAULT_CONTEXT, lng[1], "Languages’ labels from bl_i18n_utils/settings.py", reports, None, settings) for cat in settings.LANGUAGES_CATEGORIES: process_msg(msgs, settings.DEFAULT_CONTEXT, cat[1], "Language categories’ labels from bl_i18n_utils/settings.py", reports, None, settings) # pot.check() pot.unescape() # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) # pot.check() if do_messages: print("Writing messages…") pot.write('PO', settings.FILE_NAME_POT) print("Finished extracting UI messages!") return pot # Not used currently, but may be useful later (and to be consistent with dump_addon_messages!).
def validate_module(op, context): module_name = op.module_name addon = getattr(context, "active_addon", None) if addon: module_name = addon.module if not module_name: op.report({'ERROR'}, "No addon module given!") return None, None mod = utils_i18n.enable_addons(addons={module_name}, check_only=True) if not mod: op.report({'ERROR'}, "Addon '{}' not found!".format(module_name)) return None, None return module_name, mod[0]
def validate_module(op, context): module_name = op.module_name addon = getattr(context, "active_addon", None) if addon: module_name = addon.module if not module_name: op.report({'ERROR'}, "No add-on module given!") return None, None mod = utils_i18n.enable_addons(addons={module_name}, check_only=True) if not mod: op.report({'ERROR'}, "Add-on '{}' not found!".format(module_name)) return None, None return module_name, mod[0]
def dump_addon_messages(module_name, do_checks, settings): import addon_utils # Get current addon state (loaded or not): was_loaded = addon_utils.check(module_name)[1] # Enable our addon. addon = utils.enable_addons(addons={module_name})[0] addon_info = addon_utils.module_bl_info(addon) ver = addon_info["name"] + " " + ".".join( str(v) for v in addon_info["version"]) rev = 0 date = datetime.datetime.now() pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, ver, rev, date, date.year, settings=settings) msgs = pot.msgs minus_pot = utils.I18nMessages.gen_empty_messages( settings.PARSER_TEMPLATE_ID, ver, rev, date, date.year, settings=settings) minus_msgs = minus_pot.msgs check_ctxt = _gen_check_ctxt(settings) if do_checks else None minus_check_ctxt = _gen_check_ctxt(settings) if do_checks else None # Get strings from RNA, our addon being enabled. print("A") reports = _gen_reports(check_ctxt) print("B") dump_rna_messages(msgs, reports, settings) print("C") # Now disable our addon, and rescan RNA. utils.enable_addons(addons={module_name}, disable=True) print("D") reports["check_ctxt"] = minus_check_ctxt print("E") dump_rna_messages(minus_msgs, reports, settings) print("F") # Restore previous state if needed! if was_loaded: utils.enable_addons(addons={module_name}) # and make the diff! for key in minus_msgs: if key != settings.PO_HEADER_KEY: del msgs[key] if check_ctxt: _diff_check_ctxt(check_ctxt, minus_check_ctxt) # and we are done with those! del minus_pot del minus_msgs del minus_check_ctxt # get strings from UI layout definitions text="..." args reports["check_ctxt"] = check_ctxt dump_py_messages(msgs, reports, {addon}, settings, addons_only=True) pot.unescape( ) # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) print("Finished extracting UI messages!") return pot
def dump_addon_messages(module_name, do_checks, settings): import addon_utils # Get current addon state (loaded or not): was_loaded = addon_utils.check(module_name)[1] # Enable our addon. addon = utils.enable_addons(addons={module_name})[0] addon_info = addon_utils.module_bl_info(addon) ver = addon_info["name"] + " " + ".".join(str(v) for v in addon_info["version"]) rev = 0 date = datetime.datetime.now() pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, ver, rev, date, date.year, settings=settings) msgs = pot.msgs minus_pot = utils.I18nMessages.gen_empty_messages(settings.PARSER_TEMPLATE_ID, ver, rev, date, date.year, settings=settings) minus_msgs = minus_pot.msgs check_ctxt = _gen_check_ctxt(settings) if do_checks else None minus_check_ctxt = _gen_check_ctxt(settings) if do_checks else None # Get strings from RNA, our addon being enabled. print("A") reports = _gen_reports(check_ctxt) print("B") dump_rna_messages(msgs, reports, settings) print("C") # Now disable our addon, and rescan RNA. utils.enable_addons(addons={module_name}, disable=True) print("D") reports["check_ctxt"] = minus_check_ctxt print("E") dump_rna_messages(minus_msgs, reports, settings) print("F") # Restore previous state if needed! if was_loaded: utils.enable_addons(addons={module_name}) # and make the diff! for key in minus_msgs: if key != settings.PO_HEADER_KEY: del msgs[key] if check_ctxt: _diff_check_ctxt(check_ctxt, minus_check_ctxt) # and we are done with those! del minus_pot del minus_msgs del minus_check_ctxt # get strings from UI layout definitions text="..." args reports["check_ctxt"] = check_ctxt dump_py_messages(msgs, reports, {addon}, settings, addons_only=True) pot.unescape() # Strings gathered in py/C source code may contain escaped chars... print_info(reports, pot) print("Finished extracting UI messages!") return pot