diff --git a/scripts/modules/bl_i18n_utils/settings.py b/scripts/modules/bl_i18n_utils/settings.py index a207584ecf2..50218f23cb6 100644 --- a/scripts/modules/bl_i18n_utils/settings.py +++ b/scripts/modules/bl_i18n_utils/settings.py @@ -252,12 +252,18 @@ PYGETTEXT_KEYWORDS = (() + for it in ("BKE_report", "BKE_reportf", "BKE_reports_prepend", "BKE_reports_prependf", "CTX_wm_operator_poll_msg_set", "WM_report", "WM_reportf")) + + # bmesh operator errors tuple(("{}\\((?:[^\"',]+,){{3}}\\s*" + _msg_re + r"\s*\)").format(it) for it in ("BMO_error_raise",)) + + # Modifier errors tuple(("{}\\((?:[^\"',]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it) for it in ("BKE_modifier_set_error",)) + + # Compositor error messages + tuple((r"\.{}\(\s*" + _msg_re + r"\s*\)").format(it) + for it in ("set_info_message",)) + + # This one is a tad more risky, but in practice would not expect a name/uid string parameter # (the second one in those functions) to ever have a comma in it, so think this is fine. tuple(("{}\\((?:[^,]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it) @@ -297,13 +303,8 @@ PYGETTEXT_KEYWORDS = (() + # Geometry Nodes field inputs ((r"FieldInput\(CPPType::get<.*?>\(\),\s*" + _msg_re + r"\s*\)"),) + - # bUnitDef unit names. - # NOTE: regex is a bit more complex than it would need too. Since the actual - # identifier (`B_UNIT_DEF_`) is at the end, if it's simpler/too general it - # becomes extremely slow to process some (unrelated) source files. - ((r"\{(?:(?:\s*\"[^\",]+\"\s*,)|(?:\s*\"\\\"\",)|(?:\s*nullptr\s*,)){4}\s*" + - _msg_re + r"\s*,(?:(?:\s*\"[^\"',]+\"\s*,)|(?:\s*nullptr\s*,))(?:[^,]+,){2}" - + "(?:\|?\s*B_UNIT_DEF_[_A-Z]+\s*)+\}"),) + + # bUnitDef unit names + ((r"/\*name_display\*/\s*" + _msg_re + r"\s*,"),) + tuple((r"{}\(\s*" + _msg_re + r"\s*,\s*(?:" + r"\s*,\s*)?(?:".join(_ctxt_re_gen(i) for i in range(PYGETTEXT_MAX_MULTI_CTXT)) + r")?\s*\)").format(it) diff --git a/scripts/startup/bl_operators/anim.py b/scripts/startup/bl_operators/anim.py index 6156a96761b..25bebe3d781 100644 --- a/scripts/startup/bl_operators/anim.py +++ b/scripts/startup/bl_operators/anim.py @@ -13,7 +13,10 @@ from bpy.props import ( EnumProperty, StringProperty, ) -from bpy.app.translations import pgettext_tip as tip_ +from bpy.app.translations import ( + pgettext_tip as tip_, + contexts as i18n_contexts, +) class ANIM_OT_keying_set_export(Operator): @@ -238,6 +241,7 @@ class NLA_OT_bake(Operator): ) bake_types: EnumProperty( name="Bake Data", + translation_context=i18n_contexts.id_action, description="Which data's transformations to bake", options={'ENUM_FLAG'}, items=( diff --git a/scripts/startup/bl_ui/properties_physics_geometry_nodes.py b/scripts/startup/bl_ui/properties_physics_geometry_nodes.py index 9484675ee2a..4ec083dfc38 100644 --- a/scripts/startup/bl_ui/properties_physics_geometry_nodes.py +++ b/scripts/startup/bl_ui/properties_physics_geometry_nodes.py @@ -5,7 +5,10 @@ from bpy.types import ( Panel, ) -from bpy.app.translations import pgettext_iface as iface_ +from bpy.app.translations import ( + pgettext_iface as iface_, + contexts as i18n_contexts, +) class PHYSICS_PT_geometry_nodes(Panel): @@ -35,16 +38,16 @@ class PHYSICS_PT_geometry_nodes(Panel): calc_text = iface_("Calculate to Frame") bake_text = iface_("Bake") - layout.operator("object.simulation_nodes_cache_calculate_to_frame", text=calc_text).selected = True + layout.operator("object.simulation_nodes_cache_calculate_to_frame", text=calc_text, translate=False).selected = True row = layout.row(align=True) - row.operator("object.simulation_nodes_cache_bake", text=bake_text).selected = True + row.operator("object.simulation_nodes_cache_bake", text=bake_text, translate=False).selected = True row.operator("object.simulation_nodes_cache_delete", text="", icon='TRASH').selected = True layout.use_property_split = True layout.use_property_decorate = False ob = context.object - layout.prop(ob, "use_simulation_cache", text="Cache") + layout.prop(ob, "use_simulation_cache", text="Cache", text_ctxt=i18n_contexts.id_simulation) classes = ( diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index bd88c37989c..2d9b5056f5a 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -702,7 +702,7 @@ class VIEW3D_HT_header(Header): icon = snap_items[elem].icon break else: - text = "Mix" + text = iface_("Mix", i18n_contexts.editor_view3d) icon = 'NONE' del snap_items, snap_elements @@ -714,6 +714,7 @@ class VIEW3D_HT_header(Header): panel="VIEW3D_PT_snapping", icon=icon, text=text, + translate=False, ) # Proportional editing diff --git a/source/blender/blenkernel/intern/unit.cc b/source/blender/blenkernel/intern/unit.cc index 12045383e3a..884a98d9c92 100644 --- a/source/blender/blenkernel/intern/unit.cc +++ b/source/blender/blenkernel/intern/unit.cc @@ -81,7 +81,10 @@ /* clang-format on */ -/* Define a single unit. */ +/* Define a single unit. + * When changing the format, please check that the PYGETTEXT_KEYWORDS regex + * used to extract the unit names for translation still works + * in scripts/modules/bl_i18n_utils/settings.py. */ struct bUnitDef { const char *name; /** Abused a bit for the display name. */ diff --git a/source/blender/draw/intern/draw_manager_c.cc b/source/blender/draw/intern/draw_manager_c.cc index a555165259d..981d0985b14 100644 --- a/source/blender/draw/intern/draw_manager_c.cc +++ b/source/blender/draw/intern/draw_manager_c.cc @@ -18,6 +18,8 @@ #include "BLF_api.h" +#include "BLT_translation.h" + #include "BKE_colortools.h" #include "BKE_context.hh" #include "BKE_curve.hh" @@ -1151,7 +1153,7 @@ void DRW_draw_region_engine_info(int xoffset, int *yoffset, int line_height) BLF_shadow(font_id, 5, blender::float4{0.0f, 0.0f, 0.0f, 1.0f}); BLF_shadow_offset(font_id, 1, -1); - const char *buf_step = data->info; + const char *buf_step = IFACE_(data->info); do { const char *buf = buf_step; buf_step = BLI_strchr_or_end(buf, '\n'); diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 48e0a300d9d..69aeb387de3 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -5301,8 +5301,15 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp /* There is probably potential to use simpler "uiItemR" functions here, but automatic updating * after a preset is selected would be more complicated. */ uiLayout *row = uiLayoutRow(layout, true); - bt = uiDefBlockBut( - block, CurveProfile_buttons_presets, profile, "Preset", 0, 0, UI_UNIT_X, UI_UNIT_X, ""); + bt = uiDefBlockBut(block, + CurveProfile_buttons_presets, + profile, + IFACE_("Preset"), + 0, + 0, + UI_UNIT_X, + UI_UNIT_X, + ""); UI_but_funcN_set(bt, rna_update_cb, MEM_dupallocN(cb), nullptr); /* Show a "re-apply" preset button when it has been changed from the preset. */ @@ -5313,7 +5320,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp UI_BTYPE_BUT, 0, ICON_NONE, - "Apply Preset", + IFACE_("Apply Preset"), 0, 0, UI_UNIT_X, diff --git a/source/blender/editors/space_file/asset_catalog_tree_view.cc b/source/blender/editors/space_file/asset_catalog_tree_view.cc index fbaf70fbd0d..9ac91457fc8 100644 --- a/source/blender/editors/space_file/asset_catalog_tree_view.cc +++ b/source/blender/editors/space_file/asset_catalog_tree_view.cc @@ -294,7 +294,7 @@ void AssetCatalogTreeViewItem::build_context_menu(bContext &C, uiLayout &column) uiItemFullO(&column, "ASSET_OT_catalog_new", - "New Catalog", + IFACE_("New Catalog"), ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, @@ -306,14 +306,14 @@ void AssetCatalogTreeViewItem::build_context_menu(bContext &C, uiLayout &column) BLI_uuid_format(catalog_id_str_buffer, catalog_item_.get_catalog_id()); uiItemFullO(&column, "ASSET_OT_catalog_delete", - "Delete Catalog", + IFACE_("Delete Catalog"), ICON_NONE, nullptr, WM_OP_INVOKE_DEFAULT, UI_ITEM_NONE, &props); RNA_string_set(&props, "catalog_id", catalog_id_str_buffer); - uiItemO(&column, "Rename", ICON_NONE, "UI_OT_view_item_rename"); + uiItemO(&column, IFACE_("Rename"), ICON_NONE, "UI_OT_view_item_rename"); /* Doesn't actually exist right now, but could be defined in Python. Reason that this isn't done * in Python yet is that catalogs are not exposed in BPY, and we'd somehow pass the clicked on diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 089c84e5935..e73a7380a77 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -42,7 +42,7 @@ static void node_declare(NodeDeclarationBuilder &b) node_storage(node).mode = GEO_NODE_EXTRUDE_MESH_FACES; }); b.add_output("Mesh").propagate_all(); - b.add_output("Top").field_on_all(); + b.add_output("Top").field_on_all().translation_context(BLT_I18NCONTEXT_ID_NODETREE); b.add_output("Side").field_on_all(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index cc5b7346d0d..7e264fb0f2d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -52,8 +52,9 @@ static void node_declare(NodeDeclarationBuilder &b) .subtype(PROP_DISTANCE) .description("Height of the generated cone"); b.add_output("Mesh"); - b.add_output("Top").field_on_all(); - b.add_output("Bottom").field_on_all(); + b.add_output("Top").field_on_all().translation_context(BLT_I18NCONTEXT_ID_NODETREE); + b.add_output("Bottom").field_on_all().translation_context( + BLT_I18NCONTEXT_ID_NODETREE); b.add_output("Side").field_on_all(); b.add_output("UV Map").field_on_all(); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index d45eed8a559..766eb0f1af4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -47,9 +47,10 @@ static void node_declare(NodeDeclarationBuilder &b) .subtype(PROP_DISTANCE) .description("The height of the cylinder"); b.add_output("Mesh"); - b.add_output("Top").field_on_all(); + b.add_output("Top").field_on_all().translation_context(BLT_I18NCONTEXT_ID_NODETREE); b.add_output("Side").field_on_all(); - b.add_output("Bottom").field_on_all(); + b.add_output("Bottom").field_on_all().translation_context( + BLT_I18NCONTEXT_ID_NODETREE); b.add_output("UV Map").field_on_all(); }