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-20 21:29:07 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2013-01-20 21:29:07 +0400
commitcef730d969b35d7cc25006acded05c361602b319 (patch)
tree7b2b5f2412aac91cb9247866992cc8ae935cd241 /source/blender/python/intern/bpy_app_translations.h
parent08bcbafe36e28330f98d9143fe4743e69f6d6289 (diff)
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.
Diffstat (limited to 'source/blender/python/intern/bpy_app_translations.h')
-rw-r--r--source/blender/python/intern/bpy_app_translations.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_app_translations.h b/source/blender/python/intern/bpy_app_translations.h
new file mode 100644
index 00000000000..704307574d0
--- /dev/null
+++ b/source/blender/python/intern/bpy_app_translations.h
@@ -0,0 +1,32 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Bastien Montagne
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/python/intern/bpy_app_translations.h
+ * \ingroup pythonintern
+ */
+
+#ifndef __BPY_APP_TRANSLATIONS_H__
+#define __BPY_APP_TRANSLATIONS_H__
+
+PyObject *BPY_app_translations_struct(void);
+
+#endif /* __BPY_APP_TRANSLATIONS_H__ */