mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
I18n: Translate color management using a new translation context
Many UI messages are extracted from the OpenColorIO config, including color spaces and families, displays, views, view transforms, and looks. The risk of a translation collision between these data and other messages is quite high, especially if using an OCIO config other than the built-in one. This commit changes extraction and translation so that all these strings are translated with the new "Color Management" translation context. It does not reuse the existing "Color" context, in the unlikely event of a collision with other color-related stuff in the UI. Suggested by Bastien Montagne while reviewing !160883. Pull Request: https://projects.blender.org/blender/blender/pulls/161053
This commit is contained in:
parent
29b250ad2e
commit
fa663e3b59
8 changed files with 28 additions and 16 deletions
|
|
@ -966,17 +966,18 @@ 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()
|
||||
translation_context = bpy.app.translations.contexts.color_management
|
||||
|
||||
for display in config.getDisplays():
|
||||
msgsrc = "Display name from OCIO config"
|
||||
process_msg(
|
||||
msgs, settings.DEFAULT_CONTEXT, display, msgsrc,
|
||||
msgs, translation_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,
|
||||
msgs, translation_context, view, msgsrc,
|
||||
reports, None, settings,
|
||||
)
|
||||
description = config.getDisplayViewDescription(display, view)
|
||||
|
|
@ -989,7 +990,7 @@ def dump_ocio_config(msgs, reports, settings):
|
|||
for view_transform in config.getViewTransforms():
|
||||
msgsrc = "View transform name from OCIO config"
|
||||
process_msg(
|
||||
msgs, settings.DEFAULT_CONTEXT, view_transform.getName(), msgsrc,
|
||||
msgs, translation_context, view_transform.getName(), msgsrc,
|
||||
reports, None, settings,
|
||||
)
|
||||
description = config.getDisplayViewDescription(display, view)
|
||||
|
|
@ -1010,7 +1011,7 @@ def dump_ocio_config(msgs, reports, settings):
|
|||
source = "OCIO config"
|
||||
msgsrc = "Look name from " + source
|
||||
process_msg(
|
||||
msgs, settings.DEFAULT_CONTEXT, name, msgsrc,
|
||||
msgs, translation_context, name, msgsrc,
|
||||
reports, None, settings,
|
||||
)
|
||||
msgsrc = "Look description from " + source
|
||||
|
|
@ -1024,7 +1025,7 @@ def dump_ocio_config(msgs, reports, settings):
|
|||
name = colorspace.getName()
|
||||
msgsrc = "Colorspace name from OCIO config"
|
||||
process_msg(
|
||||
msgs, settings.DEFAULT_CONTEXT, name, msgsrc,
|
||||
msgs, translation_context, name, msgsrc,
|
||||
reports, None, settings,
|
||||
)
|
||||
description = colorspace.getDescription()
|
||||
|
|
@ -1038,7 +1039,7 @@ def dump_ocio_config(msgs, reports, settings):
|
|||
for family_part in family.split(family_separator):
|
||||
msgsrc = "Colorspace family from OCIO config"
|
||||
process_msg(
|
||||
msgs, settings.DEFAULT_CONTEXT, family_part, msgsrc,
|
||||
msgs, translation_context, family_part, msgsrc,
|
||||
reports, None, settings,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class RENDER_PT_color_management_working_space(RenderButtonsPanel, Panel):
|
|||
"wm.set_working_color_space",
|
||||
"working_space",
|
||||
text=blend_colorspace.working_space,
|
||||
text_ctxt=i18n_contexts.default,
|
||||
text_ctxt=i18n_contexts.color_management,
|
||||
)
|
||||
|
||||
col.prop_with_menu(
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ StringRef BLT_translate_do_new_dataname(StringRef msgctxt, StringRef msgid);
|
|||
/* Generic contexts. */
|
||||
#define BLT_I18NCONTEXT_AMOUNT "Amount"
|
||||
#define BLT_I18NCONTEXT_COLOR "Color"
|
||||
#define BLT_I18NCONTEXT_COLOR_MANAGEMENT "Color Management"
|
||||
#define BLT_I18NCONTEXT_CONSTRAINT "Constraint"
|
||||
#define BLT_I18NCONTEXT_MODIFIER "Modifier"
|
||||
#define BLT_I18NCONTEXT_NAVIGATION "Navigation"
|
||||
|
|
@ -232,6 +233,7 @@ struct BLT_i18n_contexts_descriptor {
|
|||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_EDITOR_VIEW3D, "editor_view3d"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_AMOUNT, "amount"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COLOR, "color"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_COLOR_MANAGEMENT, "color_management"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_CONSTRAINT, "constraint"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_MODIFIER, "modifier"), \
|
||||
BLT_I18NCONTEXTS_ITEM(BLT_I18NCONTEXT_NAVIGATION, "navigation"), \
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ static void colorspaces_menu_draw(const bContext *C, Menu *menu)
|
|||
for (const StringRef &dir : subdirs) {
|
||||
std::string path = root + std::string(dir);
|
||||
col.context_string_set("colorspace_parent_path", path);
|
||||
col.menu(COLORSPACE_MENU_ID, IFACE_(dir), ICON_NONE);
|
||||
col.menu(COLORSPACE_MENU_ID, CTX_IFACE_(BLT_I18NCONTEXT_COLOR_MANAGEMENT, dir), ICON_NONE);
|
||||
}
|
||||
|
||||
if (!subdirs.is_empty() && !colorspaces_at_this_level.is_empty()) {
|
||||
|
|
@ -180,12 +180,13 @@ static void colorspaces_menu_draw(const bContext *C, Menu *menu)
|
|||
}
|
||||
|
||||
for (const ColorSpace *cs : colorspaces_at_this_level) {
|
||||
colorspaces_menu_add_button(col,
|
||||
ptr,
|
||||
prop,
|
||||
IMB_colormanagement_colorspace_get_name(cs),
|
||||
IFACE_(IMB_colormanagement_colorspace_get_name(cs)),
|
||||
TIP_(IMB_colormanagement_colorspace_get_description(cs)));
|
||||
colorspaces_menu_add_button(
|
||||
col,
|
||||
ptr,
|
||||
prop,
|
||||
IMB_colormanagement_colorspace_get_name(cs),
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_COLOR_MANAGEMENT, IMB_colormanagement_colorspace_get_name(cs)),
|
||||
TIP_(IMB_colormanagement_colorspace_get_description(cs)));
|
||||
}
|
||||
|
||||
if (!parent_path) {
|
||||
|
|
@ -193,7 +194,7 @@ static void colorspaces_menu_draw(const bContext *C, Menu *menu)
|
|||
ptr,
|
||||
prop,
|
||||
"scene_linear",
|
||||
IFACE_("Working Space"),
|
||||
CTX_IFACE_(BLT_I18NCONTEXT_COLOR_MANAGEMENT, "Working Space"),
|
||||
TIP_("Working color space of the current file"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1411,6 +1411,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
|
|||
"Display name. For viewing, this is the display device that will be emulated by limiting "
|
||||
"the gamut and HDR colors. For image and video output, this is the display space used for "
|
||||
"writing.");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(
|
||||
prop, NC_WINDOW, "rna_ColorManagedDisplaySettings_display_device_update");
|
||||
|
||||
|
|
@ -1438,6 +1439,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
|
|||
"rna_ColorManagedViewSettings_look_itemf");
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Look", "Additional transform applied before view transform for artistic needs");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
|
||||
|
||||
prop = RNA_def_property(srna, "view_transform", PROP_ENUM, PROP_NONE);
|
||||
|
|
@ -1447,6 +1449,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
|
|||
"rna_ColorManagedViewSettings_view_transform_set",
|
||||
"rna_ColorManagedViewSettings_view_transform_itemf");
|
||||
RNA_def_property_ui_text(prop, "View", "View used when converting image to a display space");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagement_update");
|
||||
|
||||
prop = RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_FACTOR);
|
||||
|
|
@ -1557,6 +1560,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
|
|||
prop,
|
||||
"Input Color Space",
|
||||
"Color space in the image file, to convert to and from when saving and loading the image");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
|
||||
|
||||
prop = RNA_def_property(srna, "is_data", PROP_BOOLEAN, PROP_NONE);
|
||||
|
|
@ -1584,6 +1588,7 @@ static void rna_def_colormanage(BlenderRNA *brna)
|
|||
"rna_ColorManagedColorspaceSettings_colorspace_set",
|
||||
"rna_ColorManagedColorspaceSettings_colorspace_itemf");
|
||||
RNA_def_property_ui_text(prop, "Color Space", "Color space that the sequencer operates in");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_WINDOW, "rna_ColorManagedColorspaceSettings_reload_update");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
#include <cstring>
|
||||
|
||||
#include "BLI_path_utils.hh"
|
||||
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
#include "BLT_translation.hh"
|
||||
|
|
@ -299,6 +298,7 @@ static void rna_def_main_colorspace(BlenderRNA *brna)
|
|||
"Working Space",
|
||||
"Color space used for all scene linear colors in this file, and "
|
||||
"for compositing, shader and geometry nodes processing");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_enum_funcs(prop,
|
||||
"rna_MainColorspace_working_space_get",
|
||||
nullptr,
|
||||
|
|
|
|||
|
|
@ -6989,6 +6989,7 @@ static void def_cmp_convert_color_space(BlenderRNA * /*brna*/, StructRNA *srna)
|
|||
"rna_NodeConvertColorSpace_from_color_space_set",
|
||||
"rna_NodeConvertColorSpace_color_space_itemf");
|
||||
RNA_def_property_ui_text(prop, "From", "Color space of the input image");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "to_color_space", PROP_ENUM, PROP_NONE);
|
||||
|
|
@ -6999,6 +7000,7 @@ static void def_cmp_convert_color_space(BlenderRNA * /*brna*/, StructRNA *srna)
|
|||
"rna_NodeConvertColorSpace_to_color_space_set",
|
||||
"rna_NodeConvertColorSpace_color_space_itemf");
|
||||
RNA_def_property_ui_text(prop, "To", "Color space of the output image");
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -205,6 +205,7 @@ void WM_OT_set_working_color_space(wmOperatorType *ot)
|
|||
"Working Space",
|
||||
"Color space to set");
|
||||
RNA_def_enum_funcs(prop, working_space_itemf);
|
||||
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_COLOR_MANAGEMENT);
|
||||
|
||||
ot->prop = prop;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue