Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2011-09-15 17:20:18 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2011-09-15 17:20:18 +0400
commit0eda51f2eabe24016efdc8f07825f1ba667cac33 (patch)
tree03d6f876da6b1256b8890b89db09b63952fa544f /source/blender/blenfont
parent30293dc2ca8052ad0c7113c77365feca590f4d05 (diff)
Fixing issues with i18n stuff:
- Make gettext stuff draw-time. so switching between languages can happens without restart now. - Added option to translate visible interface (menus, buttons, labels) and tooltips. Now it's possible to have english UI and localized tooltips. - Clean-up sources, do not use gettext stuff for things which can be collected with RNA. - Fix issues with windows 64bit and ru_RU locale on my desktop (it was codepage issue). - Added operator "Get Messages" which generates new text block with with all strings collected from RNA. - Changed script for updating blender.pot so now it appends messages collected from rna to automatically gathered messages. To update .pot you have to re-generate messages.txt using "Get Messages" operator and then run update_pot script. - Clean up old translation stuff which wasn't used and most probably wouldn't be used. - Return back "International Fonts" option, so if it's disabled, no gettext lookups happens on draw. - Merged read_homefile function back. No need in splitting it. TODO: - Custom fonts and font size. Current font isn't nice at least for russian locale, it's difficult to read it. - Put references to messages.txt so gettext can merge translation when name/description of some property changes.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf.c2
-rw-r--r--source/blender/blenfont/intern/blf_lang.c66
2 files changed, 45 insertions, 23 deletions
diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c
index 9ec9dd1caa0..7b78bd05fff 100644
--- a/source/blender/blenfont/intern/blf.c
+++ b/source/blender/blenfont/intern/blf.c
@@ -307,7 +307,7 @@ void BLF_enable(int fontid, int option)
const char* BLF_gettext(const char *msgid)
{
#ifdef INTERNATIONAL
- if( msgid!=NULL && strlen(msgid)>0 )
+ if( msgid[0] )
return gettext( msgid );
return "";
#else
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index cfa7514f9af..89d2d365013 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -39,6 +39,11 @@
#ifdef INTERNATIONAL
#include <locale.h>
+
+#if defined (_WIN32)
+#include <windows.h>
+#endif
+
#include "libintl.h"
#include "DNA_userdef_types.h"
@@ -52,11 +57,6 @@
#include "BLI_string.h"
#include "BLI_path_util.h"
-
-#ifdef __APPLE__
-
-#endif
-
#define DOMAIN_NAME "blender"
#define SYSTEM_ENCODING_DEFAULT "UTF-8"
#define FONT_SIZE_DEFAULT 12
@@ -113,59 +113,81 @@ void BLF_lang_set(const char *str)
{
char *locreturn;
const char *short_locale;
+ int ok= 1;
#if defined (_WIN32)
char *long_locale = locales[ 2 * U.language];
#endif
+ if((U.transopts&USER_DOTRANSLATE)==0)
+ return;
+
if(str)
short_locale = str;
else
short_locale = locales[ 2 * U.language + 1];
#if defined (_WIN32)
- if(short_locale)
- {
+ if(short_locale) {
char *envStr;
+
if( U.language==0 )/* use system setting */
envStr = BLI_sprintfN( "LANG=%s", getenv("LANG") );
else
envStr = BLI_sprintfN( "LANG=%s", short_locale );
+
gettext_putenv(envStr);
MEM_freeN(envStr);
}
+
locreturn= setlocale(LC_ALL, long_locale);
+
if (locreturn == NULL) {
printf("Could not change locale to %s\n", long_locale);
+ ok= 0;
}
#else
- if(short_locale)
{
- BLI_setenv("LANG", short_locale);
- BLI_setenv("LANGUAGE", short_locale);
- }
+ const char *locale;
+ static char default_locale[64]="\0";
- locreturn= setlocale(LC_ALL, short_locale);
- if (locreturn == NULL) {
- char *short_locale_utf8 = BLI_sprintfN("%s.UTF-8", short_locale);
+ if(default_locale[0]==0) /* store defaul locale */
+ strncpy(default_locale, getenv("LANGUAGE"), sizeof(default_locale));
+
+ if(short_locale[0])
+ locale= short_locale;
+ else
+ locale= default_locale;
+
+ BLI_setenv("LANG", locale);
+ BLI_setenv("LANGUAGE", locale);
+
+ locreturn= setlocale(LC_ALL, locale);
- locreturn= setlocale(LC_ALL, short_locale_utf8);
if (locreturn == NULL) {
- printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
- }
+ char *short_locale_utf8= BLI_sprintfN("%s", short_locale);
- MEM_freeN(short_locale_utf8);
+ locreturn= setlocale(LC_ALL, short_locale_utf8);
+
+ if (locreturn == NULL) {
+ printf("Could not change locale to %s nor %s\n", short_locale, short_locale_utf8);
+ ok= 0;
+ }
+
+ MEM_freeN(short_locale_utf8);
+ }
}
#endif
- else
- {
- printf("Change locale to %s\n", locreturn );
+
+ if(ok) {
+ //printf("Change locale to %s\n", locreturn );
BLI_strncpy(global_language, locreturn, sizeof(global_language));
}
+
setlocale(LC_NUMERIC, "C");
textdomain(DOMAIN_NAME);
bindtextdomain(DOMAIN_NAME, global_messagepath);
- /* bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name); */
+ bind_textdomain_codeset(DOMAIN_NAME, global_encoding_name);
}
void BLF_lang_encoding(const char *str)