diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2011-11-09 18:13:17 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2011-11-09 18:13:17 +0400 |
commit | e4269043b492d2fb3ae1b751148d327ff59a26c9 (patch) | |
tree | d00688c4bdf64308cdba45fc56640df6ed5532a5 /source/blender/blenfont | |
parent | ee1569b9330a231d8781045853f5f794518de492 (diff) |
Moving i18n code to BLF_translation.h
This way, we will be able to use it in non-UI parts of the code too.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/BLF_translation.h | 10 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_translation.c | 45 |
2 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 0d33180a817..ddbc9a6a760 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -58,8 +58,18 @@ void BLF_lang_encoding_name(const char *str); 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); + + /*#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) #endif /* BLF_TRANSLATION_H */ diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 917d95cfc20..8688249732f 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -44,6 +44,8 @@ #include "BLF_translation.h" +#include "DNA_userdef_types.h" /* For user settings. */ + #ifdef WITH_INTERNATIONAL const char unifont_filename[]="droidsans.ttf.gz"; static unsigned char *unifont_ttf= NULL; @@ -88,3 +90,46 @@ const char* BLF_gettext(const char *msgid) return msgid; #endif } + +int BLF_translate_iface(void) +{ +#ifdef WITH_INTERNATIONAL + return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE); +#else + return 0; +#endif +} + +int BLF_translate_tooltips(void) +{ +#ifdef WITH_INTERNATIONAL + return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_TOOLTIPS); +#else + return 0; +#endif +} + +const char *BLF_translate_do_iface(const char *msgid) +{ +#ifdef WITH_INTERNATIONAL + if(BLF_translate_iface()) + return BLF_gettext(msgid); + else + return msgid; +#else + return msgid; +#endif +} + +const char *BLF_translate_do_tooltip(const char *msgid) +{ +#ifdef WITH_INTERNATIONAL + if(BLF_translate_tooltips()) + return BLF_gettext(msgid); + else + return msgid; +#else + return msgid; +#endif +} + |