diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-19 23:37:22 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-19 23:37:22 +0400 |
commit | d39c6fdf2d7efbb3560038184f43f6bf882c5049 (patch) | |
tree | 2850fde8813f530a89094b675976ca94415b4166 /source/blender/python/intern/bpy_app_translations.c | |
parent | 5c48eb3bb9c42ba06f40d7b6d1c83b76d90d6a67 (diff) |
Various cleanup around default i18n context.
Issue is that the real default context is NULL, however, in python and RNA, this value can't be used easily. So we use a specific string instead ("*"), defined as BLF_I18NCONTEXT_DEFAULT_BPYRNA.
From now on, all bpy/rna code should only use the BLF_I18NCONTEXT_DEFAULT_BPYRNA value, while all "usual" C code should use the BLF_I18NCONTEXT_DEFAULT value (BLF_pgettext is still able to "understand" both, anyway).
Also added BLF_is_default_context helper func, so that we can keep that check in a single place!
Finally, we should no need anymore to understand the void string "" as default context too - two values for a same thing are more than enough!
Diffstat (limited to 'source/blender/python/intern/bpy_app_translations.c')
-rw-r--r-- | source/blender/python/intern/bpy_app_translations.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 35c39814124..83e9d850ba0 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -74,7 +74,7 @@ typedef struct GHashKey { static GHashKey *_ghashutil_keyalloc(const void *msgctxt, const void *msgid) { GHashKey *key = MEM_mallocN(sizeof(GHashKey), "Py i18n GHashKey"); - key->msgctxt = BLI_strdup(msgctxt ? msgctxt : BLF_I18NCONTEXT_DEFAULT_BPY); + key->msgctxt = BLI_strdup(BLF_is_default_context(msgctxt) ? BLF_I18NCONTEXT_DEFAULT_BPYRNA : msgctxt); key->msgid = BLI_strdup(msgid); return key; } @@ -195,7 +195,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale) else { PyObject *tmp = PyTuple_GET_ITEM(pykey, 0); if (tmp == Py_None) { - msgctxt = BLF_I18NCONTEXT_DEFAULT_BPY; + msgctxt = BLF_I18NCONTEXT_DEFAULT_BPYRNA; } else if (PyUnicode_Check(tmp)) { msgctxt = _PyUnicode_AsString(tmp); @@ -433,7 +433,7 @@ static PyObject *app_translations_contexts_make(void) PyDoc_STRVAR(app_translations_contexts_doc, "A named tuple containing all pre-defined translation contexts.\n" - "WARNING: Never use a (new) context starting with \"" BLF_I18NCONTEXT_DEFAULT_BPY "\", it would be internally " + "WARNING: Never use a (new) context starting with \"" BLF_I18NCONTEXT_DEFAULT_BPYRNA "\", it would be internally " "assimilated as the default one!\n" ); |