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:
Diffstat (limited to 'source/blender/blenfont/intern/blf_translation.c')
-rw-r--r--source/blender/blenfont/intern/blf_translation.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c
index fe14f5d4d1c..1d82abcf32d 100644
--- a/source/blender/blenfont/intern/blf_translation.c
+++ b/source/blender/blenfont/intern/blf_translation.c
@@ -29,9 +29,19 @@
*/
#include <stdlib.h>
+#include <string.h>
#ifdef WITH_INTERNATIONAL
#include <libintl.h>
+#include <locale.h>
+
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* needed for windows version of gettext */
+#ifndef LC_MESSAGES
+# define LC_MESSAGES 1729
+#endif
+
#endif
#include "MEM_guardedalloc.h"
@@ -91,6 +101,40 @@ const char* BLF_gettext(const char *msgid)
#endif
}
+const char *BLF_pgettext(const char *context, const char *message)
+{
+#ifdef WITH_INTERNATIONAL
+ char static_msg_ctxt_id[1024];
+ char *dynamic_msg_ctxt_id = NULL;
+ char *msg_ctxt_id;
+ const char *translation;
+
+ size_t overall_length = strlen(context) + strlen(message) + sizeof(GETTEXT_CONTEXT_GLUE) + 1;
+
+ if (overall_length > sizeof(static_msg_ctxt_id)) {
+ dynamic_msg_ctxt_id = malloc(overall_length);
+ msg_ctxt_id = dynamic_msg_ctxt_id;
+ }
+ else {
+ msg_ctxt_id = static_msg_ctxt_id;
+ }
+
+ sprintf(msg_ctxt_id, "%s%s%s", context, GETTEXT_CONTEXT_GLUE, message);
+
+ translation = (char*)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES);
+
+ if (dynamic_msg_ctxt_id)
+ free(dynamic_msg_ctxt_id);
+
+ if (translation == msg_ctxt_id)
+ translation = message;
+
+ return translation;
+#else
+ return message;
+#endif
+}
+
int BLF_translate_iface(void)
{
#ifdef WITH_INTERNATIONAL
@@ -132,4 +176,3 @@ const char *BLF_translate_do_tooltip(const char *msgid)
return msgid;
#endif
}
-