diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-20 22:42:09 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-03-20 22:42:09 +0400 |
commit | 885441e75804a92d4c2270fd006f3e71fc460d7b (patch) | |
tree | 7d3e89d07af080a2146eb747ff9da6ecd9d0e7f9 /source/blender/python | |
parent | e9b0b402cc85533c8b247b174f17f41b1892ef04 (diff) |
I18n users request: add the ability to use a translated name for newly added/created objects or other datablocks.
This simply adds a third "translation type" (in addition to iface and tip), "new data", with relevant user settings flag and helper funcs/macros (and py api).
Currently implemented name translation when adding new objects, as well as modifiers and constraints, will add the others (cd layers, scenes, perhaps nodes [though I think they do not need this], etc.) later.
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_app_translations.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 83e9d850ba0..a1751d9717c 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -570,7 +570,7 @@ static PyObject *app_translations_pgettext_iface(BlenderAppTranslations *UNUSED( } PyDoc_STRVAR(app_translations_pgettext_tip_doc, -".. method:: pgettext(msgid, msgctxt)\n" +".. method:: pgettext_tip(msgid, msgctxt)\n" "\n" " Try to translate the given msgid (with optional msgctxt), if tooltips' translation is enabled.\n" " NOTE: See pgettext notes.\n" @@ -588,6 +588,25 @@ static PyObject *app_translations_pgettext_tip(BlenderAppTranslations *UNUSED(se return _py_pgettext(args, kw, BLF_translate_do_tooltip); } +PyDoc_STRVAR(app_translations_pgettext_data_doc, +".. method:: pgettext_data(msgid, msgctxt)\n" +"\n" +" Try to translate the given msgid (with optional msgctxt), if new data name's translation is enabled.\n" +" NOTE: See pgettext notes.\n" +"\n" +" :arg msgid: The string to translate.\n" +" :type msgid: string\n" +" :arg msgctxt: The translation context.\n" +" :type msgctxt: string or None\n" +" :default msgctxt: BLF_I18NCONTEXT_DEFAULT value.\n" +" :return: The translated string (or msgid if no translation was found).\n" +"\n" +); +static PyObject *app_translations_pgettext_data(BlenderAppTranslations *UNUSED(self), PyObject *args, PyObject *kw) +{ + return _py_pgettext(args, kw, BLF_translate_do_new_dataname); +} + PyDoc_STRVAR(app_translations_locale_explode_doc, ".. method:: locale_explode(locale)\n" "\n" @@ -620,18 +639,20 @@ static PyObject *app_translations_locale_explode(BlenderAppTranslations *UNUSED( PyMethodDef app_translations_methods[] = { /* Can't use METH_KEYWORDS alone, see http://bugs.python.org/issue11587 */ - {(char *)"register", (PyCFunction)app_translations_py_messages_register, METH_VARARGS | METH_KEYWORDS, - app_translations_py_messages_register_doc}, - {(char *)"unregister", (PyCFunction)app_translations_py_messages_unregister, METH_VARARGS | METH_KEYWORDS, - app_translations_py_messages_unregister_doc}, - {(char *)"pgettext", (PyCFunction)app_translations_pgettext, METH_VARARGS | METH_KEYWORDS | METH_STATIC, - app_translations_pgettext_doc}, - {(char *)"pgettext_iface", (PyCFunction)app_translations_pgettext_iface, METH_VARARGS | METH_KEYWORDS | METH_STATIC, - app_translations_pgettext_iface_doc}, - {(char *)"pgettext_tip", (PyCFunction)app_translations_pgettext_tip, METH_VARARGS | METH_KEYWORDS | METH_STATIC, - app_translations_pgettext_tip_doc}, - {(char *)"locale_explode", (PyCFunction)app_translations_locale_explode, METH_VARARGS | METH_KEYWORDS | METH_STATIC, - app_translations_locale_explode_doc}, + {"register", (PyCFunction)app_translations_py_messages_register, METH_VARARGS | METH_KEYWORDS, + app_translations_py_messages_register_doc}, + {"unregister", (PyCFunction)app_translations_py_messages_unregister, METH_VARARGS | METH_KEYWORDS, + app_translations_py_messages_unregister_doc}, + {"pgettext", (PyCFunction)app_translations_pgettext, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_doc}, + {"pgettext_iface", (PyCFunction)app_translations_pgettext_iface, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_iface_doc}, + {"pgettext_tip", (PyCFunction)app_translations_pgettext_tip, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_tip_doc}, + {"pgettext_data", (PyCFunction)app_translations_pgettext_data, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_pgettext_data_doc}, + {"locale_explode", (PyCFunction)app_translations_locale_explode, METH_VARARGS | METH_KEYWORDS | METH_STATIC, + app_translations_locale_explode_doc}, {NULL} }; @@ -697,7 +718,7 @@ PyDoc_STRVAR(app_translations_doc, static PyTypeObject BlenderAppTranslationsType = { PyVarObject_HEAD_INIT(NULL, 0) /* tp_name */ - (char *)"bpy.app._translations_type", + "bpy.app._translations_type", /* tp_basicsize */ sizeof(BlenderAppTranslations), 0, /* tp_itemsize */ |