[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23443] trunk/blender/source/blender: - cmake/make/scons didnt define INTERNATIONAL when buidling blenfont

Campbell Barton ideasman42 at gmail.com
Thu Sep 24 09:03:18 CEST 2009


Revision: 23443
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23443
Author:   campbellbarton
Date:     2009-09-24 09:03:18 +0200 (Thu, 24 Sep 2009)

Log Message:
-----------
- cmake/make/scons didnt define INTERNATIONAL when buidling blenfont

- BLF_lang_init used confusing IFDEF's, unlikely this was well tested. Split this into 3 functions for Apple/Win32/Unix, Unix uses BLI_gethome_folder(), cant test others, ideally they should use BLI_gethome_folder too but needs testing.
Possibly each os cant be made to use BLI_gethome_folder and the separate func's can be removed (please test).

- units, hectometers were displayed wrong.

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/CMakeLists.txt
    trunk/blender/source/blender/blenfont/Makefile
    trunk/blender/source/blender/blenfont/SConscript
    trunk/blender/source/blender/blenfont/intern/blf_lang.c
    trunk/blender/source/blender/blenkernel/intern/unit.c

Modified: trunk/blender/source/blender/blenfont/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/blenfont/CMakeLists.txt	2009-09-24 06:48:03 UTC (rev 23442)
+++ trunk/blender/source/blender/blenfont/CMakeLists.txt	2009-09-24 07:03:18 UTC (rev 23443)
@@ -32,6 +32,7 @@
 
 IF(WITH_INTERNATIONAL)
 	SET(INC ${INC} ${GETTEXT_INC})
+	ADD_DEFINITIONS(-DINTERNATIONAL)
 ENDIF(WITH_INTERNATIONAL)
 
 IF(WIN32)

Modified: trunk/blender/source/blender/blenfont/Makefile
===================================================================
--- trunk/blender/source/blender/blenfont/Makefile	2009-09-24 06:48:03 UTC (rev 23442)
+++ trunk/blender/source/blender/blenfont/Makefile	2009-09-24 07:03:18 UTC (rev 23443)
@@ -28,3 +28,7 @@
 DIRS = intern
 
 include nan_subdirs.mk
+
+ifeq ($(INTERNATIONAL), true)
+	CPPFLAGS += -DINTERNATIONAL
+endif

Modified: trunk/blender/source/blender/blenfont/SConscript
===================================================================
--- trunk/blender/source/blender/blenfont/SConscript	2009-09-24 06:48:03 UTC (rev 23442)
+++ trunk/blender/source/blender/blenfont/SConscript	2009-09-24 07:03:18 UTC (rev 23443)
@@ -9,9 +9,13 @@
 incs += ' ' + env['BF_FREETYPE_INC']
 incs += ' ' + env['BF_GETTEXT_INC']
 
-defs = ''
+defs = []
 
 if sys.platform == 'win32':
-	defs += ' _WIN32 USE_GETTEXT_DLL'
+	defs.append('_WIN32')
+	defs.append('USE_GETTEXT_DLL')
 
+if env['WITH_BF_INTERNATIONAL']:
+    defs.append('INTERNATIONAL')
+
 env.BlenderLib ( 'bf_blenfont', sources, Split(incs), Split(defs), libtype=['core','player'], priority=[210,210] )

Modified: trunk/blender/source/blender/blenfont/intern/blf_lang.c
===================================================================
--- trunk/blender/source/blender/blenfont/intern/blf_lang.c	2009-09-24 06:48:03 UTC (rev 23442)
+++ trunk/blender/source/blender/blenfont/intern/blf_lang.c	2009-09-24 07:03:18 UTC (rev 23443)
@@ -60,17 +60,14 @@
 char global_language[32];
 char global_encoding_name[32];
 
