forked from bartvdbraak/blender
minor changes to _build_translations_cache(), remove unneeded NULL checks and use slightly different funcs for getting strings.
This commit is contained in:
parent
38cee985bb
commit
d05f46c12d
@ -177,13 +177,21 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
|
|||||||
PyObject *tmp;
|
PyObject *tmp;
|
||||||
const char *msgctxt = NULL, *msgid = NULL;
|
const char *msgctxt = NULL, *msgid = NULL;
|
||||||
|
|
||||||
tmp = PyTuple_GetItem(pykey, 0);
|
if ((PyTuple_CheckExact(pykey) == false) ||
|
||||||
if (tmp && PyUnicode_Check(tmp) && !PyUnicode_READY(tmp)) {
|
(PyTuple_GET_SIZE(pykey) != 2) ||
|
||||||
msgctxt = (const char *)PyUnicode_AsUTF8(tmp);
|
(PyUnicode_Check(trans) == false))
|
||||||
|
{
|
||||||
|
/* TODO, we should error here */
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
tmp = PyTuple_GetItem(pykey, 1);
|
|
||||||
if (tmp && PyUnicode_Check(tmp) && !PyUnicode_READY(tmp)) {
|
tmp = PyTuple_GET_ITEM(pykey, 0);
|
||||||
msgid = (const char *)PyUnicode_AsUTF8(tmp);
|
if (PyUnicode_Check(tmp)) {
|
||||||
|
msgctxt = _PyUnicode_AsString(tmp);
|
||||||
|
}
|
||||||
|
tmp = PyTuple_GET_ITEM(pykey, 1);
|
||||||
|
if (PyUnicode_Check(tmp)) {
|
||||||
|
msgid = _PyUnicode_AsString(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(msgctxt && msgid)) {
|
if (!(msgctxt && msgid)) {
|
||||||
@ -197,9 +205,7 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trans && PyUnicode_Check(trans) && !PyUnicode_READY(trans)) {
|
BLI_ghash_insert(_translations_cache, key, BLI_strdup(_PyUnicode_AsString(trans)));
|
||||||
BLI_ghash_insert(_translations_cache, key, BLI_strdup((const char *)PyUnicode_AsUTF8(trans)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user