diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-20 22:42:09 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-20 22:42:09 +0400 |
commit | 885441e75804a92d4c2270fd006f3e71fc460d7b (patch) | |
tree | 7d3e89d07af080a2146eb747ff9da6ecd9d0e7f9 /source/blender/blenfont | |
parent | e9b0b402cc85533c8b247b174f17f41b1892ef04 (diff) |
I18n users request: add the ability to use a translated name for newly added/created objects or other datablocks.
This simply adds a third "translation type" (in addition to iface and tip), "new data", with relevant user settings flag and helper funcs/macros (and py api).
Currently implemented name translation when adding new objects, as well as modifiers and constraints, will add the others (cd layers, scenes, perhaps nodes [though I think they do not need this], etc.) later.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_translation.h | 6 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_translation.c | 24 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 379978feca3..f59d3409b65 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -77,8 +77,10 @@ const char *BLF_pgettext(const char *msgctxt, const char *msgid); /* translation */ bool BLF_translate_iface(void); bool BLF_translate_tooltips(void); +bool BLF_translate_new_dataname(void); const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid); const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); +const char *BLF_translate_do_new_dataname(const char *msgctxt, const char *msgid); /* The "translation-marker" macro. */ @@ -90,14 +92,18 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid); /*# define _(msgid) BLF_gettext(msgid) */ # define IFACE_(msgid) BLF_translate_do_iface(NULL, msgid) # define TIP_(msgid) BLF_translate_do_tooltip(NULL, msgid) +# define DATA_(msgid) BLF_translate_do_new_dataname(NULL, msgid) # define CTX_IFACE_(context, msgid) BLF_translate_do_iface(context, msgid) # define CTX_TIP_(context, msgid) BLF_translate_do_tooltip(context, msgid) +# define CTX_DATA_(context, msgid) BLF_translate_do_new_dataname(context, msgid) #else /*# define _(msgid) msgid */ # define IFACE_(msgid) msgid # define TIP_(msgid) msgid +# define DATA_(msgid) msgid # define CTX_IFACE_(context, msgid) msgid # define CTX_TIP_(context, msgid) msgid +# define CTX_DATA_(context, msgid) msgid #endif /* Helper macro, when we want to define a same msgid for multiple msgctxt... diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 0cd6bf56c2f..57f442f8bfc 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -177,6 +177,15 @@ bool BLF_translate_tooltips(void) #endif } +bool BLF_translate_new_dataname(void) +{ +#ifdef WITH_INTERNATIONAL + return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_NEWDATANAME); +#else + return false; +#endif +} + const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid) { #ifdef WITH_INTERNATIONAL @@ -206,3 +215,18 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid) return msgid; #endif } + +const char *BLF_translate_do_new_dataname(const char *msgctxt, const char *msgid) +{ +#ifdef WITH_INTERNATIONAL + if (BLF_translate_new_dataname()) { + return BLF_pgettext(msgctxt, msgid); + } + else { + return msgid; + } +#else + (void)msgctxt; + return msgid; +#endif +} |