Improved Internationalization and Localization

==============================================

Commiting GSoC project by Xiangquan Xiao trunk.

Applied as separated patch, because svn merge produces to much false
conflicts and worked really slow.

Details for usage would be published on code.blender.org soon.

Thanks to Xiao for implementation of project, Campbell to code review,
Dalai and Gez for pointing to nice font and everybody else who took
part in improving i18n support.
This commit is contained in:
2011-09-20 13:41:43 +00:00
114 changed files with 8818 additions and 2418 deletions

View File

@@ -17,6 +17,9 @@ defs = []
if is_debug:
defs.append('_DEBUG')
if env['WITH_BF_INTERNATIONAL']:
defs.append('INTERNATIONAL')
sources = env.Glob('generic/*.c')
env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [363,165]) # ketsji is 360

View File

@@ -48,5 +48,8 @@ set(SRC
py_capi_utils.h
)
if(WITH_INTERNATIONAL)
add_definitions(-DINTERNATIONAL)
endif()
blender_add_lib(bf_python_ext "${SRC}" "${INC}" "${INC_SYS}")

View File

@@ -31,9 +31,13 @@
#include "blf_py_api.h"
#include "../../blenfont/BLF_api.h"
#include "../../blenfont/BLF_translation.h"
#include "BLI_utildefines.h"
#ifdef INTERNATIONAL
#include "DNA_userdef_types.h" /* is it bad level? */
#endif
PyDoc_STRVAR(py_blf_position_doc,
@@ -367,6 +371,34 @@ static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
return PyLong_FromLong(BLF_load(filename));
}
#ifdef INTERNATIONAL
PyDoc_STRVAR(py_blf_gettext_doc,
".. function:: gettext(msgid)\n"
"\n"
" Get a msg in local language.\n"
"\n"
" :arg msgid: the source string.\n"
" :type msgid: string\n"
" :return: the localized string.\n"
" :rtype: string\n"
);
static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
{
if ((U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE)) {
const char *msgid= _PyUnicode_AsString(value);
if(msgid == NULL) {
PyErr_SetString(PyExc_TypeError, "blf.gettext expects a single string argument");
return NULL;
}
return PyUnicode_FromString(BLF_gettext(msgid));
}
else {
return Py_INCREF(value), value;
}
}
#endif /* INTERNATIONAL */
/*----------------------------MODULE INIT-------------------------*/
static PyMethodDef BLF_methods[] = {
{"aspect", (PyCFunction) py_blf_aspect, METH_VARARGS, py_blf_aspect_doc},
@@ -382,6 +414,9 @@ static PyMethodDef BLF_methods[] = {
{"shadow_offset", (PyCFunction) py_blf_shadow_offset, METH_VARARGS, py_blf_shadow_offset_doc},
{"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc},
{"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc},
#ifdef INTERNATIONAL
{"gettext", (PyCFunction) py_blf_gettext, METH_O, py_blf_gettext_doc},
#endif
{NULL, NULL, 0, NULL}
};