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>2013-01-21 14:52:34 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-01-21 14:52:34 +0400
commit3aa499f3f7ab750d8f0f647f8976a02967c7b040 (patch)
tree6137e31f2dc14958f23244ff654b85be7aa7275e /source/blender/blenfont
parent22b5f097d2fbfbd3ce815bfef57d11e08fd67102 (diff)
I18n fix: "" context is not the same as NULL context!
This bug did not appear earlier because the "" default context was actually never used, always NULL context was passed instead. But bpy.app.translations uses "" as default context in its keys (simplifies the hash/comp functions of internal py messages cache)... So now, Blender prefers NULL (None in python) as default context value, but understands also "" as such.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_translation.h9
-rw-r--r--source/blender/blenfont/intern/blf_translation.c9
2 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h
index b90b5c60a36..35ca5f19bdc 100644
--- a/source/blender/blenfont/BLF_translation.h
+++ b/source/blender/blenfont/BLF_translation.h
@@ -50,7 +50,7 @@ void BLF_lang_free(void);
/* Set the current locale. */
void BLF_lang_set(const char *);
-/* Get the current locale (short code, e.g. es_ES). */
+/* Get the current locale ([partial] ISO code, e.g. es_ES). */
const char *BLF_lang_get(void);
/* Get locale's elements (if relevant pointer is not NULL and element actually exists, e.g. if there is no variant,
@@ -110,8 +110,11 @@ const char *BLF_translate_do_tooltip(const char *msgctxt, const char *msgid);
* things, and limit the number of existing contexts!
*/
-/* Default, void context. Just in case... */
-#define BLF_I18NCONTEXT_DEFAULT ""
+/* Default, void context.
+ * WARNING! The "" context is not the same as no (NULL) context at mo/boost::locale level!
+ */
+#define BLF_I18NCONTEXT_DEFAULT NULL /* Translated as None in Python. */
+#define BLF_I18NCONTEXT_DEFAULT_BPY_INTERN "" /* Only used in code, never exposed to user! */
/* Default context for operator names/labels. */
#define BLF_I18NCONTEXT_OPERATOR_DEFAULT "Operator"
diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c
index 6394d1169cf..a77b464822b 100644
--- a/source/blender/blenfont/intern/blf_translation.c
+++ b/source/blender/blenfont/intern/blf_translation.c
@@ -91,7 +91,14 @@ const char *BLF_pgettext(const char *msgctxt, const char *msgid)
{
#ifdef WITH_INTERNATIONAL
if (msgid && msgid[0]) {
- const char *ret = bl_locale_pgettext(msgctxt, msgid);
+ const char *ret;
+
+ /*if (msgctxt && !strcmp(msgctxt, BLF_I18NCONTEXT_DEFAULT_BPY_INTERN)) { */
+ if (msgctxt && !msgctxt[0]) {
+ /* BLF_I18NCONTEXT_DEFAULT_BPY_INTERN context is reserved and considered the same as default NULL one. */
+ msgctxt = NULL;
+ }
+ ret = bl_locale_pgettext(msgctxt, msgid);
/* We assume if the returned string is the same (memory level) as the msgid, no translation was found,
* and we can try py scripts' ones!
*/