diff options
author | Kent Mein <mein@cs.umn.edu> | 2007-07-10 19:10:32 +0400 |
---|---|---|
committer | Kent Mein <mein@cs.umn.edu> | 2007-07-10 19:10:32 +0400 |
commit | 8198ea61beeb62c4ad86cc6bd1b91f4b756928ef (patch) | |
tree | ccd2b51c14973468f9b9a07672f51326a16d4bb2 /source/blender/src/language.c | |
parent | 9a07d9cd98d0dd09ce4a6837d27ce352d76f727d (diff) |
Update to the translation code. Patch provided by dripstone.
Basically move stuff out of filesel.c and into language.c and changes
when exactly it does the conversion. It was doing it when not needed for
some machines. It probably still needs work but its slowly getting better.
I also removed some commented out code.
Kent
Diffstat (limited to 'source/blender/src/language.c')
-rw-r--r-- | source/blender/src/language.c | 59 |
1 files changed, 47 insertions, 12 deletions
diff --git a/source/blender/src/language.c b/source/blender/src/language.c index 4c485bad8d3..bdf0dfa3baf 100644 --- a/source/blender/src/language.c +++ b/source/blender/src/language.c @@ -52,6 +52,33 @@ #include "BMF_Api.h" +#ifdef WITH_ICONV +#include "iconv.h" + +void string_to_utf8(char *original, char *utf_8, char *code) +{ + size_t inbytesleft=strlen(original); + size_t outbytesleft=512; + size_t rv=0; + iconv_t cd; + + cd=iconv_open("UTF-8", code); + + if (cd == (iconv_t)(-1)) { + printf("iconv_open Error"); + *utf_8='\0'; + return ; + } + rv=iconv(cd, &original, &inbytesleft, &utf_8, &outbytesleft); + if (rv == (size_t) -1) { + printf("iconv Error\n"); + return ; + } + *utf_8 = '\0'; + iconv_close(cd); +} +#endif // WITH_ICONV + #ifdef INTERNATIONAL #include "FTF_Api.h" @@ -92,23 +119,31 @@ int BIF_DrawString(BMF_Font* font, char *str, int translate) #ifdef INTERNATIONAL if(G.ui_international == TRUE) { if(translate) - return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8); + { +#ifdef WITH_ICONV + if(translate & CONVERT_TO_UTF8) { + char utf_8[512]; + + struct LANGMenuEntry *lme; + lme = find_language(U.language); + + if (!strcmp(lme->code, "ja_JP")) + string_to_utf8(str, utf_8, "Shift_JIS"); /* Japanese */ + else if (!strcmp(lme->code, "zh_CN")) + string_to_utf8(str, utf_8, "GB2312"); /* Chinese */ + + return FTF_DrawString(utf_8, FTF_INPUT_UTF8); + } + else +#endif // WITH_ICONV + return FTF_DrawString(str, FTF_USE_GETTEXT | FTF_INPUT_UTF8); + } else return FTF_DrawString(str, FTF_NO_TRANSCONV | FTF_INPUT_UTF8); } else { return BMF_DrawString(font, str); -/* - glEnable(GL_TEXTURE_2D); - glEnable(GL_BLEND); - BMF_GetFontTexture(font);?? - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - BMF_DrawStringTexture(font, str, pen_x, pen_y, 0.0); - glDisable(GL_TEXTURE_2D); - glDisable(GL_BLEND); - return 0; -*/ } -#else +#else // INTERNATIONAL return BMF_DrawString(font, str); #endif |