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 +} + diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 329f4599e01..31b47325aa7 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -820,16 +820,6 @@ uiStyle* UI_GetStyle(void); /* linker workaround ack! */ void UI_template_fix_linking(void); -/* translation */ -int UI_translate_iface(void); -int UI_translate_tooltips(void); -const char *UI_translate_do_iface(const char *msgid); -const char *UI_translate_do_tooltip(const char *msgid); - -/* Those macros should be used everywhere in UI code. */ -#define IFACE_(msgid) UI_translate_do_iface(msgid) -#define TIP_(msgid) UI_translate_do_tooltip(msgid) - /* UI_OT_editsource helpers */ int UI_editsource_enable_check(void); void UI_editsource_active_but_test(uiBut *but); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 2e144c0ca2b..fab983cee43 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -90,50 +90,6 @@ static void ui_free_but(const bContext *C, uiBut *but); -/* ************* translation ************** */ - -int UI_translate_iface(void) -{ -#ifdef WITH_INTERNATIONAL - return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE); -#else - return 0; -#endif -} - -int UI_translate_tooltips(void) -{ -#ifdef WITH_INTERNATIONAL - return (U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_TOOLTIPS); -#else - return 0; -#endif -} - -const char *UI_translate_do_iface(const char *msgid) -{ -#ifdef WITH_INTERNATIONAL - if(UI_translate_iface()) - return BLF_gettext(msgid); - else - return msgid; -#else - return msgid; -#endif -} - -const char *UI_translate_do_tooltip(const char *msgid) -{ -#ifdef WITH_INTERNATIONAL - if(UI_translate_tooltips()) - return BLF_gettext(msgid); - else - return msgid; -#else - return msgid; -#endif -} - /* ************* window matrix ************** */ void ui_block_to_window_fl(const ARegion *ar, uiBlock *block, float *x, float *y) diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 9a253952e6d..aa80cb632ec 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -43,6 +43,8 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_userdef_types.h" #include "BKE_context.h" diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index a3d71674a03..6cd538112e6 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -40,6 +40,8 @@ #include "BLI_string.h" #include "BLI_ghash.h" +#include "BLF_translation.h" + #include "BKE_animsys.h" #include "BKE_colortools.h" #include "BKE_context.h" diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 5aa15cc68d6..fedb12f747c 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -40,6 +40,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_depsgraph.h" #include "BKE_library.h" diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index c592e87f3b9..7075b0592b8 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -4,7 +4,7 @@ Import ('env') -incs = '. ../editors/include ../makesdna ../makesrna ../blenlib ../blenkernel ../nodes' +incs = '. ../editors/include ../makesdna ../makesrna ../blenfont ../blenlib ../blenkernel ../nodes' incs += ' ../imbuf ../blenloader ../gpu ../render/extern/include ../windowmanager' incs += ' #intern/guardedalloc #intern/memutil #extern/glew/include' incs += ' #intern/audaspace/intern ' + env['BF_PYTHON_INC'] diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt index 9a214718e73..63ccdea3f0d 100644 --- a/source/blender/python/intern/CMakeLists.txt +++ b/source/blender/python/intern/CMakeLists.txt @@ -25,6 +25,7 @@ set(INC .. + ../../blenfont ../../blenkernel ../../blenlib ../../blenloader diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 44e26a56db6..15a9ba44552 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -77,7 +77,7 @@ #include "../generic/py_capi_utils.h" #ifdef WITH_INTERNATIONAL -#include "UI_interface.h" /* bad level call into editors */ +#include "BLF_translation.h" #endif #define USE_PEDANTIC_WRITE