diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-03 13:38:21 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-05-03 13:38:21 +0300 |
commit | cb6307162b4c12743cee0db6b05f6b3a68f5258e (patch) | |
tree | bef89fc17e10b72f0c11a2f04ce511b61dfcbc12 /source/blender/blentranslation/intern | |
parent | b34f177a39ce9fdfac05f60d21f6b763833f00f2 (diff) |
Cache whether current translation language supports IME or not
Solves the weak point mentionedi n previous commit.
Diffstat (limited to 'source/blender/blentranslation/intern')
-rw-r--r-- | source/blender/blentranslation/intern/blt_lang.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/source/blender/blentranslation/intern/blt_lang.c b/source/blender/blentranslation/intern/blt_lang.c index 1ad62fa5869..40771b3315a 100644 --- a/source/blender/blentranslation/intern/blt_lang.c +++ b/source/blender/blentranslation/intern/blt_lang.c @@ -64,6 +64,12 @@ static int num_locales = 0; static EnumPropertyItem *locales_menu = NULL; static int num_locales_menu = 0; +#ifdef WITH_INPUT_IME +/* Cached IME support flags */ +static bool ime_is_lang_supported = false; +static void blt_lang_check_ime_supported(void); +#endif + static void free_locales(void) { if (locales) { @@ -280,6 +286,7 @@ void BLT_lang_set(const char *str) #else (void)str; #endif + blt_lang_check_ime_supported(); } /* Get the current locale (short code, e.g. es_ES). */ @@ -355,3 +362,32 @@ void BLT_lang_locale_explode( MEM_freeN(_t); } } + +/* Test if the translation context allows IME input - used to + * avoid weird character drawing if IME inputs non-ascii chars. + */ +static void blt_lang_check_ime_supported(void) +{ +#ifdef WITH_INPUT_IME + const char *uilng = BLT_lang_get(); + if (U.transopts & USER_DOTRANSLATE) { + ime_is_lang_supported = STREQ(uilng, "zh_CN") || + STREQ(uilng, "zh_TW") || + STREQ(uilng, "ja_JP"); + } + else { + ime_is_lang_supported = false; + } +#else + ime_is_lang_supported = false; +#endif +} + +bool BLT_lang_is_ime_supported(void) +{ +#ifdef WITH_INPUT_IME + return ime_is_lang_supported; +#else + return false; +#endif +} |