-
-void BLF_lang_init(void)
+#if defined(__APPLE__)
+void BLF_lang_init(void) /* Apple Only, todo - use BLI_gethome_folder  */
 {
-#ifdef __APPLE__
 	char *bundlepath;
-#endif
 
 	strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
 
 	/* set messagepath directory */
-
 #ifndef LOCALEDIR
 #define LOCALEDIR "/usr/share/locale"
 #endif
@@ -81,45 +78,53 @@
 		BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
 
 		if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
-#ifdef WIN32 
-			BLI_make_file_string("/", global_messagepath, BLI_gethome(), "/locale");
-			if (!BLI_exist(global_messagepath)) {
-#endif
-#ifdef __APPLE__
 			/* message catalogs are stored inside the application bundle */
 			bundlepath= BLI_getbundle();
 			strcpy(global_messagepath, bundlepath);
 			strcat(global_messagepath, "/Contents/Resources/locale");
 			if (!BLI_exist(global_messagepath)) { /* locale not in bundle (now that's odd..) */
-#endif
 				strcpy(global_messagepath, LOCALEDIR);
 
 				if (!BLI_exist(global_messagepath)) { /* locale not in LOCALEDIR */
 					strcpy(global_messagepath, "message"); /* old compatibility as last */
 				}
-#ifdef WIN32
 			}
-#endif
-#ifdef __APPLE__
-			}
-#endif
 		}
 	}
 }
+#elif defined(_WIN32)
+void BLF_lang_init(void) /* Windows Only, todo - use BLI_gethome_folder  */
+{
+	strcpy(global_encoding_name, SYSTEM_ENCODING_DEFAULT);
+	
+	strcpy(global_messagepath, ".blender/locale");
 
+	if (!BLI_exist(global_messagepath)) { /* locale not in current dir */
+		BLI_make_file_string("/", global_messagepath, BLI_gethome(), ".blender/locale");
+
+		if (!BLI_exist(global_messagepath)) { /* locale not in home dir */
+			BLI_make_file_string("/", global_messagepath, BLI_gethome(), "/locale");
+		}
+	}
+}
+#else
+void BLF_lang_init(void)  /* not win or mac */
+{
+	char *messagepath= BLI_gethome_folder("locale", BLI_GETHOME_ALL);
+	
+	if(messagepath)
+		strncpy(global_messagepath, messagepath, sizeof(global_messagepath));
+	else
+		global_messagepath[0]= '\0';
+
+}
+#endif
+
 void BLF_lang_set(const char *str)
 {
 #if defined (_WIN32) || defined(__APPLE__)
-	char envstr[12];
-
-	sprintf(envstr, "LANG=%s", str);
-	envstr[strlen(envstr)]= '\0';
-#ifdef _WIN32
-	gettext_putenv(envstr);
+	BLI_setenv("LANG", str);
 #else
-	putenv(envstr);
-#endif
-#else
 	char *locreturn= setlocale(LC_ALL, str);
 	if (locreturn == NULL) {
 		char *lang;

Modified: trunk/blender/source/blender/blenkernel/intern/unit.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/unit.c	2009-09-24 06:48:03 UTC (rev 23442)
+++ trunk/blender/source/blender/blenkernel/intern/unit.c	2009-09-24 07:03:18 UTC (rev 23443)
@@ -75,7 +75,7 @@
 /* Lengths */
 static struct bUnitDef buMetricLenDef[] = {
 	{"kilometer", "kilometers",		"km", NULL,	"Kilometers", 1000.0, 0.0,		B_UNIT_DEF_NONE},
-	{"hectometer", "hectometers",	"hm", NULL,	"10 Meters", 100.0, 0.0,			B_UNIT_DEF_SUPPRESS},
+	{"hectometer", "hectometers",	"hm", NULL,	"100 Meters", 100.0, 0.0,			B_UNIT_DEF_SUPPRESS},
 	{"dekameter", "dekameters",		"dkm",NULL,	"10 Meters", 10.0, 0.0,			B_UNIT_DEF_SUPPRESS},
 	{"meter", "meters",				"m",  NULL,	"Meters", 1.0, 0.0, 			B_UNIT_DEF_NONE}, /* base unit */
 	{"decimetre", "decimetres",		"dm", NULL,	"10 Centimeters", 0.1, 0.0,			B_UNIT_DEF_SUPPRESS},
@@ -485,7 +485,7 @@
 		if(unit==NULL)
 			unit= unit_default(usys);
 
-		/* add the unit prefic and re-run, use brackets incase there was an expression given */
+		/* add the unit prefix and re-run, use brackets incase there was an expression given */
 		if(snprintf(str_tmp, sizeof(str_tmp), "(%s)%s", str, unit->name) < sizeof(str_tmp)) {
 			strncpy(str, str_tmp, len_max);
 			return bUnit_ReplaceString(str, len_max, NULL, scale_pref, system, type);





More information about the Bf-blender-cvs mailing list