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-03-19 23:37:22 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-03-19 23:37:22 +0400
commitd39c6fdf2d7efbb3560038184f43f6bf882c5049 (patch)
tree2850fde8813f530a89094b675976ca94415b4166 /source/blender/blenfont/intern
parent5c48eb3bb9c42ba06f40d7b6d1c83b76d90d6a67 (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/blenfont/intern')
-rw-r--r--source/blender/blenfont/intern/blf_translation.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c
index 4e9408c512a..0cd6bf56c2f 100644
--- a/source/blender/blenfont/intern/blf_translation.c
+++ b/source/blender/blenfont/intern/blf_translation.c
@@ -125,15 +125,22 @@ void BLF_free_unifont_mono(void)
#endif
}
+bool BLF_is_default_context(const char *msgctxt)
+{
+ /* We use the "short" test, a more complete one could be:
+ * return (!msgctxt || !msgctxt[0] || !strcmp(msgctxt == BLF_I18NCONTEXT_DEFAULT_BPYRNA))
+ */
+ /* Note: trying without the void string check for now, it *should* not be necessary... */
+ return (!msgctxt || msgctxt[0] == BLF_I18NCONTEXT_DEFAULT_BPYRNA[0]);
+}
+
const char *BLF_pgettext(const char *msgctxt, const char *msgid)
{
#ifdef WITH_INTERNATIONAL
const char *ret = msgid;
if (msgid && msgid[0]) {
- /*if (msgctxt && !strcmp(msgctxt, BLF_I18NCONTEXT_DEFAULT_BPY_INTERN)) { */
- if (msgctxt && (!msgctxt[0] || msgctxt[0] == BLF_I18NCONTEXT_DEFAULT_BPY[0])) {
- /* BLF_I18NCONTEXT_DEFAULT_BPY context is reserved and considered the same as default NULL one. */
+ if (BLF_is_default_context(msgctxt)) {
msgctxt = BLF_I18NCONTEXT_DEFAULT;
}
ret = bl_locale_pgettext(msgctxt, msgid);