added routine that checks for LOCALE/message directory.
authorRob Haarsma <phaseIV@zonnet.nl>
Mon, 12 May 2003 02:49:29 +0000 (02:49 +0000)
committerRob Haarsma <phaseIV@zonnet.nl>
Mon, 12 May 2003 02:49:29 +0000 (02:49 +0000)
projectfiles/blender/ftfont/FTF_ftfont.dsp
source/blender/ftfont/intern/FTF_TTFont.cpp
source/blender/ftfont/intern/FTF_TTFont.h

index e898af031b5cf7a6c5a0cb2807f3d49a6ae30df0..5f7fdc0fd15c50e77bceb6600c5b18b93379c281 100644 (file)
@@ -42,7 +42,7 @@ RSC=rc.exe
 # PROP Target_Dir ""
 LINK32=link.exe -lib
 # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
-# ADD CPP /nologo /W3 /GX /O2 /I "../../../source\blender\makesdna" /I "../../../source\blender\blenloader" /I "../../../../lib/windows/ftgl/include" /I "../../../../lib/windows/freetype/include" /I "../../../lib/windows/iconv/include" /I "../../../../lib/windows/gettext/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "WCHAR_T16" /D "HAVE_LC_MESSAGES" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../../../source\blender\makesdna" /I "../../../source\blender\blenloader" /I "../../../source\blender\blenlib" /I "../../../../lib/windows/ftgl/include" /I "../../../../lib/windows/freetype/include" /I "../../../lib/windows/iconv/include" /I "../../../../lib/windows/gettext/include" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "WCHAR_T16" /D "HAVE_LC_MESSAGES" /YX /FD /c
 # ADD BASE RSC /l 0x411 /d "NDEBUG"
 # ADD RSC /l 0x411 /d "NDEBUG"
 BSC32=bscmake.exe
index 186491d921af6e84f20f9f18a6a78c3839226a33..819d5e8ef66e7ee48e391c2903bf84cca7f8ff09 100644 (file)
@@ -39,6 +39,7 @@
 #include <string.h>
 #include <locale.h>
 #include "libintl.h"
+#include "BLI_blenlib.h"
 
 #ifdef __APPLE__
 #include <libgen.h>
@@ -49,7 +50,6 @@
 #include "FTF_TTFont.h"
 
 #define DOMAIN_NAME "blender"
-#define MESSAGE_FILE "message"
 
 #define SYSTEM_ENCODING_DEFAULT "UTF-8"
 #define FONT_SIZE_DEFAULT 12
@@ -103,9 +103,50 @@ int utf8towchar(wchar_t *w, char *c)
 
 FTF_TTFont::FTF_TTFont(void)
 {      
+#ifdef __APPLE__
+       char tmp[1024];
+#endif
+
        font=NULL;
        font_size=FONT_SIZE_DEFAULT;
        strcpy(encoding_name, SYSTEM_ENCODING_DEFAULT);
+
+       //set messagepath directory
+
+#ifndef LOCALEDIR
+#define LOCALEDIR "/usr/share/locale"
+#endif
+
+       BLI_make_file_string("/", messagepath, BLI_gethome(), ".blender/locale");
+printf("1. %s\n", messagepath);
+       if (BLI_exist(messagepath) == NULL) {   // locale not in home dir
+
+               strcpy(messagepath, ".blender/locale");
+printf("2. %s\n", messagepath);
+               if(BLI_exist(messagepath) == NULL) {    // locale not in current dir
+
+                       strcpy(messagepath, LOCALEDIR);
+printf("3. %s\n", messagepath);
+                       if(BLI_exist(messagepath) == NULL) {    // locale not in LOCALEDIR
+
+
+#ifdef __APPLE__
+                               /* message catalogs are stored inside the application bundle */
+                               strcpy(tmp, dirname(bprogname));
+                               strcat(tmp, "/../Resources/message");
+                               realpath(tmp, messagepath);
+printf("4. %s\n", messagepath);
+                               if(BLI_exist(messagepath) == NULL) {    // locale not in bundle dir
+#endif
+                                       
+                                       strcpy(messagepath, "message");         // old compatibility as last
+printf("5. %s\n", messagepath);
+                               }
+#ifdef __APPLE__
+                       } // heh
+#endif
+               }
+       }
 }
 
 
@@ -142,10 +183,6 @@ 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];
@@ -169,17 +206,10 @@ 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);
+
+       bindtextdomain(DOMAIN_NAME, messagepath);
        textdomain(DOMAIN_NAME);
-#endif
+
        strcpy(language, str);
 }
 
index c42685c22217040da10653ced3533a8d5ca04311..9492e326a7ef57754ebcb33da31fd0ed314251b7 100644 (file)
@@ -91,6 +91,8 @@ public:
        void SetEncoding(char* str);
 
 protected:
+       char messagepath[1024];
+
        char language[32];
        char encoding_name[32];
        char font_name[128];