Fix FPS menu in "Format" panel not following translation setting

The FPS menu was using a cached value which wasn't being refreshed
when translation changed.

Add `bpy.app.handlers.translation_update_post` handler which runs
when translation changes, this can be used to clear any cached UI
values.

Ref !117049
This commit is contained in:
Damien Picard
2024-01-18 11:25:48 +11:00
committed by Campbell Barton
parent d068407a00
commit 8564e03cdf
4 changed files with 29 additions and 5 deletions

View File

@@ -104,6 +104,13 @@ _modules_loaded = [_namespace[name] for name in _modules]
del _namespace
# Bypass the caching mechanism in the "Format" panel to make sure it is properly translated on language update.
@bpy.app.handlers.persistent
def translation_update(_):
from .properties_output import RENDER_PT_format
RENDER_PT_format._frame_rate_args_prev = None
def register():
from bpy.utils import register_class
for mod in _modules_loaded:
@@ -166,6 +173,8 @@ def register():
)
del items
bpy.app.handlers.translation_update_post.append(translation_update)
# done...
@@ -176,6 +185,11 @@ def unregister():
if cls.is_registered:
unregister_class(cls)
try:
bpy.app.handlers.translation_update_post.remove(translation_update)
except ValueError:
pass
# Define a default UIList, when a list does not need any custom drawing...
# Keep in sync with its #defined name in UI_interface.hh