I18n: disambiguate messages #105420

Merged
Bastien Montagne merged 2 commits from pioverfour/blender:dp_disambiguate into blender-v3.5-release 2023-03-07 12:32:12 +01:00
13 changed files with 29 additions and 6 deletions

View File

@ -2,7 +2,10 @@
import bpy
from bpy.types import Menu
from bl_ui import node_add_menu
from bpy.app.translations import pgettext_iface as iface_
from bpy.app.translations import (
pgettext_iface as iface_,
contexts as i18n_contexts,
)
class NODE_MT_geometry_node_GEO_ATTRIBUTE(Menu):
@ -238,6 +241,7 @@ class NODE_MT_geometry_node_GEO_INPUT(Menu):
class NODE_MT_geometry_node_GEO_INPUT_CONSTANT(Menu):
bl_idname = "NODE_MT_geometry_node_GEO_INPUT_CONSTANT"
bl_label = "Constant"
bl_translation_context = i18n_contexts.id_nodetree
def draw(self, _context):
layout = self.layout

View File

@ -79,6 +79,7 @@ class TEXT_HT_footer(Header):
text=iface_("Text: External")
if text.library
else iface_("Text: Internal"),
translate=False
)

View File

@ -342,7 +342,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
BLI_strncpy(masklay->name, name, sizeof(masklay->name));
}
else {
strcpy(masklay->name, "MaskLayer");
strcpy(masklay->name, DATA_("MaskLayer"));
}
BLI_addtail(&mask->masklayers, masklay);

View File

@ -130,6 +130,8 @@ const char *BLT_translate_do_new_dataname(const char *msgctxt, const char *msgid
#define BLT_I18NCONTEXT_VIRTUAL_REALITY "Virtual reality"
#define BLT_I18NCONTEXT_CONSTRAINT "Constraint"
#define BLT_I18NCONTEXT_COLOR "Color"
#define BLT_I18NCONTEXT_AMOUNT "Amount"
#define BLT_I18NCONTEXT_UNIT "Unit"
mont29 marked this conversation as resolved
Review

I don't think that one is needed, for the time being at least, we can use the new 'Curves' ID context.

Which leads to another topic:

  • BLT_I18NCONTEXT_ID_CURVE should be renamed to BLT_I18NCONTEXT_ID_CURVE_DEPRECATED (only the C define, not the underlying string), this ID type will be removed soon(ish).
  • BLT_I18NCONTEXT_ID_HAIR should be renamed to BLT_I18NCONTEXT_ID_CURVES (since the to-be-done Hair ID type was renamed to Curves). That one does include renaming the py 'constant' as well, and updating the string value.

(Hair and the new curves are the same type of data now).

These changes are for main though, not 3.5.

I don't think that one is needed, for the time being at least, we can use the new 'Curves' ID context. Which leads to another topic: * `BLT_I18NCONTEXT_ID_CURVE` should be renamed to `BLT_I18NCONTEXT_ID_CURVE_DEPRECATED` (only the C define, not the underlying string), this ID type will be removed soon(ish). * `BLT_I18NCONTEXT_ID_HAIR` should be renamed to `BLT_I18NCONTEXT_ID_CURVES` (since the to-be-done `Hair` ID type was renamed to `Curves`). That one does include renaming the py 'constant' as well, and updating the string value. (Hair and the new curves are the same type of data now). These changes are for main though, not 3.5.
Review

BLT_I18NCONTEXT_ID_CURVE was already renamed to BLT_I18NCONTEXT_ID_CURVE_LEGACY, and I just removed replaced this new BLT_I18NCONTEXT_ID_HAIR by BLT_I18NCONTEXT_ID_CURVES.

`BLT_I18NCONTEXT_ID_CURVE` was already renamed to `BLT_I18NCONTEXT_ID_CURVE_LEGACY`, and I just removed replaced this new `BLT_I18NCONTEXT_ID_HAIR` by `BLT_I18NCONTEXT_ID_CURVES`.
Review

Arg right, think I was still on 2.93 branch when I checked the code!

Arg right, think I was still on 2.93 branch when I checked the code!
/* Helper for bpy.app.i18n object... */
typedef struct {
@ -198,6 +200,8 @@ typedef struct {
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_VIRTUAL_REALITY, "virtual_reality"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_CONSTRAINT, "constraint"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COLOR, "color"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_AMOUNT, "amount"), \
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_UNIT, "unit"), \
{ \
NULL, NULL, NULL \
} \

View File

@ -3877,7 +3877,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
case UI_BTYPE_KEY_EVENT: {
const char *str;
if (but->flag & UI_SELECT) {
str = "Press a key";
str = IFACE_("Press a key");
}
else {
UI_GET_BUT_VALUE_INIT(but, value);
@ -3910,7 +3910,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate)
(void)str; /* UNUSED */
}
else {
BLI_strncpy(but->drawstr, "Press a key", UI_MAX_DRAW_STR);
BLI_strncpy(but->drawstr, IFACE_("Press a key"), UI_MAX_DRAW_STR);
}
}
else {

View File

@ -2810,8 +2810,10 @@ void TEXT_OT_scroll(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_CURSOR_XY | OPTYPE_INTERNAL;
/* properties */
RNA_def_int(
PropertyRNA *prop;
prop = RNA_def_int(
ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT);
}
/** \} */
@ -2915,8 +2917,10 @@ void TEXT_OT_scroll_bar(wmOperatorType *ot)
ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL;
/* properties */
RNA_def_int(
PropertyRNA *prop;
prop = RNA_def_int(
ot->srna, "lines", 1, INT_MIN, INT_MAX, "Lines", "Number of lines to scroll", -100, 100);
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT);
}
/** \} */

View File

@ -2556,6 +2556,8 @@ static void rna_def_brush(BlenderRNA *brna)
prop = RNA_def_property(srna, "curve_preset", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, brush_curve_preset_items);
RNA_def_property_ui_text(prop, "Curve Preset", "");
RNA_def_property_translation_context(prop,
BLT_I18NCONTEXT_ID_CURVES); /* Abusing id_curves :/ */
Review

Better use the new one here, legacy will be removed at some point, so would avoid using it in new code.

Better use the new one here, legacy will be removed at some point, so would avoid using it in new code.
Review

All right!

Come to think of it, when the legacy ID is removed we can always rename the context to something like the generic BLT_I18NCONTEXT_CURVE, so the messages don’t get fuzzy without reason.

All right! Come to think of it, when the legacy ID is removed we can always rename the context to something like the generic `BLT_I18NCONTEXT_CURVE`, so the messages don’t get fuzzy without reason.
Review

Yes... or just do a massive Search&Replace in the POs ;)

