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).
This commit is contained in:
Damien Picard
2025-09-13 18:03:16 +02:00
committed by Bastien Montagne
parent 51cdcc3186
commit 285c1ee8bb

View File

@@ -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)