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.
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user