Fix T61446: (second part) Some items in editor and mode selectors are not translatable.
That one is utterly ugly fix really, but unfortunately a proper one would require some changes to our RNA (or more precisely, pyrna) code, so that when we subscript a dynamically generated RNA collection, the item is somehow duplicated (and probably 'assigned' to its py object?), before the temp RNA array memory is freed...
This commit is contained in:
parent
10efc54729
commit
cf92d83c0a
Notes:
blender-bot
2023-02-14 04:10:15 +01:00
Referenced by issue #61446, Some items in editor and mode selectors are not translatable
|
@ -52,13 +52,22 @@ class VIEW3D_HT_header(Header):
|
|||
|
||||
object_mode = 'OBJECT' if obj is None else obj.mode
|
||||
|
||||
# Note: This is actually deadly in case enum_items have to be dynamically generated
|
||||
# (because internal RNA array iterator will free everything immediately...).
|
||||
# XXX This is an RNA internal issue, not sure how to fix it.
|
||||
# Note: Tried to add an accessor to get translated UI strings instead of manual call
|
||||
# to pgettext_iface below, but this fails because translated enumitems
|
||||
# are always dynamically allocated.
|
||||
act_mode_item = bpy.types.Object.bl_rna.properties["mode"].enum_items[object_mode]
|
||||
act_mode_i18n_context = bpy.types.Object.bl_rna.properties["mode"].translation_context
|
||||
|
||||
row.separator()
|
||||
|
||||
sub = row.row()
|
||||
sub.ui_units_x = 5.5
|
||||
sub.operator_menu_enum("object.mode_set", "mode", text=act_mode_item.name, icon=act_mode_item.icon)
|
||||
sub.operator_menu_enum("object.mode_set", "mode",
|
||||
text=bpy.app.translations.pgettext_iface(act_mode_item.name, act_mode_i18n_context),
|
||||
icon=act_mode_item.icon)
|
||||
del act_mode_item
|
||||
|
||||
layout.template_header_3D_mode()
|
||||
|
|
Loading…
Reference in New Issue