store message catalogs in Resources folder of the application bundle on OS
authorStefan Gartner <stefang@aon.at>
Fri, 9 May 2003 20:20:40 +0000 (20:20 +0000)
committerStefan Gartner <stefang@aon.at>
Fri, 9 May 2003 20:20:40 +0000 (20:20 +0000)
X. Opening a file selector is no longer needed in order to switch the
language for the first time; apparently gettext wasn't too happy about
relative paths.

source/blender/ftfont/intern/FTF_TTFont.cpp
source/darwin/Makefile

index 761f301b44896828ad87823acf7edf15adbc751f..315de8178316be6286bbaccaced3f5a3f6362888 100644 (file)
 #include <string.h>
 #include <locale.h>
 #include "libintl.h"
+
+#ifdef __APPLE__
+#include <libgen.h>
+#endif
+
 #include "../FTF_Settings.h"
 
 #include "FTF_TTFont.h"
@@ -52,6 +57,7 @@
 
 #define FTF_MAX_STR_SIZE 256
 
+extern char bprogname[];
 
 int utf8towchar(wchar_t *w, char *c)
 {
@@ -136,6 +142,11 @@ int FTF_TTFont::SetFont(char* str, int size)
 
 void FTF_TTFont::SetLanguage(char* str)
 {
+#ifdef __APPLE__
+       char tmp[1024];
+       char msgpath[1024];
+#endif
+
 #if defined (_WIN32) || defined(__APPLE__)
        char envstr[12];
 
@@ -157,10 +168,18 @@ void FTF_TTFont::SetLanguage(char* str)
        
        setlocale(LC_NUMERIC, "C");
 #endif
-       
+
+#ifdef __APPLE__
+       /* message catalogs are stored inside the application bundle */
+       strcpy(tmp, dirname(bprogname));
+       strcat(tmp, "/../Resources/message");
+       realpath(tmp, msgpath);
+       bindtextdomain(DOMAIN_NAME, msgpath);
+       textdomain(DOMAIN_NAME);
+#else
        bindtextdomain(DOMAIN_NAME, MESSAGE_FILE);
        textdomain(DOMAIN_NAME);
-
+#endif
        strcpy(language, str);
 }
 
index c65b4d82bd8ce5d3046c0488d06e57c346f3bffa..9ffc42d6beb8002decb877771bca70029788bd1b 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile,v 1.4 2003/02/02 17:28:15 sgefant Exp $
+# $Id: Makefile,v 1.5 2003/02/09 18:32:55 sgefant Exp $
 #
 # ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 #
@@ -44,6 +44,10 @@ all::
        @cp $(DIR)/bin/$(APPLICATION) $(DIR)/bin/$(APPLICATION).app/Contents/MacOS/
        @echo "---> adding excutable attributes"
        @chmod +x $(DIR)/bin/$(APPLICATION).app/Contents/MacOS/$(APPLICATION)
+ifeq ($(APPLICATION), blender)
+       @echo "---> copying message files"
+       @cp -R ../../bin/message $(DIR)/bin/$(APPLICATION).app/Contents/Resources
+endif
        @echo "---> removing CVS directories and Mac hidden files from distribution"
        @find $(DIR)/bin/$(APPLICATION).app -name CVS -prune -exec rm -rf {} \;
        @find $(DIR)/bin/$(APPLICATION).app -name .DS_Store -exec rm -f {} \;