Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blentranslation/intern/blt_lang.c
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BKE_appdir.h" | #include "BKE_appdir.h" | ||||
| #include "DNA_userdef_types.h" | #include "DNA_userdef_types.h" | ||||
| #include "MEM_guardedalloc.h" | #include "MEM_guardedalloc.h" | ||||
| /* Cached IME support flags */ | #if defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) | ||||
| static bool ime_is_lang_supported = false; | /* Cached IM support flags */ | ||||
| static void blt_lang_check_ime_supported(void); | static bool im_is_lang_supported = false; | ||||
| static void blt_lang_check_im_supported(void); | |||||
| #endif | |||||
| #ifdef WITH_INTERNATIONAL | #ifdef WITH_INTERNATIONAL | ||||
| #include "boost_locale_wrapper.h" | #include "boost_locale_wrapper.h" | ||||
| /* Locale options. */ | /* Locale options. */ | ||||
| static const char **locales = NULL; | static const char **locales = NULL; | ||||
| static int num_locales = 0; | static int num_locales = 0; | ||||
| ▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | if (short_locale[0]) { | ||||
| MEM_freeN((void *)short_locale_utf8); | MEM_freeN((void *)short_locale_utf8); | ||||
| } | } | ||||
| else { | else { | ||||
| bl_locale_set(short_locale); | bl_locale_set(short_locale); | ||||
| } | } | ||||
| #else | #else | ||||
| (void)str; | (void)str; | ||||
| #endif | #endif | ||||
| blt_lang_check_ime_supported(); | #if defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) | ||||
| blt_lang_check_im_supported(); | |||||
| #endif | |||||
| } | } | ||||
| /* Get the current locale (short code, e.g. es_ES). */ | /* Get the current locale (short code, e.g. es_ES). */ | ||||
| const char *BLT_lang_get(void) | const char *BLT_lang_get(void) | ||||
| { | { | ||||
| #ifdef WITH_INTERNATIONAL | #ifdef WITH_INTERNATIONAL | ||||
| if (BLT_translate()) { | if (BLT_translate()) { | ||||
| const char *locale = LOCALE(ULANGUAGE); | const char *locale = LOCALE(ULANGUAGE); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (language_variant) { | ||||
| else | else | ||||
| *language_variant = NULL; | *language_variant = NULL; | ||||
| } | } | ||||
| if (_t && !language) { | if (_t && !language) { | ||||
| MEM_freeN(_t); | MEM_freeN(_t); | ||||
| } | } | ||||
| } | } | ||||
| /* Test if the translation context allows IME input - used to | #if defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) | ||||
| * avoid weird character drawing if IME inputs non-ascii chars. | /* Test if the translation context allows IM input - used to | ||||
| * avoid weird character drawing if IM inputs non-ascii chars. | |||||
| */ | */ | ||||
| static void blt_lang_check_ime_supported(void) | static void blt_lang_check_im_supported(void) | ||||
| { | { | ||||
| #ifdef WITH_INPUT_IME | #ifdef _WIN32 | ||||
| const char *uilng = BLT_lang_get(); | const char *uilng = BLT_lang_get(); | ||||
| if (U.transopts & USER_DOTRANSLATE) { | if (U.transopts & USER_DOTRANSLATE) { | ||||
| ime_is_lang_supported = STREQ(uilng, "zh_CN") || | im_is_lang_supported = STREQ(uilng, "zh_CN") || | ||||
| STREQ(uilng, "zh_TW") || | STREQ(uilng, "zh_TW") || | ||||
| STREQ(uilng, "ja_JP"); | STREQ(uilng, "ja_JP"); | ||||
| } | } | ||||
| else { | |||||
| ime_is_lang_supported = false; | |||||
| } | |||||
| #else | #else | ||||
| ime_is_lang_supported = false; | im_is_lang_supported = true; | ||||
| #endif | #endif /* _WIN32 */ | ||||
| } | } | ||||
| #endif /* defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) */ | |||||
| bool BLT_lang_is_ime_supported(void) | bool BLT_lang_is_im_supported(void) | ||||
| { | { | ||||
| #ifdef WITH_INPUT_IME | #if defined(WITH_IM_OVERTHESPOT) || defined(WITH_IM_ONTHESPOT) | ||||
| return ime_is_lang_supported; | return im_is_lang_supported; | ||||
| #else | #else | ||||
| return false; | return false; | ||||
| #endif | #endif | ||||
| } | } | ||||