I18n: fix translation of Grease Pencil 3.0 layer names
The Grease Pencil 3.0 layers and groups were not properly translated: - The layers and groups' names were translated during display in the layer list. Since they are data, they should be left untranslated at this time. - On object creation, the names "GP_Layer", "Color", "Lines", and "Fills" were not translated at all. This adds DATA_() macros around to translate them if the user has enabled translation of new data names. - The functions returning unique names for layers and groups unique_layer_group_name() and unique_layer_name() would return "GP_Layer" and "GP_Group" by default. These defaults are now translated. - When adding new layers and groups, the name was always hardcoded to "GP_Layer" and "GP_Group" because the operators' properties for the names defaulted to that, and prop defaults cannot be translated. Instead, make them default to a null string, but choose an appropriate name when executing the op. This name is chosen by unique_layer_name() and unique_layer_group_name(), whose defaults are now translated. Pull Request: https://projects.blender.org/blender/blender/pulls/112930
This commit is contained in:
@@ -1839,13 +1839,13 @@ static std::string unique_node_name(const GreasePencil &grease_pencil,
|
||||
static std::string unique_layer_name(const GreasePencil &grease_pencil,
|
||||
blender::StringRefNull name)
|
||||
{
|
||||
return unique_node_name(grease_pencil, "GP_Layer", name);
|
||||
return unique_node_name(grease_pencil, DATA_("GP_Layer"), name);
|
||||
}
|
||||
|
||||
static std::string unique_layer_group_name(const GreasePencil &grease_pencil,
|
||||
blender::StringRefNull name)
|
||||
{
|
||||
return unique_node_name(grease_pencil, "GP_Group", name);
|
||||
return unique_node_name(grease_pencil, DATA_("GP_Group"), name);
|
||||
}
|
||||
|
||||
blender::bke::greasepencil::Layer &GreasePencil::add_layer(
|
||||
|
||||
@@ -1198,7 +1198,7 @@ void create_blank(Main &bmain, Object &object, const int frame_number)
|
||||
int material_index = add_material_from_template(bmain, object, gp_stroke_material_black);
|
||||
object.actcol = material_index + 1;
|
||||
|
||||
Layer &new_layer = grease_pencil.add_layer(grease_pencil.root_group(), "GP_Layer");
|
||||
Layer &new_layer = grease_pencil.add_layer(grease_pencil.root_group(), DATA_("GP_Layer"));
|
||||
grease_pencil.set_active_layer(&new_layer);
|
||||
grease_pencil.insert_blank_frame(new_layer, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
|
||||
}
|
||||
@@ -1217,8 +1217,8 @@ void create_stroke(Main &bmain, Object &object, float4x4 matrix, const int frame
|
||||
add_material_from_template(bmain, object, gp_fill_material_grey);
|
||||
object.actcol = material_index + 1;
|
||||
|
||||
Layer &layer_lines = grease_pencil.add_layer(grease_pencil.root_group(), "Lines");
|
||||
Layer &layer_color = grease_pencil.add_layer(grease_pencil.root_group(), "Color");
|
||||
Layer &layer_lines = grease_pencil.add_layer(grease_pencil.root_group(), DATA_("Lines"));
|
||||
Layer &layer_color = grease_pencil.add_layer(grease_pencil.root_group(), DATA_("Color"));
|
||||
grease_pencil.set_active_layer(&layer_lines);
|
||||
|
||||
grease_pencil.insert_blank_frame(layer_lines, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
|
||||
@@ -1278,8 +1278,8 @@ void create_suzanne(Main &bmain, Object &object, float4x4 matrix, const int fram
|
||||
color_skin_shadow,
|
||||
});
|
||||
|
||||
Layer &layer_fills = grease_pencil.add_layer(grease_pencil.root_group(), "Fills");
|
||||
Layer &layer_lines = grease_pencil.add_layer(grease_pencil.root_group(), "Lines");
|
||||
Layer &layer_fills = grease_pencil.add_layer(grease_pencil.root_group(), DATA_("Fills"));
|
||||
Layer &layer_lines = grease_pencil.add_layer(grease_pencil.root_group(), DATA_("Lines"));
|
||||
grease_pencil.set_active_layer(&layer_lines);
|
||||
|
||||
grease_pencil.insert_blank_frame(layer_lines, frame_number, 0, BEZT_KEYTYPE_KEYFRAME);
|
||||
|
||||
@@ -83,7 +83,7 @@ static void GREASE_PENCIL_OT_layer_add(wmOperatorType *ot)
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
PropertyRNA *prop = RNA_def_string(
|
||||
ot->srna, "new_layer_name", "GP_Layer", INT16_MAX, "Name", "Name of the new layer");
|
||||
ot->srna, "new_layer_name", nullptr, INT16_MAX, "Name", "Name of the new layer");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
ot->prop = prop;
|
||||
}
|
||||
@@ -239,12 +239,8 @@ static void GREASE_PENCIL_OT_layer_group_add(wmOperatorType *ot)
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
PropertyRNA *prop = RNA_def_string(ot->srna,
|
||||
"new_layer_group_name",
|
||||
"GP_Group",
|
||||
INT16_MAX,
|
||||
"Name",
|
||||
"Name of the new layer group");
|
||||
PropertyRNA *prop = RNA_def_string(
|
||||
ot->srna, "new_layer_group_name", nullptr, INT16_MAX, "Name", "Name of the new layer group");
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
ot->prop = prop;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ class LayerViewItem : public AbstractTreeViewItem {
|
||||
void build_layer_name(uiLayout &row)
|
||||
{
|
||||
uiBut *but = uiItemL_ex(
|
||||
&row, IFACE_(layer_.name().c_str()), ICON_OUTLINER_DATA_GP_LAYER, false, false);
|
||||
&row, layer_.name().c_str(), ICON_OUTLINER_DATA_GP_LAYER, false, false);
|
||||
if (layer_.is_locked() || !layer_.parent_group().is_visible()) {
|
||||
UI_but_disable(but, "Layer is locked or not visible");
|
||||
}
|
||||
@@ -337,7 +337,7 @@ class LayerGroupViewItem : public AbstractTreeViewItem {
|
||||
void build_layer_group_name(uiLayout &row)
|
||||
{
|
||||
uiItemS_ex(&row, 0.8f);
|
||||
uiBut *but = uiItemL_ex(&row, IFACE_(group_.name().c_str()), ICON_FILE_FOLDER, false, false);
|
||||
uiBut *but = uiItemL_ex(&row, group_.name().c_str(), ICON_FILE_FOLDER, false, false);
|
||||
if (group_.is_locked()) {
|
||||
UI_but_disable(but, "Layer Group is locked");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user