i18n: fake_gettext is no longer needed for python

This commit is contained in:
2011-09-20 08:38:16 +00:00
parent 16e21f49f7
commit bba54a051a
4 changed files with 373 additions and 288 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1174,6 +1174,13 @@ class WM_OT_get_messages(Operator):
def _walkClass(self, cls, messages): def _walkClass(self, cls, messages):
self._walkRNA(cls.bl_rna, messages) self._walkRNA(cls.bl_rna, messages)
def _walk_keymap_hierarchy(self, hier, messages):
for lvl in hier:
self._putMessage(messages, lvl[0])
if lvl[3]:
self._walk_keymap_hierarchy(lvl[3], messages)
def execute(self, context): def execute(self, context):
messages = {} messages = {}
@@ -1186,6 +1193,10 @@ class WM_OT_get_messages(Operator):
for cls in bpy.types.Operator.__subclasses__(): for cls in bpy.types.Operator.__subclasses__():
self._walkClass(cls, messages) self._walkClass(cls, messages)
from bl_ui.space_userpref_keymap import KM_HIERARCHY
self._walk_keymap_hierarchy(KM_HIERARCHY, messages)
text = bpy.data.texts.new(name="messages.txt") text = bpy.data.texts.new(name="messages.txt")
for message in messages: for message in messages:
text.write(message + "\n") text.write(message + "\n")

View File

