From 1083a069004490b0ed8679679adb2a7ea881ba62 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 9 Feb 2013 18:17:20 +0000 Subject: [PATCH] Translation of 'text' parameter of UI functions: disables context search in RNA property (see comment in code for details). Also made some minor optimization. --- source/blender/makesrna/intern/rna_ui_api.c | 23 +++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 4070e6c0a9f..2043832a3f8 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -63,25 +63,36 @@ EnumPropertyItem icon_items[] = { static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, int translate) { - if (!text || !text[0] || !translate) { + /* Also return text if UI labels translation is disabled. */ + if (!text || !text[0] || !translate || !BLF_translate_iface()) { return text; } /* If a text_ctxt is specified, use it! */ if (text_ctxt && text_ctxt[0]) { - return CTX_IFACE_(text_ctxt, text); + return BLF_pgettext(text_ctxt, text); } /* Else, if an RNA type or property is specified, use its context. */ +#if 0 + /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA struct corresponding + * to the 'data' (in functions like prop() & co), as this is pure runtime data. Hence, messages extraction + * script can't determine the correct context it should use for such 'text' messages... + * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc. functions, + * if default context is not suitable. + */ if (prop) { - return CTX_IFACE_(RNA_property_translation_context(prop), text); + return BLF_pgettext(RNA_property_translation_context(prop), text); } +#else + (void)prop; +#endif if (type) { - return CTX_IFACE_(RNA_struct_translation_context(type), text); + return BLF_pgettext(RNA_struct_translation_context(type), text); } - /* Else, no context! */ - return IFACE_(text); + /* Else, default context! */ + return BLF_pgettext(BLF_I18NCONTEXT_DEFAULT, text); } static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,