Yes... or just do a massive Search&Replace in the POs ;)
RNA_def_property_update(prop, 0, "rna_Brush_update");
prop = RNA_def_property(srna, "deform_target", PROP_ENUM, PROP_NONE);

View File

@ -8,6 +8,8 @@
#include "DNA_cachefile_types.h"
#include "DNA_scene_types.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@ -364,6 +366,7 @@ static void rna_def_cachefile(BlenderRNA *brna)
"Velocity Unit",
"Define how the velocity vectors are interpreted with regard to time, 'frame' means "
"the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UNIT);
RNA_def_property_update(prop, 0, "rna_CacheFile_update");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);

View File

@ -1821,6 +1821,7 @@ static void rna_def_fluid_domain_settings(BlenderRNA *brna)
RNA_def_property_range(prop, 1, 5);
RNA_def_property_ui_text(
prop, "Number", "Particle number factor (higher value results in more particles)");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_AMOUNT);
RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Fluid_datacache_reset");
prop = RNA_def_property(srna, "particle_min", PROP_INT, PROP_NONE);

View File

@ -2948,6 +2948,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
RNA_def_property_ui_range(prop, 0, 1000000, 1, -1);
RNA_def_property_ui_text(prop, "Number", "Total number of particles");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_AMOUNT);
RNA_def_property_update(prop, 0, "rna_Particle_reset");
prop = RNA_def_property(

View File

@ -6440,6 +6440,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop = RNA_def_property(srna, "hair_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, hair_shape_type_items);
RNA_def_property_ui_text(prop, "Curves Shape Type", "Curves shape type");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVES);
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_render_update");
prop = RNA_def_property(srna, "hair_subdiv", PROP_INT, PROP_NONE);

View File

@ -237,6 +237,7 @@ static void rna_def_text(BlenderRNA *brna)
prop = RNA_def_property(srna, "lines", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "TextLine");
RNA_def_property_ui_text(prop, "Lines", "Lines of text");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_TEXT);
prop = RNA_def_property(srna, "current_line", PROP_POINTER, PROP_NONE);
RNA_def_property_flag(prop, PROP_NEVER_NULL);

View File

@ -664,6 +664,7 @@ static void rna_def_volume(BlenderRNA *brna)
"Velocity Unit",
"Define how the velocity vectors are interpreted with regard to time, 'frame' means "
"the delta time is 1 frame, 'second' means the delta time is 1 / FPS");
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_UNIT);
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
prop = RNA_def_property(srna, "velocity_scale", PROP_FLOAT, PROP_NONE);