I18n: Extract and disambiguate a few messages

Extract
- Cycles denoiser enum.
- Extensions user preferences UI.
- Node operator poll message from new node function.

Improve
- Split "(Enabled|Disabled) on startup, overriding the preference."
into two messages.

Disambiguate
- "Add" when describing the action of adding something should use the
  Operator context.
- "Dimensions", in noise textures.
- "Transform" as a noun, the matrix transform type of Geometry Nodes,
  as opposed to the verb to move things in space.
- "Parent" as a noun or verb (the parent of an object, to parent an
  object to another).

Some issues reported by Satoshi Yamasaki, deathblood, and Gabriel Gazzán.

Pull Request: https://projects.blender.org/blender/blender/pulls/122969
This commit is contained in:
Damien Picard 2024-06-13 12:15:55 +02:00 committed by Bastien Montagne
parent 77a69d04f2
commit f87d4e4e40
21 changed files with 106 additions and 47 deletions

@ -16,7 +16,8 @@ from bpy.props import (
)
from bpy.app.translations import (
contexts as i18n_contexts,
pgettext_rpt as rpt_
pgettext_tip as n_,
pgettext_rpt as rpt_,
)
from math import pi
@ -263,13 +264,14 @@ def enum_openimagedenoise_denoiser(self, context):
import _cycles
if _cycles.with_openimagedenoise:
return [('OPENIMAGEDENOISE', "OpenImageDenoise",
"Use Intel OpenImageDenoise AI denoiser", 4)]
n_("Use Intel OpenImageDenoise AI denoiser"), 4)]
return []
def enum_optix_denoiser(self, context):
if not context or bool(context.preferences.addons[__package__].preferences.get_devices_for_type('OPTIX')):
return [('OPTIX', "OptiX", "Use the OptiX AI denoiser with GPU acceleration, only available on NVIDIA GPUs when configured in the system tab in the user preferences", 2)]
return [('OPTIX', "OptiX", n_(
"Use the OptiX AI denoiser with GPU acceleration, only available on NVIDIA GPUs when configured in the system tab in the user preferences"), 2)]
return []
@ -281,11 +283,11 @@ def enum_preview_denoiser(self, context):
items = [
('AUTO',
"Automatic",
("Use GPU accelerated denoising if supported, for the best performance. "
"Prefer OpenImageDenoise over OptiX"),
n_("Use GPU accelerated denoising if supported, for the best performance. "
"Prefer OpenImageDenoise over OptiX"),
0)]
else:
items = [('AUTO', "None", "Blender was compiled without a viewport denoiser", 0)]
items = [('AUTO', "None", n_("Blender was compiled without a viewport denoiser"), 0)]
items += optix_items
items += oidn_items

