From 2caa507b7eaa7d55a0be7bda513f08ecfe4791f1 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Fri, 16 Mar 2012 15:39:25 +0000 Subject: 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! --- source/blender/blenfont/BLF_translation.h | 20 +++++++++++++++----- source/blender/blenfont/intern/blf_translation.c | 20 ++++++++++++++------ 2 files changed, 29 insertions(+), 11 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 4e09eb60928..5e2fee36af0 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -61,15 +61,25 @@ void BLF_lang_encoding(const char *str); /* translation */ int BLF_translate_iface(void); int BLF_translate_tooltips(void); -const char *BLF_translate_do_iface(const char *msgid); -const char *BLF_translate_do_tooltip(const char *msgid); +const char *BLF_translate_do_iface(const char *contex, const char *msgid); +const char *BLF_translate_do_tooltip(const char *contex, const char *msgid); -/* #define _(msgid) BLF_gettext(msgid) */ /* The "translation-marker" macro. */ #define N_(msgid) msgid /* Those macros should be used everywhere in UI code. */ -#define IFACE_(msgid) BLF_translate_do_iface(msgid) -#define TIP_(msgid) BLF_translate_do_tooltip(msgid) +#ifdef WITH_INTERNATIONAL +/* #define _(msgid) BLF_gettext(msgid) */ + #define IFACE_(msgid) BLF_translate_do_iface(NULL, msgid) + #define TIP_(msgid) BLF_translate_do_tooltip(NULL, msgid) + #define CTX_IFACE_(context, msgid) BLF_translate_do_iface(context, msgid) + #define CTX_TIP_(context, msgid) BLF_translate_do_tooltip(context, msgid) +#else +/* #define _(msgid) msgid */ + #define IFACE_(msgid) msgid + #define TIP_(msgid) msgid + #define CTX_IFACE_(context, msgid) msgid + #define CTX_TIP_(context, msgid) msgid +#endif #endif /* __BLF_TRANSLATION_H__ */ diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 457545eeb17..dd9fe57fa82 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -154,11 +154,15 @@ int BLF_translate_tooltips(void) #endif } -const char *BLF_translate_do_iface(const char *msgid) +const char *BLF_translate_do_iface(const char *context, const char *msgid) { #ifdef WITH_INTERNATIONAL - if (BLF_translate_iface()) - return BLF_gettext(msgid); + if(BLF_translate_iface()) { + if (context) + return BLF_pgettext(context, msgid); + else + return BLF_gettext(msgid); + } else return msgid; #else @@ -166,11 +170,15 @@ const char *BLF_translate_do_iface(const char *msgid) #endif } -const char *BLF_translate_do_tooltip(const char *msgid) +const char *BLF_translate_do_tooltip(const char *context, const char *msgid) { #ifdef WITH_INTERNATIONAL - if (BLF_translate_tooltips()) - return BLF_gettext(msgid); + if(BLF_translate_tooltips()) { + if (context) + return BLF_pgettext(context, msgid); + else + return BLF_gettext(msgid); + } else return msgid; #else -- cgit v1.2.3