modify the python gettext function to pass through the original string when no translation is done, this means the cached info such as byte representation and hash will be kept.
This commit is contained in:
@@ -289,8 +289,10 @@ void free_ttfont(void)
|
|||||||
}
|
}
|
||||||
BLI_freelistN(&ttfdata);
|
BLI_freelistN(&ttfdata);
|
||||||
|
|
||||||
|
#ifdef INTERNATIONAL
|
||||||
if(unifont_ttf)
|
if(unifont_ttf)
|
||||||
MEM_freeN(unifont_ttf);
|
MEM_freeN(unifont_ttf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TmpFont *vfont_find_tmpfont(VFont *vfont)
|
struct TmpFont *vfont_find_tmpfont(VFont *vfont)
|
||||||
|
@@ -381,20 +381,20 @@ PyDoc_STRVAR(py_blf_gettext_doc,
|
|||||||
" :return: the localized string.\n"
|
" :return: the localized string.\n"
|
||||||
" :rtype: string\n"
|
" :rtype: string\n"
|
||||||
);
|
);
|
||||||
static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *args)
|
static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
|
||||||
{
|
{
|
||||||
char* msgid;
|
if ((U.transopts & USER_DOTRANSLATE) && (U.transopts & USER_TR_IFACE)) {
|
||||||
const char *text;
|
const char *msgid= _PyUnicode_AsString(value);
|
||||||
|
if(msgid == NULL) {
|
||||||
|
PyErr_SetString(PyExc_TypeError, "blf.gettext expects a single string argument");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s:blf.gettext", &msgid))
|
return PyUnicode_FromString(BLF_gettext(msgid));
|
||||||
return NULL;
|
}
|
||||||
|
else {
|
||||||
if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_IFACE))
|
return Py_INCREF(value), value;
|
||||||
text = BLF_gettext( msgid );
|
}
|
||||||
else
|
|
||||||
text = msgid;
|
|
||||||
|
|
||||||
return PyUnicode_FromString( text );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyDoc_STRVAR(py_blf_fake_gettext_doc,
|
PyDoc_STRVAR(py_blf_fake_gettext_doc,
|
||||||
@@ -407,15 +407,16 @@ PyDoc_STRVAR(py_blf_fake_gettext_doc,
|
|||||||
" :return: the source string.\n"
|
" :return: the source string.\n"
|
||||||
" :rtype: string\n"
|
" :rtype: string\n"
|
||||||
);
|
);
|
||||||
static PyObject *py_blf_fake_gettext(PyObject *UNUSED(self), PyObject *args)
|
static PyObject *py_blf_fake_gettext(PyObject *UNUSED(self), PyObject *value)
|
||||||
{
|
{
|
||||||
const char* msgid;
|
if (!PyUnicode_Check(value)) {
|
||||||
if (!PyArg_ParseTuple(args, "s:blf.fake_gettext", &msgid))
|
PyErr_SetString(PyExc_TypeError, "blf.fake_gettext expects a single string argument");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return PyUnicode_FromString( msgid );
|
return Py_INCREF(value), value;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* INTERNATIONAL */
|
||||||
|
|
||||||
/*----------------------------MODULE INIT-------------------------*/
|
/*----------------------------MODULE INIT-------------------------*/
|
||||||
static PyMethodDef BLF_methods[] = {
|
static PyMethodDef BLF_methods[] = {
|
||||||
@@ -433,8 +434,8 @@ static PyMethodDef BLF_methods[] = {
|
|||||||
{"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc},
|
{"size", (PyCFunction) py_blf_size, METH_VARARGS, py_blf_size_doc},
|
||||||
{"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc},
|
{"load", (PyCFunction) py_blf_load, METH_VARARGS, py_blf_load_doc},
|
||||||
#ifdef INTERNATIONAL
|
#ifdef INTERNATIONAL
|
||||||
{"gettext", (PyCFunction) py_blf_gettext, METH_VARARGS, py_blf_gettext_doc},
|
{"gettext", (PyCFunction) py_blf_gettext, METH_O, py_blf_gettext_doc},
|
||||||
{"fake_gettext", (PyCFunction) py_blf_fake_gettext, METH_VARARGS, py_blf_fake_gettext_doc},
|
{"fake_gettext", (PyCFunction) py_blf_fake_gettext, METH_O, py_blf_fake_gettext_doc},
|
||||||
#endif
|
#endif
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user