From 285c1ee8bb26df84bce550ec2aa97c265c09087a Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Sat, 13 Sep 2025 18:03:16 +0200 Subject: [PATCH] I18n: Get displays, views, looks, colorspaces info from OCIO config This extracts the names and descriptions for displays, views, and colorspaces. They are all used in the different parts of the UI. The views' descriptions are used for the displays'. The extraction uses the built-in PyOpenColorIO module. This ensures only data that is actually used is extracted (not ignored in the config). --- .../bl_i18n_utils/bl_extract_messages.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/scripts/modules/bl_i18n_utils/bl_extract_messages.py index 94815fadcc7..dd79b165aac 100644 --- a/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -964,6 +964,68 @@ def dump_template_messages(msgs, reports, settings): ) +def dump_ocio_config(msgs, reports, settings): + # This assumes the default Blender config is used when we extract messages. + import PyOpenColorIO as OCIO + config = OCIO.GetCurrentConfig() + + for display in config.getDisplays(): + msgsrc = "Display name from OCIO config" + process_msg( + msgs, settings.DEFAULT_CONTEXT, display, msgsrc, + reports, None, settings, + ) + + for view in config.getViews(display): + msgsrc = "View name from OCIO display " + display + process_msg( + msgs, settings.DEFAULT_CONTEXT, view, msgsrc, + reports, None, settings, + ) + + description = config.getDisplayViewDescription(display, view) + msgsrc = "View description from OCIO display " + display + process_msg( + msgs, settings.DEFAULT_CONTEXT, description, msgsrc, + reports, None, settings, + ) + + for look in config.getLookNames(): + # Some looks include their view's name to have unique names, + # we need to keep only the look. + if " - " in look: + view, name = look.split(" - ") + source = "OCIO view " + view + else: + name = look + source = "OCIO config" + msgsrc = "Look name from " + source + process_msg( + msgs, settings.DEFAULT_CONTEXT, name, msgsrc, + reports, None, settings, + ) + msgsrc = "Look description from " + source + description = config.getLook(look).getDescription() + process_msg( + msgs, settings.DEFAULT_CONTEXT, description, msgsrc, + reports, None, settings, + ) + + for colorspace in config.getColorSpaces(): + name = colorspace.getName() + msgsrc = "Colorspace name from OCIO config" + process_msg( + msgs, settings.DEFAULT_CONTEXT, name, msgsrc, + reports, None, settings, + ) + description = colorspace.getDescription() + msgsrc = "Colorspace description from OCIO config" + process_msg( + msgs, settings.DEFAULT_CONTEXT, description, msgsrc, + reports, None, settings, + ) + + def dump_asset_messages(msgs, reports, settings): # Where to search for assets, relative to the local user resources. assets_dir = os.path.join(bpy.utils.resource_path('LOCAL'), "datafiles", "assets") @@ -1158,6 +1220,9 @@ def dump_messages(do_messages, do_checks, settings): reports, None, settings, ) + # Get strings from OCIO config. + dump_ocio_config(msgs, reports, settings) + # Get strings from asset catalogs and blend files. # This loads each asset blend file in turn. dump_asset_messages(msgs, reports, settings)