[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41698] trunk/blender/source/blender: Moving i18n code to BLF_translation.h

Bastien Montagne montagne29 at wanadoo.fr
Wed Nov 9 15:13:18 CET 2011


Revision: 41698
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41698
Author:   mont29
Date:     2011-11-09 14:13:17 +0000 (Wed, 09 Nov 2011)
Log Message:
-----------
Moving i18n code to BLF_translation.h

This way, we will be able to use it in non-UI parts of the code too.

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/BLF_translation.h
    trunk/blender/source/blender/blenfont/intern/blf_translation.c
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_panel.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/space_node/node_templates.c
    trunk/blender/source/blender/python/SConscript
    trunk/blender/source/blender/python/intern/CMakeLists.txt
    trunk/blender/source/blender/python/intern/bpy_rna.c

Modified: trunk/blender/source/blender/blenfont/BLF_translation.h
===================================================================
--- trunk/blender/source/blender/blenfont/BLF_translation.h	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/blenfont/BLF_translation.h	2011-11-09 14:13:17 UTC (rev 41698)
@@ -58,8 +58,18 @@
 
 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 */

Modified: trunk/blender/source/blender/blenfont/intern/blf_translation.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_translation.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/blenfont/intern/blf_translation.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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 @@
 	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
+}
+

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2011-11-09 14:13:17 UTC (rev 41698)
@@ -820,16 +820,6 @@
 /* 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);

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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)

Modified: trunk/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_panel.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/editors/interface/interface_panel.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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"

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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"

Modified: trunk/blender/source/blender/editors/space_node/node_templates.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_templates.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/editors/space_node/node_templates.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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"

Modified: trunk/blender/source/blender/python/SConscript
===================================================================
--- trunk/blender/source/blender/python/SConscript	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/python/SConscript	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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']

Modified: trunk/blender/source/blender/python/intern/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/intern/CMakeLists.txt	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/python/intern/CMakeLists.txt	2011-11-09 14:13:17 UTC (rev 41698)
@@ -25,6 +25,7 @@
 
 set(INC 
 	..
+	../../blenfont
 	../../blenkernel
 	../../blenlib
 	../../blenloader

Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c	2011-11-09 14:00:24 UTC (rev 41697)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c	2011-11-09 14:13:17 UTC (rev 41698)
@@ -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




More information about the Bf-blender-cvs mailing list