I18n: Allow translation of extension tags and permissions
The new extension system introduces tags, similar to categories from legacy add-ons, and permissions. A hardcoded list is supported for each, available in the docs: - https://docs.blender.org/manual/en/dev/advanced/extensions/tags.html - https://developer.blender.org/docs/features/extensions/schema/ This change allows extraction of these new metadata to the translation files. In order to disambiguate the new messages, tags use the new "Script" translation context. Permissions are lower case, so there is a low risk of collision, and they use the default context. While the tags are defined per-platform, with extensions.blender.org being the only one available currently, they are extracted as a single list. Pull Request: https://projects.blender.org/blender/blender/pulls/123150
This commit is contained in:
parent
e23e5443e7
commit
4719ce5d56
@ -826,7 +826,7 @@ def extensions_panel_draw_impl(
|
||||
# As it happens dictionary keys & list values both iterate over string,
|
||||
# however we will want to show the dictionary values eventually.
|
||||
if (value := item_remote.permissions):
|
||||
col_b.label(text=", ".join([iface_(x.title()) for x in value]), translate=False)
|
||||
col_b.label(text=", ".join([iface_(x).title() for x in value]), translate=False)
|
||||
else:
|
||||
col_b.label(text="No permissions specified")
|
||||
del value
|
||||
@ -1183,6 +1183,7 @@ def tags_refresh(wm):
|
||||
|
||||
def tags_panel_draw(panel, context):
|
||||
from bpy.utils import escape_identifier
|
||||
from bpy.app.translations import contexts as i18n_contexts
|
||||
layout = panel.layout
|
||||
wm = context.window_manager
|
||||
tags_sorted = tags_refresh(wm)
|
||||
@ -1194,7 +1195,12 @@ def tags_panel_draw(panel, context):
|
||||
for i, t in enumerate(sorted(tags_sorted)):
|
||||
if i == tags_len_half:
|
||||
col = split.column()
|
||||
col.prop(wm.extension_tags, "[\"{:s}\"]".format(escape_identifier(t)))
|
||||
col.prop(
|
||||
wm.extension_tags,
|
||||
"[\"{:s}\"]".format(escape_identifier(t)),
|
||||
text=t,
|
||||
text_ctxt=i18n_contexts.editor_preferences,
|
||||
)
|
||||
|
||||
|
||||
def extensions_repo_active_draw(self, _context):
|
||||
|
16
scripts/modules/_bpy_internal/extensions/permissions.py
Normal file
16
scripts/modules/_bpy_internal/extensions/permissions.py
Normal file
@ -0,0 +1,16 @@
|
||||
# SPDX-FileCopyrightText: 2024 Blender Authors
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# The purpose of this list is to present the permissions to be picked up by translation.
|
||||
|
||||
# The initial list of permissions is the one defined in the manifest schema
|
||||
# (https://developer.blender.org/docs/features/extensions/schema/).
|
||||
|
||||
permissions = [
|
||||
"camera",
|
||||
"clipboard",
|
||||
"files",
|
||||
"microphone",
|
||||
"network",
|
||||
]
|
@ -9,6 +9,7 @@
|
||||
# Other platforms can send PRs to extend this list further.
|
||||
|
||||
addons = {
|
||||
"All", # Added automatically for legacy add-ons without a category.
|
||||
"3D View",
|
||||
"Add Curve",
|
||||
"Add Mesh",
|
||||
@ -23,13 +24,13 @@ addons = {
|
||||
"Import-Export",
|
||||
"Lighting",
|
||||
"Material",
|
||||
"Modeling",
|
||||
"Mesh",
|
||||
"Modeling",
|
||||
"Node",
|
||||
"Object",
|
||||
"Paint",
|
||||
"Pipeline",
|
||||
"Physics",
|
||||
"Pipeline",
|
||||
"Render",
|
||||
"Rigging",
|
||||
"Scene",
|
||||
|
@ -1039,6 +1039,24 @@ def dump_addon_bl_info(msgs, reports, module, settings):
|
||||
)
|
||||
|
||||
|
||||
def dump_extension_metadata(msgs, reports, settings):
|
||||
from _bpy_internal.extensions import (
|
||||
tags,
|
||||
permissions,
|
||||
)
|
||||
i18n_contexts = bpy.app.translations.contexts
|
||||
|
||||
# Extract tags for add-on and theme extensions.
|
||||
for tag in sorted(tags.addons):
|
||||
process_msg(msgs, i18n_contexts.editor_preferences, tag, "Add-on extension tag", reports, None, settings)
|
||||
for tag in sorted(tags.themes):
|
||||
process_msg(msgs, i18n_contexts.editor_preferences, tag, "Theme extension tag", reports, None, settings)
|
||||
|
||||
# Extract extension permissions.
|
||||
for permission in sorted(permissions.permissions):
|
||||
process_msg(msgs, settings.DEFAULT_CONTEXT, permission, "Extension permission", reports, None, settings)
|
||||
|
||||
|
||||
##### Main functions! #####
|
||||
def dump_messages(do_messages, do_checks, settings):
|
||||
bl_ver = "Blender " + bpy.app.version_string
|
||||
@ -1104,6 +1122,9 @@ def dump_messages(do_messages, do_checks, settings):
|
||||
process_msg(msgs, settings.DEFAULT_CONTEXT, label, "Add-ons' categories", reports, None, settings)
|
||||
process_msg(msgs, settings.DEFAULT_CONTEXT, tip, "Add-ons' categories", reports, None, settings)
|
||||
|
||||
# Get strings from extension tags and permissions.
|
||||
dump_extension_metadata(msgs, reports, 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",
|
||||
|
Loading…
Reference in New Issue
Block a user