From e4269043b492d2fb3ae1b751148d327ff59a26c9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 9 Nov 2011 14:13:17 +0000 Subject: Moving i18n code to BLF_translation.h This way, we will be able to use it in non-UI parts of the code too. --- source/blender/blenfont/BLF_translation.h | 10 ++++++ source/blender/blenfont/intern/blf_translation.c | 45 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'source/blender/blenfont') 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 +} + -- cgit v1.2.3