mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 17:37:14 +00:00
Localize fixed picker titles with a translated-template fallback
This commit is contained in:
1 parent
1c85e25bbf
commit
d676995a77
2 files changed
+7
-2
No files matched your search
@@ -787,8 +787,8 @@ fn about_tab_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, tab: &str) {
|
||||
/// The dialog title as shown: [`title`] in the UI language.
|
||||
fn display_title(d: &Dialog) -> String {
|
||||
match d.fields.get("__colorPicker").and_then(Value::as_str) {
|
||||
Some("foreground") => return tl!("Color Picker (Foreground Color)").to_string(),
|
||||
Some("background") => return tl!("Color Picker (Background Color)").to_string(),
|
||||
Some("foreground") => return crate::color_picker_ui::fixed_title("Color Picker (Foreground Color)", "Foreground Color"),
|
||||
Some("background") => return crate::color_picker_ui::fixed_title("Color Picker (Background Color)", "Background Color"),
|
||||
_ => {}
|
||||
}
|
||||
if crate::smart_filter_dialog::owns(&d.fields) {
|
||||
|
||||
@@ -221,6 +221,11 @@ pub fn title_for(name: &str) -> String {
|
||||
crate::i18n::fmt(tl!("Color Picker ({name})"), &[("name", name)])
|
||||
}
|
||||
|
||||
/// Prefer a complete catalogued title; some locales only provide the named-colour template.
|
||||
pub(crate) fn fixed_title(label: &str, name: &str) -> String {
|
||||
if crate::i18n::has(crate::i18n::current(), label) { tl!(label).to_string() } else { title_for(tl!(name)) }
|
||||
}
|
||||
|
||||
/// The `"#rrggbb"` at `field` of `f` (a key or a JSON pointer).
|
||||
fn field_value<'a>(f: &'a Map<String, Value>, field: &str) -> Option<&'a str> {
|
||||
match field.strip_prefix('/') {
|
||||
|
||||
Reference in new issue
Block a user