@@ -21,92 +21,91 @@ import bpy
from bpy.types import Menu, Operator, OperatorProperties from bpy.types import Menu, Operator, OperatorProperties
import os import os
from blf import gettext as _ from blf import gettext as _
from blf import fake_gettext as N_
KM_HIERARCHY = [ KM_HIERARCHY = [
( N_('Window'), 'EMPTY', 'WINDOW', []), # file save, window change, exit ('Window', 'EMPTY', 'WINDOW', []), # file save, window change, exit
( N_('Screen'), 'EMPTY', 'WINDOW', [ # full screen, undo, screenshot ('Screen', 'EMPTY', 'WINDOW', [ # full screen, undo, screenshot
( N_('Screen Editing'), 'EMPTY', 'WINDOW', []), # resizing, action corners ('Screen Editing', 'EMPTY', 'WINDOW', []), # resizing, action corners
]), ]),
( N_('View2D'), 'EMPTY', 'WINDOW', []), # view 2d navigation (per region) ('View2D', 'EMPTY', 'WINDOW', []), # view 2d navigation (per region)
( N_('View2D Buttons List'), 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation ('View2D Buttons List', 'EMPTY', 'WINDOW', []), # view 2d with buttons navigation
( N_('Header'), 'EMPTY', 'WINDOW', []), # header stuff (per region) ('Header', 'EMPTY', 'WINDOW', []), # header stuff (per region)
( N_('Grease Pencil'), 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region) ('Grease Pencil', 'EMPTY', 'WINDOW', []), # grease pencil stuff (per region)
( N_('3D View'), 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform) ('3D View', 'VIEW_3D', 'WINDOW', [ # view 3d navigation and generic stuff (select, transform)
( N_('Object Mode'), 'EMPTY', 'WINDOW', []), ('Object Mode', 'EMPTY', 'WINDOW', []),
( N_('Mesh'), 'EMPTY', 'WINDOW', []), ('Mesh', 'EMPTY', 'WINDOW', []),
( N_('Curve'), 'EMPTY', 'WINDOW', []), ('Curve', 'EMPTY', 'WINDOW', []),
( N_('Armature'), 'EMPTY', 'WINDOW', []), ('Armature', 'EMPTY', 'WINDOW', []),
( N_('Metaball'), 'EMPTY', 'WINDOW', []), ('Metaball', 'EMPTY', 'WINDOW', []),
( N_('Lattice'), 'EMPTY', 'WINDOW', []), ('Lattice', 'EMPTY', 'WINDOW', []),
( N_('Font'), 'EMPTY', 'WINDOW', []), ('Font', 'EMPTY', 'WINDOW', []),
( N_('Pose'), 'EMPTY', 'WINDOW', []), ('Pose', 'EMPTY', 'WINDOW', []),
( N_('Vertex Paint'), 'EMPTY', 'WINDOW', []), ('Vertex Paint', 'EMPTY', 'WINDOW', []),
( N_('Weight Paint'), 'EMPTY', 'WINDOW', []), ('Weight Paint', 'EMPTY', 'WINDOW', []),
( N_('Face Mask'), 'EMPTY', 'WINDOW', []), ('Face Mask', 'EMPTY', 'WINDOW', []),
( N_('Image Paint'), 'EMPTY', 'WINDOW', []), # image and view3d ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
( N_('Sculpt'), 'EMPTY', 'WINDOW', []), ('Sculpt', 'EMPTY', 'WINDOW', []),
( N_('Armature Sketch'), 'EMPTY', 'WINDOW', []), ('Armature Sketch', 'EMPTY', 'WINDOW', []),
( N_('Particle'), 'EMPTY', 'WINDOW', []), ('Particle', 'EMPTY', 'WINDOW', []),
( N_('Object Non-modal'), 'EMPTY', 'WINDOW', []), # mode change ('Object Non-modal', 'EMPTY', 'WINDOW', []), # mode change
( N_('3D View Generic'), 'VIEW_3D', 'WINDOW', []) # toolbar and properties ('3D View Generic', 'VIEW_3D', 'WINDOW', []) # toolbar and properties
]), ]),
( N_('Frames'), 'EMPTY', 'WINDOW', []), # frame navigation (per region) ('Frames', 'EMPTY', 'WINDOW', []), # frame navigation (per region)
( N_('Markers'), 'EMPTY', 'WINDOW', []), # markers (per region) ('Markers', 'EMPTY', 'WINDOW', []), # markers (per region)
( N_('Animation'), 'EMPTY', 'WINDOW', []), # frame change on click, preview range (per region) ('Animation', 'EMPTY', 'WINDOW', []), # frame change on click, preview range (per region)
( N_('Animation Channels'), 'EMPTY', 'WINDOW', []), ('Animation Channels', 'EMPTY', 'WINDOW', []),
( N_('Graph Editor'), 'GRAPH_EDITOR', 'WINDOW', [ ('Graph Editor', 'GRAPH_EDITOR', 'WINDOW', [
( N_('Graph Editor Generic'), 'GRAPH_EDITOR', 'WINDOW', []) ('Graph Editor Generic', 'GRAPH_EDITOR', 'WINDOW', [])
]), ]),
( N_('Dopesheet'), 'DOPESHEET_EDITOR', 'WINDOW', []), ('Dopesheet', 'DOPESHEET_EDITOR', 'WINDOW', []),
( N_('NLA Editor'), 'NLA_EDITOR', 'WINDOW', [ ('NLA Editor', 'NLA_EDITOR', 'WINDOW', [
( N_('NLA Channels'), 'NLA_EDITOR', 'WINDOW', []), ('NLA Channels', 'NLA_EDITOR', 'WINDOW', []),
( N_('NLA Generic'), 'NLA_EDITOR', 'WINDOW', []) ('NLA Generic', 'NLA_EDITOR', 'WINDOW', [])
]), ]),
( N_('Image'), 'IMAGE_EDITOR', 'WINDOW', [ ('Image', 'IMAGE_EDITOR', 'WINDOW', [
( N_('UV Editor'), 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image ('UV Editor', 'EMPTY', 'WINDOW', []), # image (reverse order, UVEdit before Image
( N_('Image Paint'), 'EMPTY', 'WINDOW', []), # image and view3d ('Image Paint', 'EMPTY', 'WINDOW', []), # image and view3d
( N_('Image Generic'), 'IMAGE_EDITOR', 'WINDOW', []) ('Image Generic', 'IMAGE_EDITOR', 'WINDOW', [])
]), ]),
( N_('Timeline'), 'TIMELINE', 'WINDOW', []), ('Timeline', 'TIMELINE', 'WINDOW', []),
( N_('Outliner'), 'OUTLINER', 'WINDOW', []), ('Outliner', 'OUTLINER', 'WINDOW', []),
( N_('Node Editor'), 'NODE_EDITOR', 'WINDOW', [ ('Node Editor', 'NODE_EDITOR', 'WINDOW', [
( N_('Node Generic'), 'NODE_EDITOR', 'WINDOW', []) ('Node Generic', 'NODE_EDITOR', 'WINDOW', [])
]), ]),
( N_('Sequencer'), 'SEQUENCE_EDITOR', 'WINDOW', []), ('Sequencer', 'SEQUENCE_EDITOR', 'WINDOW', []),
( N_('Logic Editor'), 'LOGIC_EDITOR', 'WINDOW', []), ('Logic Editor', 'LOGIC_EDITOR', 'WINDOW', []),
( N_('File Browser'), 'FILE_BROWSER', 'WINDOW', [ ('File Browser', 'FILE_BROWSER', 'WINDOW', [
( N_('File Browser Main'), 'FILE_BROWSER', 'WINDOW', []), ('File Browser Main', 'FILE_BROWSER', 'WINDOW', []),
( N_('File Browser Buttons'), 'FILE_BROWSER', 'WINDOW', []) ('File Browser Buttons', 'FILE_BROWSER', 'WINDOW', [])
]), ]),
( N_('Property Editor'), 'PROPERTIES', 'WINDOW', []), # align context menu ('Property Editor', 'PROPERTIES', 'WINDOW', []), # align context menu
( N_('Script'), 'SCRIPTS_WINDOW', 'WINDOW', []), ('Script', 'SCRIPTS_WINDOW', 'WINDOW', []),
( N_('Text'), 'TEXT_EDITOR', 'WINDOW', []), ('Text', 'TEXT_EDITOR', 'WINDOW', []),
( N_('Console'), 'CONSOLE', 'WINDOW', []), ('Console', 'CONSOLE', 'WINDOW', []),
( N_('View3D Gesture Circle'), 'EMPTY', 'WINDOW', []), ('View3D Gesture Circle', 'EMPTY', 'WINDOW', []),
( N_('Gesture Border'), 'EMPTY', 'WINDOW', []), ('Gesture Border', 'EMPTY', 'WINDOW', []),
( N_('Standard Modal Map'), 'EMPTY', 'WINDOW', []), ('Standard Modal Map', 'EMPTY', 'WINDOW', []),
( N_('Transform Modal Map'), 'EMPTY', 'WINDOW', []), ('Transform Modal Map', 'EMPTY', 'WINDOW', []),
( N_('View3D Fly Modal'), 'EMPTY', 'WINDOW', []), ('View3D Fly Modal', 'EMPTY', 'WINDOW', []),
( N_('View3D Rotate Modal'), 'EMPTY', 'WINDOW', []), ('View3D Rotate Modal', 'EMPTY', 'WINDOW', []),
( N_('View3D Move Modal'), 'EMPTY', 'WINDOW', []), ('View3D Move Modal', 'EMPTY', 'WINDOW', []),
( N_('View3D Zoom Modal'), 'EMPTY', 'WINDOW', []), ('View3D Zoom Modal', 'EMPTY', 'WINDOW', []),
] ]

View File

@@ -397,26 +397,6 @@ static PyObject *py_blf_gettext(PyObject *UNUSED(self), PyObject *value)
return Py_INCREF(value), value; return Py_INCREF(value), value;
} }
} }
PyDoc_STRVAR(py_blf_fake_gettext_doc,
".. function:: fake_gettext(msgid)\n"
"\n"
" Just tag the msgid.\n"
"\n"
" :arg msgid: the source string.\n"
" :type msgid: string\n"
" :return: the source string.\n"
" :rtype: string\n"
);
static PyObject *py_blf_fake_gettext(PyObject *UNUSED(self), PyObject *value)
{
if (!PyUnicode_Check(value)) {
PyErr_SetString(PyExc_TypeError, "blf.fake_gettext expects a single string argument");
return NULL;
}
return Py_INCREF(value), value;
}
#endif /* INTERNATIONAL */ #endif /* INTERNATIONAL */
/*----------------------------MODULE INIT-------------------------*/ /*----------------------------MODULE INIT-------------------------*/
@@ -436,7 +416,6 @@ static PyMethodDef BLF_methods[] = {
{"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_O, py_blf_gettext_doc}, {"gettext", (PyCFunction) py_blf_gettext, METH_O, py_blf_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}
}; };