|
Blender V4.5
|
#include <Python.h>#include <structmember.h>#include "../generic/python_compat.hh"#include "BLI_utildefines.h"#include "BPY_extern.hh"#include "bpy_app_translations.hh"#include "MEM_guardedalloc.h"#include "BLT_lang.hh"#include "BLT_translation.hh"#include "RNA_types.hh"Go to the source code of this file.
Classes | |
| struct | BlenderAppTranslations |
Macros | |
| #define | SetObjString(item) |
| #define | SetObjNone() |
Functions | |
Helpers for hash | |
| PyDoc_STRVAR (app_translations_py_messages_register_doc, ".. method:: register(module_name, translations_dict)\n" "\n" " Registers an addon's UI translations.\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support.\n" "\n" " :arg module_name: The name identifying the addon.\n" " :type module_name: str\n" " :arg translations_dict: A dictionary built like that:\n" " ``{locale: {msg_key: msg_translation, ...}, ...}``\n" " :type translations_dict: dict[str, dict[str, str]]\n" "\n") | |
| static PyObject * | app_translations_py_messages_register (BlenderAppTranslations *self, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_py_messages_unregister_doc, ".. method:: unregister(module_name)\n" "\n" " Unregisters an addon's UI translations.\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support.\n" "\n" " :arg module_name: The name identifying the addon.\n" " :type module_name: str\n" "\n") | |
| static PyObject * | app_translations_py_messages_unregister (BlenderAppTranslations *self, PyObject *args, PyObject *kw) |
Variables | |
Local Struct to Store Translation | |
| static BlenderAppTranslations * | _translations = nullptr |
C-defined Contexts | |
| static PyTypeObject | BlenderAppTranslationsContextsType |
| static BLT_i18n_contexts_descriptor | _contexts [] = BLT_I18NCONTEXTS_DESC |
| static PyStructSequence_Field | app_translations_contexts_fields [ARRAY_SIZE(_contexts)] |
| static PyStructSequence_Desc | app_translations_contexts_desc |
| static PyObject * | app_translations_contexts_make () |
Main #BlenderAppTranslations #PyObject Definition | |
| static PyMemberDef | app_translations_members [] |
| static PyGetSetDef | app_translations_getseters [] |
| static PyMethodDef | app_translations_methods [] |
| static PyTypeObject | BlenderAppTranslationsType |
| PyDoc_STRVAR (app_translations_contexts_doc, "A named tuple containing all predefined translation contexts.\n" "\n" ".. warning::\n" " Never use a (new) context starting with \"" BLT_I18NCONTEXT_DEFAULT_BPYRNA "\", it would be internally\n" " assimilated as the default one!\n") | |
| PyDoc_STRVAR (app_translations_contexts_C_to_py_doc, "A readonly dict mapping contexts' C-identifiers to their py-identifiers.") | |
| PyDoc_STRVAR (app_translations_locale_doc, "The actual locale currently in use (will always return a void string when Blender " "is built without " "internationalization support).") | |
| static PyObject * | app_translations_locale_get (PyObject *, void *) |
| PyDoc_STRVAR (app_translations_locales_doc, "All locales currently known by Blender (i.e. available as translations).") | |
| static PyObject * | app_translations_locales_get (PyObject *, void *) |
| static PyObject * | _py_pgettext (PyObject *args, PyObject *kw, const char *(*_pgettext)(const char *, const char *)) |
| PyDoc_STRVAR (app_translations_pgettext_doc, ".. method:: pgettext(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt).\n" "\n" " .. note::\n" " The ``(msgid, msgctxt)`` parameters order has been switched compared to gettext " "function, to allow\n" " single-parameter calls (context then defaults to BLT_I18NCONTEXT_DEFAULT).\n" "\n" " .. note::\n" " You should really rarely need to use this function in regular addon code, as all " "translation should be\n" " handled by Blender internal code. The only exception are string containing formatting " "(like \"File: %r\"),\n" " but you should rather use :func:`pgettext_iface`/:func:`pgettext_tip` in those cases!\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support (hence always " "returns ``msgid``).\n" "\n" " :arg msgid: The string to translate.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n") | |
| static PyObject * | app_translations_pgettext (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_pgettext_n_doc, ".. method:: pgettext_n(msgid, msgctxt=None)\n" "\n" " Extract the given msgid to translation files. This is a no-op function that will " "only mark the string to extract, but not perform the actual translation.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid: The string to extract.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The original string.\n" "\n") | |
| static PyObject * | app_translations_pgettext_n (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_pgettext_iface_doc, ".. method:: pgettext_iface(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt), if labels' translation " "is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid: The string to translate.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n") | |
| static PyObject * | app_translations_pgettext_iface (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_pgettext_tip_doc, ".. method:: pgettext_tip(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt), if tooltips' " "translation is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid: The string to translate.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n") | |
| static PyObject * | app_translations_pgettext_tip (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_pgettext_rpt_doc, ".. method:: pgettext_rpt(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt), if reports' translation " "is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid: The string to translate.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The translated string (or msgid if no translation was found).\n" "\n") | |
| static PyObject * | app_translations_pgettext_rpt (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_pgettext_data_doc, ".. method:: pgettext_data(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt), if new data name's " "translation is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid: The string to translate.\n" " :type msgid: str\n" " :arg msgctxt: The translation context (defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt: str | None\n" " :return: The translated string (or ``msgid`` if no translation was found).\n" "\n") | |
| static PyObject * | app_translations_pgettext_data (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| PyDoc_STRVAR (app_translations_locale_explode_doc, ".. method:: locale_explode(locale)\n" "\n" " Return all components and their combinations of the given ISO locale string.\n" "\n" " >>> bpy.app.translations.locale_explode(\"sr_RS@latin\")\n" " (\"sr\", \"RS\", \"latin\", \"sr_RS\", \"sr@latin\")\n" "\n" " For non-complete locales, missing elements will be None.\n" "\n" " :arg locale: The ISO locale string to explode.\n" " :type msgid: str\n" " :return: A tuple ``(language, country, variant, language_country, language@variant)``.\n" "\n") | |
| static PyObject * | app_translations_locale_explode (BlenderAppTranslations *, PyObject *args, PyObject *kw) |
| static PyObject * | app_translations_new (PyTypeObject *type, PyObject *args, PyObject *kw) |
| static void | app_translations_free (void *self_v) |
| PyDoc_STRVAR (app_translations_doc, "This object contains some data/methods regarding internationalization in Blender, " "and allows every py script\n" "to feature translations for its own UI messages.\n" "\n") | |
| PyObject * | BPY_app_translations_struct () |
| void | BPY_app_translations_end () |
This file defines a singleton py object accessed via 'bpy.app.translations', which exposes various data and functions useful in i18n work. Most notably, it allows to extend main translations with Python dictionaries.
Definition in file bpy_app_translations.cc.
| #define SetObjNone | ( | ) |
Referenced by app_translations_contexts_make().
| #define SetObjString | ( | item | ) |
Referenced by app_translations_contexts_make().
|
static |
Definition at line 553 of file bpy_app_translations.cc.
References _py_pgettext(), and BLT_I18NCONTEXT_DEFAULT.
Referenced by _py_pgettext(), app_translations_pgettext(), app_translations_pgettext_data(), app_translations_pgettext_iface(), app_translations_pgettext_rpt(), and app_translations_pgettext_tip().
|
static |
Definition at line 432 of file bpy_app_translations.cc.
References _contexts, app_translations_contexts_make(), BlenderAppTranslationsContextsType, BLT_i18n_contexts_descriptor::c_id, SetObjNone, SetObjString, and BLT_i18n_contexts_descriptor::value.
Referenced by app_translations_contexts_make(), and app_translations_new().
|
static |
Definition at line 884 of file bpy_app_translations.cc.
References app_translations_free(), BlenderAppTranslations::contexts, BlenderAppTranslations::contexts_C_to_py, and BlenderAppTranslations::py_messages.
Referenced by app_translations_free().
|
static |
Definition at line 763 of file bpy_app_translations.cc.
References app_translations_locale_explode(), BLT_lang_locale_explode(), and MEM_SAFE_FREE.
Referenced by app_translations_locale_explode().
|
static |
Definition at line 503 of file bpy_app_translations.cc.
References app_translations_locale_get(), and BLT_lang_get().
Referenced by app_translations_locale_get().
|
static |
Definition at line 513 of file bpy_app_translations.cc.
References app_translations_locales_get(), BLT_lang_RNA_enum_properties(), EnumPropertyItem::identifier, ret, and EnumPropertyItem::value.
Referenced by app_translations_locales_get().
|
static |
Definition at line 852 of file bpy_app_translations.cc.
References _contexts, _translations, app_translations_contexts_make(), app_translations_new(), ARRAY_SIZE, BLI_assert, BLT_i18n_contexts_descriptor::c_id, BlenderAppTranslations::contexts, BlenderAppTranslations::contexts_C_to_py, BLT_i18n_contexts_descriptor::py_id, BlenderAppTranslations::py_messages, and UNUSED_VARS_NDEBUG.
Referenced by app_translations_new().
|
static |
Definition at line 612 of file bpy_app_translations.cc.
References _py_pgettext(), app_translations_pgettext(), and BLT_pgettext().
Referenced by app_translations_pgettext().
|
static |
Definition at line 740 of file bpy_app_translations.cc.
References _py_pgettext(), app_translations_pgettext_data(), and BLT_translate_do_new_dataname().
Referenced by app_translations_pgettext_data().
|
static |
Definition at line 668 of file bpy_app_translations.cc.
References _py_pgettext(), app_translations_pgettext_iface(), and BLT_translate_do_iface().
Referenced by app_translations_pgettext_iface().
|
static |
Definition at line 634 of file bpy_app_translations.cc.
References app_translations_pgettext_n().
Referenced by app_translations_pgettext_n().
|
static |
Definition at line 716 of file bpy_app_translations.cc.
References _py_pgettext(), app_translations_pgettext_rpt(), and BLT_translate_do_report().
Referenced by app_translations_pgettext_rpt().
|
static |
Definition at line 692 of file bpy_app_translations.cc.
References _py_pgettext(), app_translations_pgettext_tip(), and BLT_translate_do_tooltip().
Referenced by app_translations_pgettext_tip().
|
static |
Definition at line 318 of file bpy_app_translations.cc.
References app_translations_py_messages_register(), and BlenderAppTranslations::py_messages.
Referenced by app_translations_py_messages_register().
|
static |
Definition at line 374 of file bpy_app_translations.cc.
References app_translations_py_messages_unregister(), and BlenderAppTranslations::py_messages.
Referenced by app_translations_py_messages_unregister().
| void BPY_app_translations_end | ( | ) |
Definition at line 993 of file bpy_app_translations.cc.
References BPY_app_translations_end().
Referenced by BPY_app_translations_end(), and BPY_python_end().
| PyObject * BPY_app_translations_struct | ( | ) |
Definition at line 957 of file bpy_app_translations.cc.
References _contexts, app_translations_contexts_desc, BlenderAppTranslationsContextsType, BlenderAppTranslationsType, BPY_app_translations_struct(), BLT_i18n_contexts_descriptor::c_id, Py_HashPointer, BLT_i18n_contexts_descriptor::py_id, and ret.
Referenced by BPY_app_translations_struct(), and make_app_info().
| PyDoc_STRVAR | ( | app_translations_contexts_C_to_py_doc | , |
| "A readonly dict mapping contexts' C-identifiers to their py-identifiers." | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_contexts_doc | , |
| "A named tuple containing all predefined translation contexts.\n" "\n" ".. warning::\n" " Never use a (new) context starting with \"" BLT_I18NCONTEXT_DEFAULT_BPYRNA "\" | , | ||
| it would be internally\n" " assimilated as the default one!\n" | ) |
References BLT_I18NCONTEXT_DEFAULT_BPYRNA, and PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_doc | , |
| "This object contains some data/methods regarding internationalization in | Blender, | ||
| " "and allows every py script\n" "to feature translations for its own UI messages.\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_locale_doc | , |
| "The actual locale currently in use (will always return a void string when Blender " "is built without " "internationalization support)." | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_locale_explode_doc | , |
| ".. method:: locale_explode(locale)\n" "\n" " Return all components and their combinations of the given ISO locale string.\n" "\n" " >> | , | ||
| bpy.app.translations.locale_explode(\"sr_RS@latin\")\n" " (\"sr\", \"RS\", \"latin\", \"sr_RS\", \"sr@latin\")\n" "\n" " For non-complete | locales, | ||
| missing elements will be None.\n" "\n" " :arg locale:The ISO locale string to explode.\n" " :type msgid:str\n" " :return:A tuple ``(language, country, variant, language_country, language @variant)``.\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_locales_doc | , |
| "All locales currently known by Blender (i.e. available as translations)." | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_data_doc | , |
| ".. method:: | pgettext_datamsgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt, | ||
| if new data name 's " "translation is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid:The string to translate.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The translated string(or ``msgid`` if no translation was found).\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_doc | , |
| ".. method:: pgettext(msgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt).\n" "\n" " .. note::\n" " The ``(msgid, msgctxt)`` parameters order has been switched compared to gettext " " | function, | ||
| to allow\n" " single-parameter calls(context then defaults to BLT_I18NCONTEXT_DEFAULT).\n" "\n" " .. note::\n" " You should really rarely need to use this function in regular addon | code, | ||
| as all " "translation should be\n" " handled by Blender internal code. The only exception are string containing formatting " " | like \"File: %r\", | ||
| \n" " but you should rather use :func:`pgettext_iface`/:func:`pgettext_tip` in those cases!\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support(hence always " "returns ``msgid``).\n" "\n" " :arg msgid:The string to translate.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The translated string(or msgid if no translation was found).\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_iface_doc | , |
| ".. method:: | pgettext_ifacemsgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt, | ||
| if labels' translation " "is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid:The string to translate.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The translated string(or msgid if no translation was found).\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_n_doc | , |
| ".. method:: pgettext_n(msgid, msgctxt=None)\n" "\n" " Extract the given msgid to translation files. This is a no-op function that will " "only mark the string to | extract, | ||
| but not perform the actual translation.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid:The string to extract.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The original string.\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_rpt_doc | , |
| ".. method:: | pgettext_rptmsgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt, | ||
| if reports' translation " "is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid:The string to translate.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The translated string(or msgid if no translation was found).\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_pgettext_tip_doc | , |
| ".. method:: | pgettext_tipmsgid, msgctxt=None)\n" "\n" " Try to translate the given msgid (with optional msgctxt, | ||
| if tooltips' " "translation is enabled.\n" "\n" " .. note::\n" " See :func:`pgettext` notes.\n" "\n" " :arg msgid:The string to translate.\n" " :type msgid:str\n" " :arg msgctxt:The translation context(defaults to BLT_I18NCONTEXT_DEFAULT).\n" " :type msgctxt:str|None\n" " :return:The translated string(or msgid if no translation was found).\n" "\n" | ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_py_messages_register_doc | , |
| ".. method:: register(module_name, translations_dict)\n" "\n" " Registers an addon's UI translations.\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support.\n" "\n" " :arg module_name: The name identifying the addon.\n" " :type module_name: str\n" " :arg translations_dict: A dictionary built like that:\n" " ``{locale: {msg_key: msg_translation, ...}, ...}``\n" " :type translations_dict: dict]\n" "\n" | [str, dict[str, str] ) |
References PyDoc_STRVAR().
| PyDoc_STRVAR | ( | app_translations_py_messages_unregister_doc | , |
| ".. method:: unregister(module_name)\n" "\n" " Unregisters an addon's UI translations.\n" "\n" " .. note::\n" " Does nothing when Blender is built without internationalization support.\n" "\n" " :arg module_name: The name identifying the addon.\n" " :type module_name: str\n" "\n" | ) |
References PyDoc_STRVAR().
|
static |
Definition at line 417 of file bpy_app_translations.cc.
Referenced by app_translations_contexts_make(), app_translations_new(), and BPY_app_translations_struct().
|
static |
Definition at line 63 of file bpy_app_translations.cc.
Referenced by app_translations_new().
|
static |
Definition at line 425 of file bpy_app_translations.cc.
Referenced by BPY_app_translations_struct().
|
static |
Definition at line 422 of file bpy_app_translations.cc.
|
static |
Definition at line 541 of file bpy_app_translations.cc.
|
static |
Definition at line 483 of file bpy_app_translations.cc.
|
static |
Definition at line 803 of file bpy_app_translations.cc.
|
static |
Definition at line 415 of file bpy_app_translations.cc.
Referenced by app_translations_contexts_make(), and BPY_app_translations_struct().
|
static |
Definition at line 905 of file bpy_app_translations.cc.
Referenced by BPY_app_translations_struct().