[Bf-blender-cvs] [73bfd8058f7] master: I18n: make add-ons' info translatable

Damien Picard noreply at git.blender.org
Mon Aug 29 14:12:32 CEST 2022


Commit: 73bfd8058f7506fa50f806227256f11ec8eeab85
Author: Damien Picard
Date:   Mon Aug 29 14:02:24 2022 +0200
Branches: master
https://developer.blender.org/rB73bfd8058f7506fa50f806227256f11ec8eeab85

I18n: make add-ons' info translatable

The info provided by add-ons is very valuable to users, yet it wasn’t translatable yet.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D15747

===================================================================

M	release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
M	release/scripts/startup/bl_ui/space_userpref.py

===================================================================

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 fc7cbe566c3..683ca2bc5fe 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -907,6 +907,11 @@ def dump_template_messages(msgs, reports, 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! #####
 def dump_messages(do_messages, do_checks, settings):
     bl_ver = "Blender " + bpy.app.version_string
@@ -945,6 +950,13 @@ def dump_messages(do_messages, do_checks, settings):
     # Get strings from startup templates.
     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
+        dump_addon_bl_info(msgs, reports, module, settings)
+
     # Get strings from addons' categories.
     for uid, label, tip in bpy.types.WindowManager.addon_filter.keywords['items'](
             bpy.context.window_manager,
@@ -1041,6 +1053,9 @@ def dump_addon_messages(module_name, do_checks, settings):
     reports["check_ctxt"] = check_ctxt
     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...
     print_info(reports, pot)
 
diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py
index 1b155d22bdf..1b71b503eb7 100644
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@ -1928,10 +1928,12 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
 
             if is_visible:
                 if search and not (
-                        (search in info["name"].lower()) or
+                        (search in info["name"].lower() or
+                         search in iface_(info["name"]).lower()) or
                         (info["author"] and (search in info["author"].lower())) or
-                        ((filter == "All") and (search in info["category"].lower()))
-                ):
+                        ((filter == "All") and (search in info["category"].lower() or
+                                                search in iface_(info["category"]).lower()))
+                        ):
                     continue
 
                 # Addon UI Code
@@ -1954,7 +1956,7 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
 
                 sub = row.row()
                 sub.active = is_enabled
-                sub.label(text="%s: %s" % (info["category"], info["name"]))
+                sub.label(text=iface_("%s: %s") % (iface_(info["category"]), iface_(info["name"])))
 
                 if info["warning"]:
                     sub.label(icon='ERROR')
@@ -1967,11 +1969,11 @@ class USERPREF_PT_addons(AddOnPanel, Panel):
                     if info["description"]:
                         split = colsub.row().split(factor=0.15)
                         split.label(text="Description:")
-                        split.label(text=info["description"])
+                        split.label(text=tip_(info["description"]))
                     if info["location"]:
                         split = colsub.row().split(factor=0.15)
                         split.label(text="Location:")
-                        split.label(text=info["location"])
+                        split.label(text=tip_(info["location"]))
                     if mod:
                         split = colsub.row().split(factor=0.15)
                         split.label(text="File:")



More information about the Bf-blender-cvs mailing list