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:
authorBastien Montagne <montagne29@wanadoo.fr>2015-04-10 16:28:47 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2015-04-10 16:34:31 +0300
commit8a99dc232469a987ca2631b3ab5dd8e0da948054 (patch)
treedc36d7d3c0d99afd595b88b14c929a0d058ea27c /source/blender/blenfont
parenta36c43fc8cabdaee69df69e9b0d2ee37fd7a8b12 (diff)
BLF translation: fix BLF_lang_get(), add UI-agnostic BLF_translate/_do helpers.
BLF_lang_get() shall return 'default' Blender locale (en_US) when translations are completely disabled! Also, add BLF_translate() and BLF_translate_do() to allow translating some strings outside of label/tip context, but still only when i18n global flag is enabled.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_translation.h2
-rw-r--r--source/blender/blenfont/intern/blf_lang.c13
-rw-r--r--source/blender/blenfont/intern/blf_translation.c24
3 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h
index 49bfdbfe877..c9b0c253ed4 100644
--- a/source/blender/blenfont/BLF_translation.h
+++ b/source/blender/blenfont/BLF_translation.h
@@ -79,9 +79,11 @@ bool BLF_is_default_context(const char *msgctxt);
const char *BLF_pgettext(const char *msgctxt, const char *msgid);
/* translation */
+bool BLF_translate(void);
bool BLF_translate_iface(void);
bool BLF_translate_tooltips(void);
bool BLF_translate_new_dataname(void);
+const char *BLF_translate_do(const char *msgctxt, const char *msgid);
const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid);
const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid);
const char *BLF_translate_do_new_dataname(const char *msgctxt, const char *msgid);
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index 99e1aa5d3e3..4683081a1ed 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -284,12 +284,15 @@ void BLF_lang_set(const char *str)
const char *BLF_lang_get(void)
{
#ifdef WITH_INTERNATIONAL
- const char *locale = LOCALE(ULANGUAGE);
- if (locale[0] == '\0') {
- /* Default locale, we have to find which one we are actually using! */
- locale = bl_locale_get();
+ if (BLF_translate()) {
+ const char *locale = LOCALE(ULANGUAGE);
+ if (locale[0] == '\0') {
+ /* Default locale, we have to find which one we are actually using! */
+ locale = bl_locale_get();
+ }
+ return locale;
}
- return locale;
+ return "en_US"; /* Kind of default locale in Blender when no translation enabled. */
#else
return "";
#endif
diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c
index 2a4a152f0eb..25464864657 100644
--- a/source/blender/blenfont/intern/blf_translation.c
+++ b/source/blender/blenfont/intern/blf_translation.c
@@ -164,6 +164,15 @@ const char *BLF_pgettext(const char *msgctxt, const char *msgid)
#endif
}
+bool BLF_translate(void)
+{
+#ifdef WITH_INTERNATIONAL
+ return (U.transopts & USER_DOTRANSLATE) != 0;
+#else
+ return false;
+#endif
+}
+
bool BLF_translate_iface(void)
{
#ifdef WITH_INTERNATIONAL
@@ -191,6 +200,21 @@ bool BLF_translate_new_dataname(void)
#endif
}
+const char *BLF_translate_do(const char *msgctxt, const char *msgid)
+{
+#ifdef WITH_INTERNATIONAL
+ if (BLF_translate()) {
+ return BLF_pgettext(msgctxt, msgid);
+ }
+ else {
+ return msgid;
+ }
+#else
+ (void)msgctxt;
+ return msgid;
+#endif
+}
+
const char *BLF_translate_do_iface(const char *msgctxt, const char *msgid)
{
#ifdef WITH_INTERNATIONAL