From cef730d969b35d7cc25006acded05c361602b319 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 20 Jan 2013 17:29:07 +0000 Subject: Python i18n API. Many thanks to Campbell and Brecht for the reviews and suggestions! This commit adds: * A new bpy.app.translations module giving some info about locales/translation stuff (current active locale, all locales currently known by blender, all translation contexts currently defined, etc.). * The ability for addons to feature translations, using the (un)register functions of above module. * Also cleans up "translate py string when storing into RNA prop" by removing "PROP_TRANSLATE" string's subtype, and adding a PROP_STRING_PY_TRANSLATE flag instead (this way it is no more exposed to python...). Addon translations work with py dictionaries: each addon features a dict {lang: {(context, message): translation, ...}, ...}, which is registered when the addon is enabled (and unregistered when disabled). Then, when a key (context, message) is not found in regular mo catalog, a cache dict for current locale is built from all registered addon translations, and key is searched in it. Note: currently addons writers have to do all the work by hand, will add something (probably extend "edit translation" addon) to automate messages extraction from addons soon(ish)! To get a look to expected behavior from addons, have a look at render_copy_settings/__init__.py and render_copy_settings/translations.py (rather stupid example currently, but...). Once we have a complete process, I'll also update relevant wiki pages. --- intern/locale/boost_locale_wrapper.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'intern/locale/boost_locale_wrapper.h') diff --git a/intern/locale/boost_locale_wrapper.h b/intern/locale/boost_locale_wrapper.h index e7956d216f1..4e3a1f848d2 100644 --- a/intern/locale/boost_locale_wrapper.h +++ b/intern/locale/boost_locale_wrapper.h @@ -40,7 +40,8 @@ extern "C" { void bl_locale_init(const char *messages_path, const char *default_domain); void bl_locale_set(const char *locale); -const char* bl_locale_pgettext(const char *msgctxt, const char *msgid); +const char *bl_locale_get(void); +const char *bl_locale_pgettext(const char *msgctxt, const char *msgid); #ifdef __cplusplus } -- cgit v1.2.3