@ -16,6 +16,8 @@ import os
import bpy
import sys
from bpy.app.translations import pgettext_rpt as rpt_
from . import bl_extension_ops
from . import bl_extension_utils
@ -349,7 +351,7 @@ class NotifyHandle:
def ui_text(self):
if self.sync_info is None:
return "Checking for Extension Updates", 'SORTTIME', WM_EXTENSIONS_UPDATE_CHECKING
return rpt_("Checking for Extension Updates"), 'SORTTIME', WM_EXTENSIONS_UPDATE_CHECKING
status_data, update_count, extra_warnings = self.sync_info
text, icon = bl_extension_utils.CommandBatch.calc_status_text_icon_from_data(
status_data, update_count,

@ -107,6 +107,7 @@ def extensions_panel_draw_legacy_addons(
import addon_utils
from bpy.app.translations import (
pgettext_iface as iface_,
pgettext_tip as tip_,
)
from .bl_extension_ops import (
pkg_info_check_exclude_filter_ex,
@ -165,9 +166,9 @@ def extensions_panel_draw_legacy_addons(
sub.active = is_enabled
if module_parent_dirname(mod.__file__) == "addons_core":
sub.label(text="Core: " + bl_info["name"], translate=False)
sub.label(text=iface_("Core:") + " " + iface_(bl_info["name"]), translate=False)
else:
sub.label(text="Legacy: " + bl_info["name"], translate=False)
sub.label(text=iface_("Legacy:") + " " + iface_(bl_info["name"]), translate=False)
if bl_info["warning"]:
sub.label(icon='ERROR')
@ -186,7 +187,10 @@ def extensions_panel_draw_legacy_addons(
col_b = split.column()
if bl_info["description"]:
col_a.label(text="{:s}.".format(bl_info["description"]))
col_a.label(
text="{:s}.".format(tip_(bl_info["description"])),
translate=False,
)
if bl_info["doc_url"] or bl_info.get("tracker_url"):
sub = box.row()
@ -226,7 +230,7 @@ def extensions_panel_draw_legacy_addons(
col_b.label(text=".".join(str(x) for x in value), translate=False)
if value := bl_info["warning"]:
col_a.label(text="Warning")
col_b.label(text=" " + iface_(value), icon='ERROR')
col_b.label(text=" " + iface_(value), icon='ERROR', translate=False)
del value
col_a.label(text="File")
@ -509,6 +513,7 @@ def extensions_panel_draw_impl(
import os
from bpy.app.translations import (
pgettext_iface as iface_,
pgettext_tip as tip_,
)
from .bl_extension_ops import (
blender_extension_mark,
@ -777,7 +782,7 @@ def extensions_panel_draw_impl(
col_b = split.column()
# The full tagline may be multiple lines (not yet supported by Blender's UI).
col_a.label(text="{:s}.".format(item_remote.tagline), translate=False)
col_a.label(text="{:s}.".format(tip_(item_remote.tagline)), translate=False)
if value := item_remote.website:
# Use half size button, for legacy add-ons there are two, here there is one
@ -992,6 +997,7 @@ def extensions_panel_draw(panel, context):
prefs = context.preferences
from bpy.app.translations import pgettext_iface as iface_
from .bl_extension_ops import (
blender_filter_by_type_map,
)
@ -1035,7 +1041,7 @@ def extensions_panel_draw(panel, context):
# Don't clip longer names.
row = box.split(factor=0.9, align=True)
if repo_status_text.running:
row.label(text=repo_status_text.title + "...", icon='INFO')
row.label(text=iface_(repo_status_text.title) + "...", icon='INFO', translate=False)
else:
row.label(text=repo_status_text.title, icon='INFO')
if show_development_reports:
@ -1053,16 +1059,28 @@ def extensions_panel_draw(panel, context):
factor=progress / progress_range,
text="{:s}, {:s}".format(
sizes_as_percentage_string(progress, progress_range),
msg_str,
iface_(msg_str),
),
translate=False,
)
elif progress_unit == 'BYTE':
boxsub.progress(factor=0.0, text="{:s}, {:s}".format(msg_str, size_as_fmt_string(progress)))
boxsub.progress(
factor=0.0,
text="{:s}, {:s}".format(iface_(msg_str), size_as_fmt_string(progress)),
translate=False,
)
else:
# We might want to support other types.
boxsub.progress(factor=0.0, text="{:s}, {:d}".format(msg_str, progress))
boxsub.progress(
factor=0.0,
text="{:s}, {:d}".format(iface_(msg_str), progress),
translate=False,
)
else:
boxsub.label(text="{:s}: {:s}".format(ty, msg))
boxsub.label(
text="{:s}: {:s}".format(iface_(ty), iface_(msg)),
translate=False,
)
# Hide when running.
if repo_status_text.running:

@ -3,6 +3,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import bpy
from bpy.app.translations import pgettext_tip as tip_
def node_editor_poll(cls, context):
@ -25,8 +26,9 @@ def node_editor_poll(cls, context):
def node_space_type_poll(cls, context, types):
if context.space_data.tree_type not in types:
tree_types_str = ", ".join(t.split('NodeTree')[0].lower() for t in sorted(types))
cls.poll_message_set("Current node tree type not supported.\n"
"Should be one of " + tree_types_str + ".")
poll_message = tip_("Current node tree type not supported.\n"
"Should be one of {:s}.").format(tree_types_str)
cls.poll_message_set(poll_message)
return False
return True

@ -2650,8 +2650,8 @@ class BatchRenameAction(bpy.types.PropertyGroup):
)
# Weak, add/remove as properties.
op_add: BoolProperty(name="Add")
op_remove: BoolProperty(name="Remove")
op_add: BoolProperty(name="Add", translation_context=i18n_contexts.operator_default)
op_remove: BoolProperty(name="Remove", translation_context=i18n_contexts.operator_default)
class WM_OT_batch_rename(Operator):

@ -7,6 +7,7 @@ from bpy.types import Menu
from bl_ui import node_add_menu
from bpy.app.translations import (
pgettext_iface as iface_,
contexts as i18n_contexts,
)
@ -352,6 +353,7 @@ class NODE_MT_category_shader_group(Menu):
class NODE_MT_shader_node_add_all(Menu):
bl_idname = "NODE_MT_shader_node_add_all"
bl_label = "Add"
bl_translation_context = i18n_contexts.operator_default
def draw(self, _context):
layout = self.layout

@ -4,6 +4,9 @@
import bpy
from bpy.types import Menu
from bpy.app.translations import (
contexts as i18n_contexts,
)
from bl_ui import node_add_menu
@ -109,6 +112,7 @@ class NODE_MT_category_texture_group(Menu):
class NODE_MT_texture_node_add_all(Menu):
bl_idname = "NODE_MT_texture_node_add_all"
bl_label = "Add"
bl_translation_context = i18n_contexts.operator_default
def draw(self, _context):
layout = self.layout

@ -735,11 +735,11 @@ class USERPREF_PT_system_network(SystemPanel, CenterAlignMixIn, Panel):
if system.use_online_access != runtime_online_access:
row = layout.split(factor=0.4)
row.label(text="")
row.label(
text="{:s} on startup, overriding the preference.".format(
"Enabled" if runtime_online_access else "Disabled"
),
)
if runtime_online_access:
text = iface_("Enabled on startup, overriding the preference.")
else:
text = iface_("Disabled on startup, overriding the preference.")
row.label(text=text, translate=False)
class USERPREF_PT_system_memory(SystemPanel, CenterAlignMixIn, Panel):

@ -1279,7 +1279,7 @@ class VIEW3D_MT_editor_menus(Menu):
if gp_edit:
pass
elif mode_string == 'OBJECT':
layout.menu("VIEW3D_MT_add", text="Add", text_ctxt=i18n_contexts.operator_default)
layout.menu("VIEW3D_MT_add")
elif mode_string == 'EDIT_MESH':
layout.menu("VIEW3D_MT_mesh_add", text="Add", text_ctxt=i18n_contexts.operator_default)
elif mode_string == 'EDIT_CURVE':
@ -1790,7 +1790,7 @@ class VIEW3D_MT_select_object_more_less(Menu):
layout.separator()
props = layout.operator("object.select_hierarchy", text="Parent")
props = layout.operator("object.select_hierarchy", text="Parent", text_ctxt=i18n_contexts.default)
props.extend = False
props.direction = 'PARENT'
@ -1849,7 +1849,7 @@ class VIEW3D_MT_select_pose_more_less(Menu):
def draw(self, _context):
layout = self.layout
props = layout.operator("pose.select_hierarchy", text="Parent")
props = layout.operator("pose.select_hierarchy", text="Parent", text_ctxt=i18n_contexts.default)
props.extend = False
props.direction = 'PARENT'
@ -2269,7 +2269,7 @@ class VIEW3D_MT_select_edit_armature(Menu):
layout.separator()
props = layout.operator("armature.select_hierarchy", text="Parent")
props = layout.operator("armature.select_hierarchy", text="Parent", text_ctxt=i18n_contexts.default)
props.extend = False
props.direction = 'PARENT'
@ -3318,6 +3318,7 @@ class VIEW3D_MT_object_apply(Menu):
class VIEW3D_MT_object_parent(Menu):
bl_label = "Parent"
bl_translation_context = i18n_contexts.operator_default
def draw(self, _context):
from bl_ui_utils.layout import operator_context
@ -5774,6 +5775,7 @@ class VIEW3D_MT_edit_armature_names(Menu):
class VIEW3D_MT_edit_armature_parent(Menu):
bl_label = "Parent"
bl_translation_context = i18n_contexts.operator_default
def draw(self, _context):
layout = self.layout
@ -6183,6 +6185,7 @@ class VIEW3D_MT_edit_greasepencil_point(Menu):
class VIEW3D_MT_edit_curves_add(Menu):
bl_label = "Add"
bl_translation_context = i18n_contexts.operator_default
def draw(self, _context):
layout = self.layout

@ -767,7 +767,7 @@ static int clear_anim_v3d_invoke(bContext *C, wmOperator *op, const wmEvent * /*
op,
IFACE_("Remove animation from selected objects?"),
nullptr,
IFACE_("Remove"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove"),
ALERT_ICON_NONE,
false);
}

@ -279,7 +279,8 @@ static int geometry_attribute_add_invoke(bContext *C, wmOperator *op, const wmEv
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_string_set(op->ptr, prop, DATA_("Attribute"));
}
return WM_operator_props_popup_confirm_ex(C, op, event, IFACE_("Add Attribute"), IFACE_("Add"));
return WM_operator_props_popup_confirm_ex(
C, op, event, IFACE_("Add Attribute"), CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
void GEOMETRY_OT_attribute_add(wmOperatorType *ot)
@ -399,8 +400,11 @@ static int geometry_color_attribute_add_invoke(bContext *C, wmOperator *op, cons
if (!RNA_property_is_set(op->ptr, prop)) {
RNA_property_string_set(op->ptr, prop, DATA_("Color"));
}
return WM_operator_props_popup_confirm_ex(
C, op, event, IFACE_("Add Color Attribute"), IFACE_("Add"));
return WM_operator_props_popup_confirm_ex(C,
op,
event,
IFACE_("Add Color Attribute"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
enum class ConvertAttributeMode {

@ -3430,7 +3430,11 @@ int ED_gpencil_new_layer_dialog(bContext *C, wmOperator *op)
bGPdata *gpd = static_cast<bGPdata *>(ob->data);
gpencil_layer_new_name_get(gpd, name, sizeof(name));
RNA_property_string_set(op->ptr, prop, name);
return WM_operator_props_dialog_popup(C, op, 200, IFACE_("Add New Layer"), IFACE_("Add"));
return WM_operator_props_dialog_popup(C,
op,
200,
IFACE_("Add New Layer"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
}
return 0;

@ -71,8 +71,11 @@ static int grease_pencil_layer_add_exec(bContext *C, wmOperator *op)
static int grease_pencil_layer_add_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
return WM_operator_props_popup_confirm_ex(
C, op, event, IFACE_("Add New Grease Pencil Layer"), IFACE_("Add"));
return WM_operator_props_popup_confirm_ex(C,
op,
event,
IFACE_("Add New Grease Pencil Layer"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
static void GREASE_PENCIL_OT_layer_add(wmOperatorType *ot)

@ -2964,11 +2964,12 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna,
"use_base_parent",
false,
"Parent",
"Parent newly created objects to the original instancer");
ot->prop = RNA_def_boolean(ot->srna,
"use_base_parent",
false,
"Parent",
"Parent newly created objects to the original instancer");
RNA_def_property_translation_context(ot->prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
RNA_def_boolean(
ot->srna, "use_hierarchy", false, "Keep Hierarchy", "Maintain parent child relationships");
}

@ -6835,7 +6835,8 @@ static int texture_paint_add_texture_paint_slot_invoke(bContext *C,
default_paint_slot_color_get(type, ma, color);
RNA_float_set_array(op->ptr, "color", color);
return WM_operator_props_dialog_popup(C, op, 300, IFACE_("Add Paint Slot"), IFACE_("Add"));
return WM_operator_props_dialog_popup(
C, op, 300, IFACE_("Add Paint Slot"), CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
static void texture_paint_add_texture_paint_slot_ui(bContext *C, wmOperator *op)

@ -4257,7 +4257,11 @@ static int tile_add_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*
RNA_int_set(op->ptr, "count", 1);
RNA_string_set(op->ptr, "label", "");
return WM_operator_props_dialog_popup(C, op, 300, IFACE_("Add Tile to Image"), IFACE_("Add"));
return WM_operator_props_dialog_popup(C,
op,
300,
IFACE_("Add Tile to Image"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add"));
}
static void tile_add_draw(bContext * /*C*/, wmOperator *op)

@ -635,7 +635,7 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
but = uiDefBut(block,
UI_BTYPE_BUT,
0,
IFACE_("Remove"),
CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove"),
0,
0,
UI_UNIT_X * 4,

@ -2248,6 +2248,7 @@ static void rna_def_curves_sculpt_options(BlenderRNA *brna)
RNA_def_property_enum_items(prop, density_mode_items);
RNA_def_property_ui_text(
prop, "Density Mode", "Determines whether the brush adds or removes curves");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
prop = RNA_def_property(srna, "curve_parameter_falloff", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "CurveMapping");

@ -5039,6 +5039,7 @@ static void def_sh_tex_noise(StructRNA *srna)
RNA_def_property_enum_sdna(prop, nullptr, "dimensions");
RNA_def_property_enum_items(prop, rna_enum_node_tex_dimensions_items);
RNA_def_property_ui_text(prop, "Dimensions", "Number of dimensions to output noise for");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXTURE);
RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update");
prop = RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE);
@ -5155,6 +5156,7 @@ static void def_sh_tex_voronoi(StructRNA *srna)
RNA_def_property_enum_sdna(prop, nullptr, "dimensions");
RNA_def_property_enum_items(prop, rna_enum_node_tex_dimensions_items);
RNA_def_property_ui_text(prop, "Dimensions", "Number of dimensions to output noise for");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXTURE);
RNA_def_property_update(prop, 0, "rna_ShaderNode_socket_update");
prop = RNA_def_property(srna, "distance", PROP_ENUM, PROP_NONE);
@ -5250,6 +5252,7 @@ static void def_sh_tex_white_noise(StructRNA *srna)
RNA_def_property_enum_sdna(prop, nullptr, "custom1");
RNA_def_property_enum_items(prop, rna_enum_node_tex_dimensions_items);
RNA_def_property_ui_text(prop, "Dimensions", "Number of dimensions to output noise for");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXTURE);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update");
}
@ -8564,6 +8567,7 @@ static void def_cmp_cryptomatte_common(StructRNA *srna)
RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);
RNA_def_property_ui_text(
prop, "Add", "Add object or material to matte, by picking a color from the Pick output");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_add");
prop = RNA_def_property(srna, "remove", PROP_FLOAT, PROP_COLOR);
@ -8574,6 +8578,7 @@ static void def_cmp_cryptomatte_common(StructRNA *srna)
prop,
"Remove",
"Remove object or material from matte, by picking a color from the Pick output");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_OPERATOR_DEFAULT);
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeCryptomatte_update_remove");
}

@ -2242,7 +2242,7 @@ static void draw_named_attributes_panel(uiLayout *layout, NodesModifierData &nmd
usages.append(IFACE_("Write"));
}
if ((usage & geo_log::NamedAttributeUsage::Remove) != geo_log::NamedAttributeUsage::None) {
usages.append(IFACE_("Remove"));
usages.append(CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove"));
}
for (const int i : usages.index_range()) {
ss << usages[i];

@ -7,6 +7,8 @@
#include "BKE_volume.hh"
#include "BKE_volume_grid.hh"
#include "BLT_translation.hh"
#include "RNA_enum_types.hh"
#include "NOD_rna_define.hh"
@ -20,7 +22,8 @@ static void node_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Geometry>("Volume");
b.add_input<decl::String>("Name");
b.add_input<decl::Bool>("Remove").default_value(true);
b.add_input<decl::Bool>("Remove").default_value(true).translation_context(
BLT_I18NCONTEXT_OPERATOR_DEFAULT);
b.add_output<decl::Geometry>("Volume");