- 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.
This commit is contained in:
Campbell Barton 2009-09-24 07:03:18 +00:00
parent 20998fdcfa
commit b94ed5d7e4
5 changed files with 43 additions and 29 deletions

@ -32,6 +32,7 @@ SET(INC
IF(WITH_INTERNATIONAL)
SET(INC ${INC} ${GETTEXT_INC})
ADD_DEFINITIONS(-DINTERNATIONAL)
ENDIF(WITH_INTERNATIONAL)
IF(WIN32)

@ -28,3 +28,7 @@ SOURCEDIR = source/blender/blenfont
DIRS = intern
include nan_subdirs.mk
ifeq ($(INTERNATIONAL), true)
CPPFLAGS += -DINTERNATIONAL
endif

@ -9,9 +9,13 @@ incs += ' #/extern/glew/include'
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] )

@ -60,17 +60,14 @@ char global_messagepath[1024];
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,44 +78,52 @@ void BLF_lang_init(void)
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);
#else
putenv(envstr);
#endif
BLI_setenv("LANG", str);
#else
char *locreturn= setlocale(LC_ALL, str);
if (locreturn == NULL) {

@ -75,7 +75,7 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum
/* 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 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre
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);