Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3854)

Issue 7102054: Blender i18n enhancements (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 3 months ago by b.mont29
Modified:
11 years, 1 month ago
Reviewers:
brechtvl, ideasman42, bf-codereview
Base URL:
https://svn.blender.org/svnroot/bf-blender/trunk/blender/
Visibility:
Public.

Description

This adds three new features: * The ability to specify contexts in string property that are marked as PROP_PY_TRANSLATE, i.e. that are stored translated in RNA properties (used only by UI api funcs currently), using a simple 'context::message' format. Also done some cleanup in this area. * A new bpy.app.i18n 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. 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, if enabled, 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 as well!

Patch Set 1 #

Total comments: 7

Patch Set 2 : Updated patch. #

Patch Set 3 : Updated, removed the "context in text string" feature #

Total comments: 18
Unified diffs Side-by-side diffs Delta from patch set Stats (+879 lines, -47 lines) Patch
intern/locale/boost_locale_wrapper.h View 1 2 1 chunk +2 lines, -1 line 0 comments Download
intern/locale/boost_locale_wrapper.cpp View 1 2 6 chunks +25 lines, -5 lines 0 comments Download
release/scripts/startup/bl_ui/space_userpref.py View 1 2 1 chunk +1 line, -0 lines 0 comments Download
source/blender/blenfont/BLF_translation.h View 1 2 2 chunks +58 lines, -1 line 0 comments Download
source/blender/blenfont/CMakeLists.txt View 1 2 1 chunk +1 line, -0 lines 0 comments Download
source/blender/blenfont/SConscript View 1 2 1 chunk +1 line, -1 line 0 comments Download
source/blender/blenfont/intern/blf_lang.c View 1 2 5 chunks +67 lines, -4 lines 0 comments Download
source/blender/blenfont/intern/blf_translation.c View 1 2 2 chunks +11 lines, -1 line 0 comments Download
source/blender/makesdna/DNA_userdef_types.h View 1 2 1 chunk +5 lines, -4 lines 0 comments Download
source/blender/makesrna/RNA_types.h View 1 2 1 chunk +3 lines, -4 lines 0 comments Download
source/blender/makesrna/intern/makesrna.c View 1 2 1 chunk +1 line, -1 line 0 comments Download
source/blender/makesrna/intern/rna_define.c View 1 2 1 chunk +1 line, -1 line 0 comments Download
source/blender/makesrna/intern/rna_rna.c View 1 2 2 chunks +7 lines, -1 line 2 comments Download
source/blender/makesrna/intern/rna_ui.c View 1 2 2 chunks +0 lines, -6 lines 0 comments Download
source/blender/makesrna/intern/rna_userdef.c View 1 2 1 chunk +6 lines, -0 lines 2 comments Download
source/blender/makesrna/intern/rna_wm.c View 1 2 2 chunks +0 lines, -6 lines 0 comments Download
source/blender/python/BPY_extern.h View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
source/blender/python/intern/CMakeLists.txt View 1 2 2 chunks +2 lines, -0 lines 0 comments Download
source/blender/python/intern/bpy_app.c View 1 2 3 chunks +11 lines, -1 line 2 comments Download
source/blender/python/intern/bpy_app_build_options.c View 1 2 2 chunks +2 lines, -2 lines 0 comments Download
source/blender/python/intern/bpy_app_i18n.h View 1 chunk +32 lines, -0 lines 0 comments Download
source/blender/python/intern/bpy_app_i18n.c View 1 2 1 chunk +625 lines, -0 lines 12 comments Download
source/blender/python/intern/bpy_props.c View 1 2 1 chunk +7 lines, -2 lines 0 comments Download
source/blender/python/intern/bpy_rna.c View 1 2 1 chunk +6 lines, -6 lines 0 comments Download

Messages

Total messages: 8
mont29
11 years, 3 months ago (2013-01-13 10:20:57 UTC) #1
ideasman42
While I like that scripts could make translations Im hesitant to accept this functionality as ...
11 years, 3 months ago (2013-01-14 17:35:28 UTC) #2
mont29
Updated patch.
11 years, 3 months ago (2013-01-14 21:17:04 UTC) #3
mont29
On 2013/01/14 21:17:04, mont29 wrote: > Updated patch. Addressed all issues from previous review (i.e. ...
11 years, 3 months ago (2013-01-14 21:21:20 UTC) #4
mont29
Updated, removed the "context in text string" feature
11 years, 3 months ago (2013-01-15 14:11:41 UTC) #5
ideasman42
LGTM - noted some minor issues. https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/bpy_app.c File source/blender/python/intern/bpy_app.c (right): https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/bpy_app.c#newcode94 source/blender/python/intern/bpy_app.c:94: {(char *)"i18n", (char ...
11 years, 3 months ago (2013-01-20 15:03:46 UTC) #6
brechtvl
Added two comments about RNA part. https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern/rna_rna.c File source/blender/makesrna/intern/rna_rna.c (right): https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern/rna_rna.c#newcode59 source/blender/makesrna/intern/rna_rna.c:59: {PROP_PY_TRANSLATE, "TRANSLATE", 0, ...
11 years, 3 months ago (2013-01-20 15:26:31 UTC) #7
mont29
11 years, 3 months ago (2013-01-20 17:34:49 UTC) #8
Applied suggested changes and committed. Thanks both of you for the reviews :)

https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern...
File source/blender/makesrna/intern/rna_rna.c (right):

https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern...
source/blender/makesrna/intern/rna_rna.c:59: {PROP_PY_TRANSLATE, "TRANSLATE", 0,
"Translate",
On 2013/01/20 15:26:31, brechtvl wrote:
> I don't think this should be a subtype but a flag instead? That way it doesn't
> get unnecessarily exposed to python, and it can work even if we ever add
useful
> string subtypes here.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern...
File source/blender/makesrna/intern/rna_userdef.c (right):

https://codereview.appspot.com/7102054/diff/31/source/blender/makesrna/intern...
source/blender/makesrna/intern/rna_userdef.c:3317: prop = RNA_def_property(srna,
"dpi", PROP_INT, PROP_NONE);
On 2013/01/20 15:26:31, brechtvl wrote:
> I don't think this should be an option, just enable it always, don't think
> addons should work different than builtin code here.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
File source/blender/python/intern/bpy_app.c (right):

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app.c:94: {(char *)"i18n", (char *)"Application
and addons internationalization API"},
On 2013/01/20 15:03:46, ideasman42 wrote:
> picky but perhaps 
> 'bpy.app.translations'
> is nicer?

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
File source/blender/python/intern/bpy_app_i18n.c (right):

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:179: if (!PyArg_ParseTuple(pykey,
"ss", &msgctxt, &msgid)) {
On 2013/01/20 15:03:46, ideasman42 wrote:
> In this case I'd suggest to manually get each string from the tuple ...
> PyTuple_GETITEM, str = _PyUnicode_AsString() for each.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:255: "   :return: None.\n"
On 2013/01/20 15:03:46, ideasman42 wrote:
> you can just leave this out.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:266: Py_RETURN_NONE;
On 2013/01/20 15:03:46, ideasman42 wrote:
> Shouldn't this return NULL? (which would raise a python exception)

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:273: Py_RETURN_NONE;
On 2013/01/20 15:03:46, ideasman42 wrote:
> same as above.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:292: "   :return: None.\n"
On 2013/01/20 15:03:46, ideasman42 wrote:
> you can just leave this out.

Done.

https://codereview.appspot.com/7102054/diff/31/source/blender/python/intern/b...
source/blender/python/intern/bpy_app_i18n.c:303: Py_RETURN_NONE;
On 2013/01/20 15:03:46, ideasman42 wrote:
> again, return NULL for error cases

Done.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b