Blender Git Loki

Git Commits -> Revision cef730d

Revision cef730d by Bastien Montagne (master)
January 20, 2013, 17:29 (GMT)
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.

Commit Details:

Full Hash: cef730d969b35d7cc25006acded05c361602b319
SVN Revision: 53930
Parent Commit: 08bcbaf
Lines Changed: +890, -50

2 Added Paths:

/source/blender/python/intern/bpy_app_translations.c (+638, -0) (View)
/source/blender/python/intern/bpy_app_translations.h (+32, -0) (View)

21 Modified Paths:

/intern/locale/boost_locale_wrapper.cpp (+25, -5) (Diff)
/intern/locale/boost_locale_wrapper.h (+2, -1) (Diff)
/source/blender/blenfont/BLF_translation.h (+58, -1) (Diff)
/source/blender/blenfont/CMakeLists.txt (+1, -0) (Diff)
/source/blender/blenfont/intern/blf_lang.c (+67, -4) (Diff)
/source/blender/blenfont/intern/blf_translation.c (+11, -1) (Diff)
/source/blender/blenfont/SConscript (+1, -1) (Diff)
/source/blender/makesrna/intern/makesrna.c (+0, -1) (Diff)
/source/blender/makesrna/intern/rna_define.c (+4, -3) (Diff)
/source/blender/makesrna/intern/rna_rna.c (+4, -1) (Diff)
/source/blender/makesrna/intern/rna_ui.c (+0, -6) (Diff)
/source/blender/makesrna/intern/rna_ui_api.c (+3, -3) (Diff)
/source/blender/makesrna/intern/rna_wm.c (+0, -6) (Diff)
/source/blender/makesrna/RNA_define.h (+1, -1) (Diff)
/source/blender/makesrna/RNA_types.h (+9, -4) (Diff)
/source/blender/python/BPY_extern.h (+5, -0) (Diff)
/source/blender/python/intern/bpy_app.c (+11, -1) (Diff)
/source/blender/python/intern/bpy_app_build_options.c (+2, -2) (Diff)
/source/blender/python/intern/bpy_props.c (+4, -2) (Diff)
/source/blender/python/intern/bpy_rna.c (+10, -7) (Diff)
/source/blender/python/intern/CMakeLists.txt (+2, -0) (Diff)
Tehnyt: Miika HämäläinenViimeksi päivitetty: 07.11.2014 14:18MiikaH:n Sivut a.k.a. MiikaHweb | 2003-2021