Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2012-03-16 19:39:25 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-03-16 19:39:25 +0400
commit2caa507b7eaa7d55a0be7bda513f08ecfe4791f1 (patch)
tree86e65a98805030b6191643571c2eea1962da9ea7 /source/blender/makesrna
parent4e6669cee38ed81dc2e9be52f2900885295506f3 (diff)
i18n stuff: adds translation_context to RNA structs (used for there ui name), and a first default "Operator" one for all operators' label.
The fact is, operators' label are nearly always verbs, while properties labels are nearly always nouns. So this should already solve many translations' problems regarding noun/verb confusion. This commit also simplifies a bit i18n usage: *Now IFACE_ and TIP_ macros (or there context versions, CTX_IFACE_/TIP_) are used nearly everywhere (with one exception, where code is a bit complex and needs to manually test whether ui/tip translations is allowed, so no need to redo it later through those macros). *Also, those macros are now defined to NOP in case WITH_INTERNATIONAL is false, which avoid testing that define everywhere in code!
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_define.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c2
-rw-r--r--source/blender/makesrna/intern/rna_access.c23
-rw-r--r--source/blender/makesrna/intern/rna_define.c5
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_rna.c17
6 files changed, 32 insertions, 19 deletions
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index d6c3422c8d4..9939d0839e6 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -66,6 +66,8 @@ void RNA_def_struct_ui_icon(StructRNA *srna, int icon);
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext);
void RNA_struct_free(BlenderRNA *brna, StructRNA *srna);
+void RNA_def_struct_translation_context(StructRNA *srna, const char *context);
+
/* Compact Property Definitions */
typedef void StructOrFunctionRNA;
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index be7ced4b656..bb69e23b1f3 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -2474,6 +2474,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f)
rna_print_c_string(f, srna->name);
fprintf(f, ", ");
rna_print_c_string(f, srna->description);
+ fprintf(f, ", ");
+ rna_print_c_string(f, srna->translation_context);
fprintf(f, ",\n\t%d,\n", srna->icon);
prop = srna->nameproperty;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 543824eb5d5..76d33ea9b9a 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -474,12 +474,7 @@ static const char *rna_ensure_property_description(PropertyRNA *prop)
description = ((IDProperty*)prop)->name; /* XXX - not correct */
}
-#ifdef WITH_INTERNATIONAL
- if (description && BLF_translate_tooltips())
- description = BLF_gettext(description);
-#endif
-
- return description;
+ return TIP_(description);
}
static const char *rna_ensure_property_name(PropertyRNA *prop)
@@ -491,16 +486,7 @@ static const char *rna_ensure_property_name(PropertyRNA *prop)
else
name = ((IDProperty*)prop)->name;
-#ifdef WITH_INTERNATIONAL
- if (BLF_translate_iface()) {
- if (prop->translation_context)
- name = BLF_pgettext(prop->translation_context, name);
- else
- name = BLF_gettext(name);
- }
-#endif
-
- return name;
+ return CTX_IFACE_(prop->translation_context, name);
}
/* Structs */
@@ -523,7 +509,7 @@ const char *RNA_struct_identifier(StructRNA *type)
const char *RNA_struct_ui_name(StructRNA *type)
{
- return type->name;
+ return CTX_IFACE_(type->translation_context, type->name);
}
int RNA_struct_ui_icon(StructRNA *type)
@@ -536,7 +522,7 @@ int RNA_struct_ui_icon(StructRNA *type)
const char *RNA_struct_ui_description(StructRNA *type)
{
- return type->description;
+ return TIP_(type->description);
}
PropertyRNA *RNA_struct_name_property(StructRNA *type)
@@ -1182,6 +1168,7 @@ void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA
RNA_property_enum_items(C, ptr, prop, item, totitem, free);
#ifdef WITH_INTERNATIONAL
+ /* Note: keep directly using BLF_gettext here, has we have already done tests like BLF_translate_iface... */
if (BLF_translate_iface()) {
int i;
EnumPropertyItem *nitem;
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 202418205f3..78780678af4 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -871,6 +871,11 @@ void RNA_def_struct_ui_icon(StructRNA *srna, int icon)
srna->icon = icon;
}
+void RNA_def_struct_translation_context(StructRNA *srna, const char *context)
+{
+ srna->translation_context = context;
+}
+
/* Property Definition */
PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 997f9d084c5..e71352748ea 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -312,6 +312,8 @@ struct StructRNA {
const char *name;
/* single line description, displayed in the tooltip for example */
const char *description;
+ /* context for translation */
+ const char *translation_context;
/* icon ID */
int icon;
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c
index 153e9288375..03a1fbc4a80 100644
--- a/source/blender/makesrna/intern/rna_rna.c
+++ b/source/blender/makesrna/intern/rna_rna.c
@@ -129,6 +129,16 @@ static int rna_Struct_name_length(PointerRNA *ptr)
return strlen(((StructRNA*)ptr->data)->name);
}
+static void rna_Struct_translation_context_get(PointerRNA *ptr, char *value)
+{
+ strcpy(value, ((StructRNA*)ptr->data)->translation_context ? ((StructRNA*)ptr->data)->translation_context : "");
+}
+
+static int rna_Struct_translation_context_length(PointerRNA *ptr)
+{
+ return ((StructRNA*)ptr->data)->translation_context ? strlen(((StructRNA*)ptr->data)->translation_context) : 0;
+}
+
static PointerRNA rna_Struct_base_get(PointerRNA *ptr)
{
return rna_pointer_inherit_refine(ptr, &RNA_Struct, ((StructRNA*)ptr->data)->base);
@@ -982,6 +992,11 @@ static void rna_def_struct(BlenderRNA *brna)
RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL);
RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose");
+ prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+ RNA_def_property_string_funcs(prop, "rna_Struct_translation_context_get", "rna_Struct_translation_context_length", NULL);
+ RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the struct's name");
+
prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_struct_type(prop, "Struct");
@@ -1064,7 +1079,7 @@ static void rna_def_property(BlenderRNA *brna)
prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_string_funcs(prop, "rna_Property_translation_context_get", "rna_Property_translation_context_length", NULL);
- RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the property");
+ RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the property's name");
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);