Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Localise the UI: i18n foundation and a Japanese catalog (menus, dialogs, panels) (#169)

Kentaro Tsutsumi17d4cd0d789e
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs
index 8cc953509..474be6111 100644
--- a/crates/engine/src/prefs.rs
+++ b/crates/engine/src/prefs.rs
@@ -201,6 +201,10 @@ pub struct Interface {
/// Document border in standard screen mode.
pub canvas_border: CanvasBorder,
pub ui_scale: UiScale,
+ /// UI language: `auto` (follow the system) or a language code such as `en`, `ja`. The list of
+ /// languages belongs to the shell (`ui-egui` i18n); an unknown code falls back to `auto`.
+ /// Command ids and the control protocol stay English.
+ pub language: String,
pub ui_font_size: UiFontSize,
pub show_channels_in_color: bool,
pub dynamic_color_sliders: bool,
@@ -217,6 +221,7 @@ impl Default for Interface {
canvas_custom_color: "#282828".into(),
canvas_border: CanvasBorder::DropShadow,
ui_scale: UiScale::Auto,
+ language: "auto".into(),
ui_font_size: UiFontSize::Small,
show_channels_in_color: false,
dynamic_color_sliders: true,
@@ -984,6 +989,12 @@ fn check_value(path: &str, v: &Value) -> std::result::Result<(), String> {
return Err(format!("`{path}` must be one of {} (got `{s}`)", c.join("|")));
}
}
+ if path == "interface.language" {
+ let ok = v.as_str().is_some_and(|s| !s.is_empty() && s.len() <= 16 && s.chars().all(|c| c.is_ascii_alphanumeric() || c == '-'));
+ if !ok {
+ return Err("`interface.language` must be `auto` or a language code such as `en` or `ja`".into());
+ }
+ }
if let Some((lo, hi)) = range(path) {
let x = v.as_f64().ok_or_else(|| format!("`{path}` must be a number"))?;
if !(lo..=hi).contains(&x) {
diff --git a/crates/ui-egui/src/actions.rs b/crates/ui-egui/src/actions.rs
index 3217a9a98..e883b4a04 100644
--- a/crates/ui-egui/src/actions.rs
+++ b/crates/ui-egui/src/actions.rs
@@ -70,7 +70,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut play_idx = None;
egui::ScrollArea::vertical().id_salt("actions-rows").max_height(max_h).auto_shrink([false, true]).show(ui, |ui| {
if app.ui.actions.list.is_empty() {
- ui.label(egui::RichText::new("Record ● a sequence of edits, then play ▶ it on any document.").color(t.text_faint).size(11.5));
+ ui.label(egui::RichText::new(tl!("Record ● a sequence of edits, then play ▶ it on any document.")).color(t.text_faint).size(11.5));
}
let n = app.ui.actions.list.len();
for i in 0..n {
@@ -126,7 +126,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
let recording = app.ui.actions.recording.is_some();
- if crate::icons::button(ui, "square", 24.0, false, "Stop playing/recording").clicked() {
+ if crate::icons::button(ui, "square", 24.0, false, tl!("Stop playing/recording")).clicked() {
stop_recording(app);
}
let (r, rec) = ui.allocate_exact_size(vec2(24.0, 24.0), Sense::click());
@@ -134,16 +134,16 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.painter().rect_filled(r, 3.0, t.hover);
}
ui.painter().circle_filled(r.center(), 5.5, if recording { Color32::from_rgb(230, 60, 60) } else { t.icon });
- if rec.on_hover_text("Begin recording").clicked() && !recording {
+ if rec.on_hover_text(tl!("Begin recording")).clicked() && !recording {
start_recording(app);
}
- if crate::icons::button(ui, "play", 24.0, false, "Play selection").clicked() {
+ if crate::icons::button(ui, "play", 24.0, false, tl!("Play selection")).clicked() {
play_idx = app.ui.actions.selected;
}
- if crate::icons::button(ui, "plus", 24.0, false, "Create new action").clicked() && !recording {
+ if crate::icons::button(ui, "plus", 24.0, false, tl!("Create new action")).clicked() && !recording {
start_recording(app);
}
- if crate::icons::button(ui, "trash", 24.0, false, "Delete").clicked()
+ if crate::icons::button(ui, "trash", 24.0, false, tl!("Delete")).clicked()
&& !recording
&& let Some(i) = app.ui.actions.selected.take()
&& i < app.ui.actions.list.len()
diff --git a/crates/ui-egui/src/adjust_dialog.rs b/crates/ui-egui/src/adjust_dialog.rs
index 93a9ddb89..585119932 100644
--- a/crates/ui-egui/src/adjust_dialog.rs
+++ b/crates/ui-egui/src/adjust_dialog.rs
@@ -64,7 +64,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, fields: &mut Map<String,
}
let mut preview = fields.get("__preview").and_then(Value::as_bool).unwrap_or(true);
ui.add_space(6.0);
- if crate::widgets::checkbox(ui, &mut preview, "Preview").changed() {
+ if crate::widgets::checkbox(ui, &mut preview, tl!("Preview")).changed() {
fields.insert("__preview".into(), json!(preview));
}
}
diff --git a/crates/ui-egui/src/adjust_editors.rs b/crates/ui-egui/src/adjust_editors.rs
index 85732681d..5e754a823 100644
--- a/crates/ui-egui/src/adjust_editors.rs
+++ b/crates/ui-egui/src/adjust_editors.rs
@@ -102,7 +102,11 @@ pub fn editor(ui: &mut egui::Ui, kind: &str, v: &mut Value, cx: &EditorCx) -> Ed
"exposure" => sliders(
ui,
v,
- &[("exposure", "Exposure", -20.0, 20.0, 0.0, ""), ("offset", "Offset", -0.5, 0.5, 0.0, ""), ("gamma", "Gamma Correction", 0.01, 9.99, 1.0, "")],
+ &[
+ ("exposure", tl!("Exposure"), -20.0, 20.0, 0.0, ""),
+ ("offset", tl!("Offset"), -0.5, 0.5, 0.0, ""),
+ ("gamma", tl!("Gamma Correction"), 0.01, 9.99, 1.0, ""),
+ ],
),
"vibrance" => sliders(ui, v, &[("vibrance", "Vibrance", -100.0, 100.0, 0.0, "%"), ("saturation", "Saturation", -100.0, 100.0, 0.0, "%")]),
"hueSaturation" => hue_saturation(ui, v, cx),
@@ -170,7 +174,7 @@ fn color_button(ui: &mut egui::Ui, c: &mut [f32; 3]) -> Edit {
fn label(ui: &mut egui::Ui, text: &str) {
let t = Tokens::get(ui.ctx());
- ui.label(RichText::new(text).color(t.text_dim).size(12.0));
+ ui.label(RichText::new(tl!(&text)).color(t.text_dim).size(12.0));
}
/// Labelled slider rows over top-level keys: (key, label, min, max, default, unit).
@@ -198,9 +202,9 @@ fn gradient_slider(ui: &mut egui::Ui, text: &str, x: &mut f32, range: std::ops::
fn brightness_contrast(ui: &mut egui::Ui, v: &mut Value) -> Edit {
let legacy = flag(v, "legacy", false);
let lo = if legacy { -100.0 } else { -50.0 };
- let mut e = sliders(ui, v, &[("brightness", "Brightness", -150.0, 150.0, 0.0, ""), ("contrast", "Contrast", lo, 100.0, 0.0, "")]);
+ let mut e = sliders(ui, v, &[("brightness", tl!("Brightness"), -150.0, 150.0, 0.0, ""), ("contrast", tl!("Contrast"), lo, 100.0, 0.0, "")]);
let mut l = legacy;
- if widgets::checkbox(ui, &mut l, "Use Legacy").changed() {
+ if widgets::checkbox(ui, &mut l, tl!("Use Legacy")).changed() {
v["legacy"] = json!(l);
if !l {
v["contrast"] = json!(num(v, "contrast", 0.0).max(-50.0));
@@ -400,7 +404,7 @@ fn curves(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let chans = tone_channels(space, cx.gray);
let state_id = cx.mem.with("curves");
let mut st: CurveUi = ui.data(|d| d.get_temp(state_id)).unwrap_or_default();
- let ch = channel_picker(ui, cx.mem.with("curves-ch"), chans, "Channel:");
+ let ch = channel_picker(ui, cx.mem.with("curves-ch"), chans, tl!("Channel:"));
if ch != st.channel {
st = CurveUi { channel: ch, ..Default::default() };
}
@@ -557,9 +561,9 @@ fn curves(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
ui.horizontal(|ui| {
let i = st.sel.filter(|i| *i < pts.len());
let (mut vi, mut vo) = i.map_or((0.0, 0.0), |i| (pts[i][0], pts[i][1]));
- label(ui, "Input:");
+ label(ui, tl!("Input:"));
let ri = ui.add_enabled_ui(i.is_some(), |ui| widgets::value_field(ui, &mut vi, 0.0..=255.0, "", 52.0)).inner;
- label(ui, "Output:");
+ label(ui, tl!("Output:"));
let ro = ui.add_enabled_ui(i.is_some(), |ui| widgets::value_field(ui, &mut vo, 0.0..=255.0, "", 52.0)).inner;
if let Some(i) = i
&& (ri.changed() || ro.changed())
@@ -574,9 +578,12 @@ fn curves(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
});
let t2 = Tokens::get(ui.ctx());
ui.label(
- RichText::new(format!("Click to add a point · drag off or {}-click or Delete to remove", crate::shortcuts::pretty("Cmd")))
- .color(t2.text_faint)
- .size(11.0),
+ RichText::new(crate::i18n::fmt(
+ tl!("Click to add a point · drag off or {key}-click or Delete to remove"),
+ &[("key", &crate::shortcuts::pretty("Cmd"))],
+ ))
+ .color(t2.text_faint)
+ .size(11.0),
);
ui.data_mut(|d| d.insert_temp(state_id, st));
if changed {
@@ -657,9 +664,9 @@ fn levels(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mut ch = 0;
let mut auto = false;
ui.horizontal(|ui| {
- ch = channel_picker(ui, cx.mem.with("levels-ch"), chans, "Channel:");
+ ch = channel_picker(ui, cx.mem.with("levels-ch"), chans, tl!("Channel:"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- auto = widgets::secondary_button(ui, "Auto", 0.0).clicked();
+ auto = widgets::secondary_button(ui, tl!("Auto"), 0.0).clicked();
});
});
let chan = chans.get(ch).copied().unwrap_or(ToneChannel { key: "", label: "" });
@@ -744,7 +751,7 @@ fn levels(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
});
// Output levels.
ui.add_space(6.0);
- label(ui, "Output Levels:");
+ label(ui, tl!("Output Levels:"));
let (ob_r, _) = ui.allocate_exact_size(vec2(w, 10.0), Sense::hover());
gradient_bar(ui.painter(), ob_r.shrink2(vec2(6.0, 0.0)), Color32::BLACK, bar_color(&chan, &t), false);
let (or, oresp) = ui.allocate_exact_size(vec2(w, 14.0), Sense::click_and_drag());
@@ -816,7 +823,7 @@ fn threshold(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
p.line_segment([pos2(x, hr.top()), pos2(x, hr.bottom())], Stroke::new(1.0, t.accent));
p.rect_stroke(hr, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
ui.add_space(4.0);
- sliders(ui, v, &[("level", "Threshold Level", 1.0, 255.0, 128.0, "")])
+ sliders(ui, v, &[("level", tl!("Threshold Level"), 1.0, 255.0, 128.0, "")])
}
// ---------------------------------------------------------------------------------------------
@@ -862,7 +869,7 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
range = 0;
}
ui.horizontal(|ui| {
- let opts: Vec<(usize, &str)> = std::iter::once((0, "Master")).chain(RANGE_LABELS.iter().enumerate().map(|(i, l)| (i + 1, *l))).collect();
+ let opts: Vec<(usize, &str)> = std::iter::once((0, tl!("Master"))).chain(RANGE_LABELS.iter().enumerate().map(|(i, l)| (i + 1, *l))).collect();
ui.add_enabled_ui(!colorize, |ui| widgets::dropdown(ui, &format!("{range_id:?}"), &mut range, &opts, 120.0));
});
ui.data_mut(|d| d.insert_temp(range_id, range));
@@ -871,18 +878,18 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
if range == 0 {
let (hlo, hhi, slo) = if colorize { (0.0, 360.0, 0.0) } else { (-180.0, 180.0, -100.0) };
let mut h = num(v, "hue", 0.0).clamp(hlo, hhi);
- let r = widgets::slider_row(ui, "Hue", &mut h, hlo..=hhi, "°", Some(&hue_grad));
+ let r = widgets::slider_row(ui, tl!("Hue"), &mut h, hlo..=hhi, "°", Some(&hue_grad));
if r.changed() {
v["hue"] = json!(h.round());
}
e.add(Edit::of(&r));
let mut s = num(v, "saturation", 0.0).clamp(slo, 100.0);
- let r = widgets::slider_row(ui, "Saturation", &mut s, slo..=100.0, "%", None);
+ let r = widgets::slider_row(ui, tl!("Saturation"), &mut s, slo..=100.0, "%", None);
if r.changed() {
v["saturation"] = json!(s.round());
}
e.add(Edit::of(&r));
- e.add(sliders(ui, v, &[("lightness", "Lightness", -100.0, 100.0, 0.0, "%")]));
+ e.add(sliders(ui, v, &[("lightness", tl!("Lightness"), -100.0, 100.0, 0.0, "%")]));
} else {
let key = HUE_RANGES[range - 1];
if !v.get(key).is_some_and(Value::is_object) {
@@ -891,19 +898,19 @@ fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mut o = v[key].clone();
let mut sub = Edit::default();
let mut h = num(&o, "hue", 0.0);
- let r = widgets::slider_row(ui, "Hue", &mut h, -180.0..=180.0, "°", Some(&hue_grad));
+ let r = widgets::slider_row(ui, tl!("Hue"), &mut h, -180.0..=180.0, "°", Some(&hue_grad));
if r.changed() {
o["hue"] = json!(h.round());
}
sub.add(Edit::of(&r));
- sub.add(sliders(ui, &mut o, &[("saturation", "Saturation", -100.0, 100.0, 0.0, "%"), ("lightness", "Lightness", -100.0, 100.0, 0.0, "%")]));
+ sub.add(sliders(ui, &mut o, &[("saturation", tl!("Saturation"), -100.0, 100.0, 0.0, "%"), ("lightness", tl!("Lightness"), -100.0, 100.0, 0.0, "%")]));
if sub.changed {
v[key] = o;
}
e.add(sub);
}
let mut c = colorize;
- if widgets::checkbox(ui, &mut c, "Colorize").changed() {
+ if widgets::checkbox(ui, &mut c, tl!("Colorize")).changed() {
v["colorize"] = json!(c);
let h = num(v, "hue", 0.0);
v["hue"] = json!(if c {
@@ -999,8 +1006,8 @@ fn color_balance(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let tone_id = cx.mem.with("cb-tone");
let mut tone_ix: usize = ui.data(|d| d.get_temp(tone_id)).unwrap_or(1);
ui.horizontal(|ui| {
- label(ui, "Tone:");
- for (i, l) in ["Shadows", "Midtones", "Highlights"].iter().enumerate() {
+ label(ui, tl!("Tone:"));
+ for (i, l) in [tl!("Shadows"), tl!("Midtones"), tl!("Highlights")].iter().enumerate() {
if ui.radio(tone_ix == i, *l).clicked() {
tone_ix = i;
}
@@ -1011,9 +1018,9 @@ fn color_balance(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mut vals = nums(v, key, [0.0; 3]);
let mut e = Edit::default();
let rows = [
- ("Cyan · Red", Color32::from_rgb(0, 190, 210), Color32::from_rgb(225, 40, 40)),
- ("Magenta · Green", Color32::from_rgb(210, 40, 190), Color32::from_rgb(40, 190, 60)),
- ("Yellow · Blue", Color32::from_rgb(230, 210, 30), Color32::from_rgb(40, 80, 230)),
+ (tl!("Cyan · Red"), Color32::from_rgb(0, 190, 210), Color32::from_rgb(225, 40, 40)),
+ (tl!("Magenta · Green"), Color32::from_rgb(210, 40, 190), Color32::from_rgb(40, 190, 60)),
+ (tl!("Yellow · Blue"), Color32::from_rgb(230, 210, 30), Color32::from_rgb(40, 80, 230)),
];
let mut changed = false;
for (i, (text, a, b)) in rows.iter().enumerate() {
@@ -1025,7 +1032,7 @@ fn color_balance(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
v[key] = json!(vals.map(f32::round));
}
let mut pl = flag(v, "preserveLuminosity", true);
- if widgets::checkbox(ui, &mut pl, "Preserve Luminosity").changed() {
+ if widgets::checkbox(ui, &mut pl, tl!("Preserve Luminosity")).changed() {
v["preserveLuminosity"] = json!(pl);
e.add(Edit::discrete(true));
}
@@ -1050,7 +1057,7 @@ fn black_white(ui: &mut egui::Ui, v: &mut Value) -> Edit {
ui.add_space(2.0);
ui.horizontal(|ui| {
let mut on = flag(v, "tint", false);
- if widgets::checkbox(ui, &mut on, "Tint").changed() {
+ if widgets::checkbox(ui, &mut on, tl!("Tint")).changed() {
v["tint"] = json!(on);
e.add(Edit::discrete(true));
}
@@ -1060,7 +1067,7 @@ fn black_white(ui: &mut egui::Ui, v: &mut Value) -> Edit {
v["tintColor"] = json!(adjust_params::hex(c));
}
e.add(r);
- if widgets::secondary_button(ui, "Default", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Default"), 0.0).clicked() {
for (i, key) in HUE_RANGES.iter().enumerate() {
v[*key] = json!(adjust_params::BW_DEFAULTS[i]);
}
@@ -1081,7 +1088,7 @@ fn photo_filter(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mode_id = cx.mem.with("pf-mode");
let mut use_color: bool = ui.data(|d| d.get_temp(mode_id)).unwrap_or(preset.is_none());
ui.horizontal(|ui| {
- if ui.radio(!use_color, "Filter:").clicked() {
+ if ui.radio(!use_color, tl!("Filter:")).clicked() {
use_color = false;
}
let mut sel = preset.unwrap_or("custom").to_string();
@@ -1097,7 +1104,7 @@ fn photo_filter(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
}
});
ui.horizontal(|ui| {
- if ui.radio(use_color, "Color:").clicked() {
+ if ui.radio(use_color, tl!("Color:")).clicked() {
use_color = true;
}
let r = ui.add_enabled_ui(use_color, |ui| color_button(ui, &mut c)).inner;
@@ -1107,9 +1114,9 @@ fn photo_filter(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
e.add(r);
});
ui.data_mut(|d| d.insert_temp(mode_id, use_color));
- e.add(sliders(ui, v, &[("density", "Density", 0.0, 100.0, 25.0, "%")]));
+ e.add(sliders(ui, v, &[("density", tl!("Density"), 0.0, 100.0, 25.0, "%")]));
let mut pl = flag(v, "preserveLuminosity", true);
- if widgets::checkbox(ui, &mut pl, "Preserve Luminosity").changed() {
+ if widgets::checkbox(ui, &mut pl, tl!("Preserve Luminosity")).changed() {
v["preserveLuminosity"] = json!(pl);
e.add(Edit::discrete(true));
}
@@ -1124,12 +1131,12 @@ fn channel_mixer(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mono = flag(v, "monochrome", false);
let out_id = cx.mem.with("cm-out");
let mut out: usize = ui.data(|d| d.get_temp(out_id)).unwrap_or(0);
- let outs: &[(usize, &str)] = if mono { &[(0, "Gray")] } else { &[(0, "Red"), (1, "Green"), (2, "Blue")] };
+ let outs: &[(usize, &str)] = if mono { &[(0, tl!("Gray"))] } else { &[(0, tl!("Red")), (1, tl!("Green")), (2, tl!("Blue"))] };
if out >= outs.len() {
out = 0;
}
ui.horizontal(|ui| {
- label(ui, "Output Channel:");
+ label(ui, tl!("Output Channel:"));
widgets::dropdown(ui, &format!("{out_id:?}"), &mut out, outs, 110.0);
});
ui.data_mut(|d| d.insert_temp(out_id, out));
@@ -1138,25 +1145,25 @@ fn channel_mixer(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mut row = nums(v, key, if mono { nums(v, "red", identity) } else { identity });
let mut e = Edit::default();
let mut changed = false;
- for (i, (text, c)) in [("Red", [225, 50, 50]), ("Green", [50, 190, 70]), ("Blue", [60, 100, 235])].iter().enumerate() {
+ for (i, (text, c)) in [(tl!("Red"), [225, 50, 50]), (tl!("Green"), [50, 190, 70]), (tl!("Blue"), [60, 100, 235])].iter().enumerate() {
let r = gradient_slider(ui, text, &mut row[i], -200.0..=200.0, "%", Color32::BLACK, Color32::from_rgb(c[0], c[1], c[2]));
changed |= r.changed;
e.add(r);
}
let total = row[0] + row[1] + row[2];
ui.horizontal(|ui| {
- label(ui, "Total:");
+ label(ui, tl!("Total:"));
let warn = total > 100.0;
ui.label(RichText::new(format!("{total:+.0}%")).font(crate::theme::mono(12.0)).color(if warn { t.warning } else { t.text }));
});
- let r = widgets::slider_row(ui, "Constant", &mut row[3], -200.0..=200.0, "%", None);
+ let r = widgets::slider_row(ui, tl!("Constant"), &mut row[3], -200.0..=200.0, "%", None);
changed |= r.changed();
e.add(Edit::of(&r));
if changed {
v[key] = json!(row.map(f32::round));
}
let mut m = mono;
- if widgets::checkbox(ui, &mut m, "Monochrome").changed() {
+ if widgets::checkbox(ui, &mut m, tl!("Monochrome")).changed() {
v["monochrome"] = json!(m);
if m {
v["gray"] = json!([40.0, 40.0, 20.0, 0.0]);
@@ -1221,16 +1228,16 @@ fn gradient_map(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
let mut e = Edit::default();
let mut stops = read_stops(v);
let presets: [(&str, Vec<Stop>); 5] = [
- ("Black, White", vec![(0.0, [0.0; 3]), (1.0, [1.0; 3])]),
- ("Foreground to Background", vec![(0.0, cx.swatches[0]), (1.0, cx.swatches[1])]),
- ("Violet, Orange", vec![(0.0, [0.161, 0.039, 0.349]), (1.0, [1.0, 0.486, 0.0])]),
- ("Blue, Red, Yellow", vec![(0.0, [0.039, 0.0, 0.698]), (0.5, [1.0, 0.0, 0.0]), (1.0, [1.0, 0.988, 0.0])]),
- ("Copper", vec![(0.0, [0.592, 0.275, 0.102]), (0.4, [0.984, 0.847, 0.773]), (0.7, [0.424, 0.180, 0.086]), (1.0, [0.937, 0.859, 0.804])]),
+ (tl!("Black, White"), vec![(0.0, [0.0; 3]), (1.0, [1.0; 3])]),
+ (tl!("Foreground to Background"), vec![(0.0, cx.swatches[0]), (1.0, cx.swatches[1])]),
+ (tl!("Violet, Orange"), vec![(0.0, [0.161, 0.039, 0.349]), (1.0, [1.0, 0.486, 0.0])]),
+ (tl!("Blue, Red, Yellow"), vec![(0.0, [0.039, 0.0, 0.698]), (0.5, [1.0, 0.0, 0.0]), (1.0, [1.0, 0.988, 0.0])]),
+ (tl!("Copper"), vec![(0.0, [0.592, 0.275, 0.102]), (0.4, [0.984, 0.847, 0.773]), (0.7, [0.424, 0.180, 0.086]), (1.0, [0.937, 0.859, 0.804])]),
];
let mut preset = usize::MAX;
ui.horizontal(|ui| {
- label(ui, "Preset:");
- let mut opts: Vec<(usize, &str)> = vec![(usize::MAX, "Custom")];
+ label(ui, tl!("Preset:"));
+ let mut opts: Vec<(usize, &str)> = vec![(usize::MAX, tl!("Custom"))];
opts.extend(presets.iter().enumerate().map(|(i, p)| (i, p.0)));
if widgets::dropdown(ui, &format!("{:?}-gm-preset", cx.mem), &mut preset, &opts, 190.0)
&& let Some(p) = presets.get(preset)
@@ -1268,7 +1275,7 @@ fn gradient_map(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
changed = true;
}
e.add(Edit::of(&rl));
- if crate::icons::button(ui, "x", 20.0, false, "Remove stop").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Remove stop")).clicked() {
remove = Some(i);
}
});
@@ -1280,7 +1287,7 @@ fn gradient_map(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
changed = true;
e.add(Edit::discrete(true));
}
- if stops.len() < 64 && widgets::secondary_button(ui, "Add Stop", 0.0).clicked() {
+ if stops.len() < 64 && widgets::secondary_button(ui, tl!("Add Stop"), 0.0).clicked() {
// Halfway along the widest gap, in the gradient's colour there.
let mut sorted = stops.clone();
sorted.sort_by(|a, b| a.0.total_cmp(&b.0));
@@ -1294,7 +1301,7 @@ fn gradient_map(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> Edit {
e.changed = true;
}
ui.horizontal(|ui| {
- for (key, text) in [("reverse", "Reverse"), ("dither", "Dither")] {
+ for (key, text) in [("reverse", tl!("Reverse")), ("dither", tl!("Dither"))] {
let mut b = flag(v, key, false);
if widgets::checkbox(ui, &mut b, text).changed() {
v[key] = json!(b);
@@ -1327,7 +1334,7 @@ pub fn layer_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: LayerId, adj
Adjustment::SelectiveColor { .. } => return crate::adjust_ui::selective_color_editor(app, ui, id, adj),
Adjustment::ColorLookup { .. } => return crate::adjust_ui::color_lookup_editor(app, ui, id, adj),
Adjustment::Invert => {
- ui.label(RichText::new("Invert has no settings.").color(t.text_faint));
+ ui.label(RichText::new(tl!("Invert has no settings.")).color(t.text_faint));
return;
}
Adjustment::Unsupported { psd_key, .. } => {
diff --git a/crates/ui-egui/src/adjust_preview.rs b/crates/ui-egui/src/adjust_preview.rs
index 91ec1d877..392ef8ca6 100644
--- a/crates/ui-egui/src/adjust_preview.rs
+++ b/crates/ui-egui/src/adjust_preview.rs
@@ -64,7 +64,7 @@ pub fn unsupported(doc: &Document, target: LayerId) -> Option<&'static str> {
return Some("the target is clipped");
}
if photocraft_compose::blend_if_active(l, doc.mode) {
- return Some("Blend If");
+ return Some(tl!("Blend If"));
}
let shows_default = !s.format().alpha || s.default_pixel().last().is_some_and(|a| *a > 0.0);
if shows_default && !s.content_bounds().contains_rect(&doc.bounds()) {
@@ -96,7 +96,7 @@ pub fn base_document(doc: &Document, target: LayerId) -> Result<Document, String
if let Some(why) = unsupported(doc, target) {
return Err(why.into());
}
- let mut l = Layer::new("Adjustment Preview", LayerContent::Adjustment(Adjustment::Invert));
+ let mut l = Layer::new(tl!("Adjustment Preview"), LayerContent::Adjustment(Adjustment::Invert));
l.id = PREVIEW_LAYER;
l.clipped = true;
if let Some(sel) = &doc.selection {
diff --git a/crates/ui-egui/src/adjust_ui.rs b/crates/ui-egui/src/adjust_ui.rs
index 53cdf4b28..54e252906 100644
--- a/crates/ui-egui/src/adjust_ui.rs
+++ b/crates/ui-egui/src/adjust_ui.rs
@@ -36,7 +36,7 @@ pub fn selective_color_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: La
let key = egui::Id::new(("selc-range", id.0));
let mut range: usize = ui.data(|d| d.get_temp(key)).unwrap_or(0);
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Colors").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Colors")).color(t.text_dim));
let opts: Vec<(usize, &str)> = RANGE_LABELS.iter().copied().enumerate().collect();
if widgets::dropdown(ui, &format!("selc-colors-{}", id.0), &mut range, &opts, 150.0) {
ui.data_mut(|d| d.insert_temp(key, range));
@@ -45,7 +45,7 @@ pub fn selective_color_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: La
ui.add_space(4.0);
let mut live = false;
let mut commit = false;
- for (k, label) in ["Cyan", "Magenta", "Yellow", "Black"].iter().enumerate() {
+ for (k, label) in [tl!("Cyan"), tl!("Magenta"), tl!("Yellow"), tl!("Black")].iter().enumerate() {
let mut v = values[RANGES[range]][k].as_f64().unwrap_or(0.0) as f32;
let r = widgets::slider_row(ui, label, &mut v, -100.0..=100.0, "%", None);
if r.changed() {
@@ -59,7 +59,7 @@ pub fn selective_color_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: La
ui.add_space(4.0);
let mut method = values["method"].as_str().unwrap_or("relative").to_string();
ui.horizontal(|ui| {
- for (m, label) in [("relative", "Relative"), ("absolute", "Absolute")] {
+ for (m, label) in [("relative", tl!("Relative")), ("absolute", tl!("Absolute"))] {
if ui.radio(method == m, label).clicked() && method != m {
method = m.to_string();
values["method"] = json!(m);
@@ -87,7 +87,7 @@ pub fn color_lookup_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: Layer
let current =
if lut.is_none() { "none".to_string() } else { builtins.iter().find(|b| b.1 == name).map_or_else(|| "custom".to_string(), |b| b.0.to_string()) };
let custom_label = format!("{name} ({size}³)");
- let mut opts: Vec<(String, &str)> = vec![("none".into(), "Load 3D LUT…")];
+ let mut opts: Vec<(String, &str)> = vec![("none".into(), tl!("Load 3D LUT…"))];
opts.extend(builtins.iter().map(|(id, label)| (id.to_string(), *label)));
if current == "custom" {
opts.push(("custom".into(), custom_label.as_str()));
@@ -95,7 +95,7 @@ pub fn color_lookup_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: Layer
let mut sel = current.clone();
let mut params: Option<Value> = None;
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("3D LUT File").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("3D LUT File")).color(t.text_dim));
if widgets::dropdown(ui, &format!("clrl-{}", id.0), &mut sel, &opts, 170.0) && sel != current && sel != "custom" {
params = Some(json!({"lut": sel}));
}
@@ -108,14 +108,14 @@ pub fn color_lookup_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: Layer
if r.changed() {
ui.data_mut(|d| d.insert_temp(path_key, path.clone()));
}
- if widgets::secondary_button(ui, "Load", 60.0).clicked() && !path.trim().is_empty() {
+ if widgets::secondary_button(ui, tl!("Load"), 60.0).clicked() && !path.trim().is_empty() {
params = Some(json!({"file": path.trim()}));
}
});
ui.add_space(4.0);
let mut tet = *tetrahedral;
ui.horizontal(|ui| {
- for (on, label) in [(false, "Trilinear"), (true, "Tetrahedral")] {
+ for (on, label) in [(false, tl!("Trilinear")), (true, tl!("Tetrahedral"))] {
if ui.radio(tet == on, label).clicked() && tet != on {
tet = on;
params = Some(json!({"tetrahedral": on}));
@@ -123,7 +123,7 @@ pub fn color_lookup_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: Layer
}
});
let mut d = *dither;
- if widgets::toggle(ui, &mut d, "Dither").changed() {
+ if widgets::toggle(ui, &mut d, tl!("Dither")).changed() {
params = Some(json!({"dither": d}));
}
if let Some(mut p) = params {
diff --git a/crates/ui-egui/src/analysis_ui.rs b/crates/ui-egui/src/analysis_ui.rs
index 43686c432..6b9ab669e 100644
--- a/crates/ui-egui/src/analysis_ui.rs
+++ b/crates/ui-egui/src/analysis_ui.rs
@@ -403,7 +403,7 @@ pub fn draw_overlay(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform
fn readout(ui: &mut egui::Ui, label: &str, value: Option<f64>) {
let t = Tokens::get(ui.ctx());
- ui.label(RichText::new(label).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim).size(11.0));
ui.label(RichText::new(value.map_or(String::new(), |v| format!("{v:.2}"))).color(t.text).size(11.0).monospace());
ui.add_space(6.0);
}
@@ -425,12 +425,12 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
readout(ui, "L1:", g("l1").map(|v| v * f));
readout(ui, "L2:", g("l2").map(|v| v * f));
crate::widgets::vline(ui, 22.0);
- crate::widgets::checkbox(ui, &mut app.ui.analysis.use_measurement_scale, "Use Measurement Scale");
+ crate::widgets::checkbox(ui, &mut app.ui.analysis.use_measurement_scale, tl!("Use Measurement Scale"));
let has = doc.measurement.ruler.is_some();
- if ui.add_enabled_ui(has, |ui| crate::widgets::secondary_button(ui, "Straighten Layer", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(has, |ui| crate::widgets::secondary_button(ui, tl!("Straighten Layer"), 0.0)).inner.clicked() {
let _ = app.run("image.analysis.straightenLayer", json!({}));
}
- if ui.add_enabled_ui(has, |ui| crate::widgets::secondary_button(ui, "Clear", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(has, |ui| crate::widgets::secondary_button(ui, tl!("Clear"), 0.0)).inner.clicked() {
let _ = app.run("image.analysis.rulerTool", json!({"clear": true}));
}
true
@@ -438,7 +438,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
Tool::Count => {
let t = Tokens::get(ui.ctx());
let m = &doc.measurement;
- ui.label(RichText::new(format!("Count: {}", m.count_total())).color(t.text).size(11.0));
+ ui.label(RichText::new(crate::i18n::fmt(tl!("Count: {n}"), &[("n", &m.count_total().to_string())])).color(t.text).size(11.0));
crate::widgets::vline(ui, 22.0);
if !m.count_groups.is_empty() {
let mut gi = m.active_count_group.min(m.count_groups.len() - 1);
@@ -448,29 +448,29 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
}
let g = &m.count_groups[gi];
let eye = if g.visible { "eye" } else { "eye-off" };
- if crate::icons::button(ui, eye, 22.0, false, "Toggle count group visibility").clicked() {
+ if crate::icons::button(ui, eye, 22.0, false, tl!("Toggle count group visibility")).clicked() {
let _ = app.run("count.setGroup", json!({"group": gi, "visible": !g.visible}));
}
let mut rgb = g.color.to_rgb();
if ui.color_edit_button_rgb(&mut rgb).changed() {
let _ = app.run("count.setGroup", json!({"group": gi, "color": [rgb[0], rgb[1], rgb[2]], "coalesce": "count-color"}));
}
- if crate::icons::button(ui, "trash", 22.0, false, "Delete count group").clicked() {
+ if crate::icons::button(ui, "trash", 22.0, false, tl!("Delete count group")).clicked() {
let _ = app.run("count.deleteGroup", json!({"group": gi}));
}
}
- if crate::icons::button(ui, "folder-plus", 22.0, false, "Create a new count group").clicked() {
+ if crate::icons::button(ui, "folder-plus", 22.0, false, tl!("Create a new count group")).clicked() {
let _ = app.run("count.newGroup", json!({}));
}
- if crate::widgets::secondary_button(ui, "Clear", 0.0).clicked() && m.count_total() > 0 {
+ if crate::widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() && m.count_total() > 0 {
let _ = app.run("count.clear", json!({}));
}
if let Some(g) = m.count_groups.get(m.active_count_group) {
crate::widgets::vline(ui, 22.0);
let (mut ms, mut ls) = (g.marker_size as f32, g.label_size as f32);
- ui.label(RichText::new("Marker Size").color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!("Marker Size")).color(t.text_dim).size(11.0));
let a = crate::widgets::value_field(ui, &mut ms, 1.0..=10.0, "", 40.0).changed();
- ui.label(RichText::new("Label Size").color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!("Label Size")).color(t.text_dim).size(11.0));
let b = crate::widgets::value_field(ui, &mut ls, 8.0..=72.0, "", 44.0).changed();
if a || b {
let _ = app.run("count.setGroup", json!({"markerSize": ms.round(), "labelSize": ls.round()}));
@@ -480,15 +480,15 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
}
Tool::Note => {
let t = Tokens::get(ui.ctx());
- ui.label(RichText::new("Author:").color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!("Author:")).color(t.text_dim).size(11.0));
ui.add(egui::TextEdit::singleline(&mut app.ui.analysis.note_author).desired_width(120.0));
- ui.label(RichText::new("Color:").color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!("Color:")).color(t.text_dim).size(11.0));
ui.color_edit_button_rgb(&mut app.ui.analysis.note_color);
- if ui.add_enabled_ui(!doc.notes.is_empty(), |ui| crate::widgets::secondary_button(ui, "Clear All", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(!doc.notes.is_empty(), |ui| crate::widgets::secondary_button(ui, tl!("Clear All"), 0.0)).inner.clicked() {
let _ = app.run("notes.delete", json!({"all": true}));
app.ui.analysis.note_selected = None;
}
- if crate::icons::button(ui, "message-square", 22.0, app.ui.analysis.notes, "Show or hide the Notes panel").clicked() {
+ if crate::icons::button(ui, "message-square", 22.0, app.ui.analysis.notes, tl!("Show or hide the Notes panel")).clicked() {
app.ui.analysis.notes = !app.ui.analysis.notes;
}
true
@@ -513,9 +513,9 @@ pub(crate) fn title_row(ui: &mut egui::Ui, title: &str) -> bool {
let t = Tokens::get(ui.ctx());
let mut close = false;
ui.horizontal(|ui| {
- ui.label(RichText::new(title).color(t.text).size(12.0).strong());
+ ui.label(RichText::new(tl!(&title)).color(t.text).size(12.0).strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
close = true;
}
});
@@ -553,23 +553,23 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
let rows = app.session.analysis.log.clone();
let mut sel = app.ui.analysis.log_selected.clone();
let t = Tokens::get(ctx);
- panel_window(app, ctx, "measurement-log", "Measurement Log", vec2(-300.0, 470.0), 620.0, |ui| {
- close = title_row(ui, "Measurement Log");
+ panel_window(app, ctx, "measurement-log", tl!("Measurement Log"), vec2(-300.0, 470.0), 620.0, |ui| {
+ close = title_row(ui, tl!("Measurement Log"));
ui.horizontal(|ui| {
- if crate::widgets::secondary_button(ui, "Record Measurements", 0.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Record Measurements"), 0.0).clicked() {
act = Some(("record", Value::Null));
}
- if crate::widgets::secondary_button(ui, "Select All", 0.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Select All"), 0.0).clicked() {
sel = rows.iter().map(|r| r.id).collect();
}
- if crate::widgets::secondary_button(ui, "Deselect All", 0.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Deselect All"), 0.0).clicked() {
sel.clear();
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 22.0, false, "Delete selected measurements").clicked() && !sel.is_empty() {
+ if crate::icons::button(ui, "trash", 22.0, false, tl!("Delete selected measurements")).clicked() && !sel.is_empty() {
act = Some(("measurementLog.delete", json!({"rows": sel.clone()})));
}
- if crate::icons::button(ui, "file", 22.0, false, "Export selected measurements (CSV)").clicked() {
+ if crate::icons::button(ui, "file", 22.0, false, tl!("Export selected measurements (CSV)")).clicked() {
act = Some(("export", json!(sel.clone())));
}
});
@@ -645,15 +645,15 @@ fn notes_panel(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut edit: Option<Value> = None;
let mut delete = false;
let t = Tokens::get(ctx);
- panel_window(app, ctx, "notes-panel", "Notes", vec2(-40.0, 300.0), 260.0, |ui| {
- close = title_row(ui, "Notes");
+ panel_window(app, ctx, "notes-panel", tl!("Notes"), vec2(-40.0, 300.0), 260.0, |ui| {
+ close = title_row(ui, tl!("Notes"));
match sel {
None => {
- ui.label(RichText::new("Click with the Note tool to add a note.").color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!("Click with the Note tool to add a note.")).color(t.text_dim).size(11.0));
}
Some(i) => {
let note = &notes[i];
- ui.label(RichText::new(if note.author.is_empty() { "No author".to_string() } else { note.author.clone() }).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(if note.author.is_empty() { tl!("No author").to_string() } else { note.author.clone() }).color(t.text_dim).size(11.0));
let mut text = note.text.clone();
if ui.add(egui::TextEdit::multiline(&mut text).desired_rows(6).desired_width(f32::INFINITY)).changed() {
edit = Some(json!({"index": i, "text": text, "coalesce": format!("note-{i}")}));
@@ -662,15 +662,15 @@ fn notes_panel(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
crate::widgets::hairline(ui);
ui.horizontal(|ui| {
- if ui.add_enabled_ui(n > 1, |ui| crate::icons::button(ui, "chevrons-left", 22.0, false, "Previous note")).inner.clicked() {
+ if ui.add_enabled_ui(n > 1, |ui| crate::icons::button(ui, "chevrons-left", 22.0, false, tl!("Previous note"))).inner.clicked() {
sel = sel.map(|i| (i + n - 1) % n);
}
- if ui.add_enabled_ui(n > 1, |ui| crate::icons::button(ui, "chevrons-right", 22.0, false, "Next note")).inner.clicked() {
+ if ui.add_enabled_ui(n > 1, |ui| crate::icons::button(ui, "chevrons-right", 22.0, false, tl!("Next note"))).inner.clicked() {
sel = sel.map(|i| (i + 1) % n);
}
ui.label(RichText::new(sel.map_or("0 of 0".into(), |i| format!("{} of {n}", i + 1))).color(t.text_dim).size(11.0));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if ui.add_enabled_ui(sel.is_some(), |ui| crate::icons::button(ui, "trash", 22.0, false, "Delete note")).inner.clicked() {
+ if ui.add_enabled_ui(sel.is_some(), |ui| crate::icons::button(ui, "trash", 22.0, false, tl!("Delete note"))).inner.clicked() {
delete = true;
}
});
@@ -694,7 +694,7 @@ fn notes_panel(app: &mut PhotocraftApp, ctx: &egui::Context) {
fn num_field(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str, range: std::ops::RangeInclusive<f32>, suffix: &str) {
let t = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
- ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new(label).color(t.text_dim).size(11.0)));
+ ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new(tl!(&label)).color(t.text_dim).size(11.0)));
let mut v = f.get(key).and_then(Value::as_f64).unwrap_or(0.0) as f32;
if crate::widgets::value_field(ui, &mut v, range, suffix, 80.0).changed() {
f.insert(key.into(), json!(v));
@@ -705,7 +705,7 @@ fn num_field(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &s
fn choice(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str, opts: &[(&str, &str)]) {
let t = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
- ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new(label).color(t.text_dim).size(11.0)));
+ ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new(tl!(&label)).color(t.text_dim).size(11.0)));
let mut cur = f.get(key).and_then(Value::as_str).unwrap_or(opts[0].0).to_string();
let list: Vec<(String, &str)> = opts.iter().map(|(k, l)| (k.to_string(), *l)).collect();
if crate::widgets::dropdown(ui, &format!("an-{key}"), &mut cur, &list, 120.0) {
@@ -752,18 +752,18 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
.anchor(Align2::CENTER_CENTER, vec2(0.0, 0.0))
.frame(float_frame(&t))
.show(ctx, |ui| {
- ui.label(RichText::new(title).color(t.text).size(13.0).strong());
+ ui.label(RichText::new(tl!(&title)).color(t.text).size(13.0).strong());
crate::widgets::hairline(ui);
ui.add_space(6.0);
match kind.as_str() {
"scale" => {
- choice(ui, &mut f, "preset", "Presets:", &[("custom", "Custom"), ("default", "Default")]);
+ choice(ui, &mut f, "preset", tl!("Presets:"), &[("custom", tl!("Custom")), ("default", tl!("Default"))]);
let custom = f.get("preset").and_then(Value::as_str) != Some("default");
ui.add_enabled_ui(custom, |ui| {
- num_field(ui, &mut f, "pixelLength", "Pixel Length:", 0.001..=1e7, "");
- num_field(ui, &mut f, "logicalLength", "Logical Length:", 0.0001..=1e7, "");
+ num_field(ui, &mut f, "pixelLength", tl!("Pixel Length:"), 0.001..=1e7, "");
+ num_field(ui, &mut f, "logicalLength", tl!("Logical Length:"), 0.0001..=1e7, "");
ui.horizontal(|ui| {
- ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new("Logical Units:").color(t.text_dim).size(11.0)));
+ ui.add_sized(vec2(110.0, 18.0), egui::Label::new(RichText::new(tl!("Logical Units:")).color(t.text_dim).size(11.0)));
let mut u = f.get("units").and_then(Value::as_str).unwrap_or("pixels").to_string();
if ui.add(egui::TextEdit::singleline(&mut u).desired_width(80.0)).changed() {
f.insert("units".into(), json!(u));
@@ -773,13 +773,13 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
let (pl, ll) = (f.get("pixelLength").and_then(Value::as_f64).unwrap_or(1.0), f.get("logicalLength").and_then(Value::as_f64).unwrap_or(1.0));
let u = f.get("units").and_then(Value::as_str).unwrap_or("pixels");
let text = if custom { format!("{pl} pixels = {ll:.4} {u}") } else { "1 pixels = 1.0000 pixels".into() };
- ui.label(RichText::new(text).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!(&text)).color(t.text_dim).size(11.0));
}
"dataPoints" => {
ui.horizontal_top(|ui| {
- for (source, label) in [("selection", "Selections"), ("ruler", "Ruler Tool"), ("count", "Count Tool")] {
+ for (source, label) in [("selection", tl!("Selections")), ("ruler", tl!("Ruler Tool")), ("count", tl!("Count Tool"))] {
ui.vertical(|ui| {
- ui.label(RichText::new(label).color(t.text).size(11.0).strong());
+ ui.label(RichText::new(tl!(&label)).color(t.text).size(11.0).strong());
let mut list: Vec<String> = f
.get(source)
.and_then(Value::as_array)
@@ -807,23 +807,23 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
_ => {
let units = f.get("units").and_then(Value::as_str).unwrap_or("pixels").to_string();
- num_field(ui, &mut f, "length", "Length:", 0.0001..=1e7, &units);
- num_field(ui, &mut f, "fontSize", "Font Size:", 1.0..=1000.0, "pt");
+ num_field(ui, &mut f, "length", tl!("Length:"), 0.0001..=1e7, &units);
+ num_field(ui, &mut f, "fontSize", tl!("Font Size:"), 1.0..=1000.0, "pt");
let mut show = f.get("displayText").and_then(Value::as_bool).unwrap_or(true);
- if crate::widgets::checkbox(ui, &mut show, "Display Text").changed() {
+ if crate::widgets::checkbox(ui, &mut show, tl!("Display Text")).changed() {
f.insert("displayText".into(), json!(show));
}
- choice(ui, &mut f, "textPosition", "Text Position:", &[("bottom", "Bottom"), ("top", "Top")]);
- choice(ui, &mut f, "color", "Color:", &[("black", "Black"), ("white", "White")]);
+ choice(ui, &mut f, "textPosition", tl!("Text Position:"), &[("bottom", tl!("Bottom")), ("top", tl!("Top"))]);
+ choice(ui, &mut f, "color", tl!("Color:"), &[("black", tl!("Black")), ("white", tl!("White"))]);
}
}
ui.add_space(8.0);
ui.horizontal(|ui| {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::widgets::primary_button(ui, "OK", 70.0).clicked() {
+ if crate::widgets::primary_button(ui, tl!("OK"), 70.0).clicked() {
result = Some(true);
}
- if crate::widgets::secondary_button(ui, "Cancel", 70.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Cancel"), 70.0).clicked() {
result = Some(false);
}
});
diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rs
index 6dd66a9df..68a228a94 100644
--- a/crates/ui-egui/src/artboard_ui.rs
+++ b/crates/ui-egui/src/artboard_ui.rs
@@ -76,19 +76,19 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
let t = Tokens::get(ui.ctx());
let key = |k: &str| format!("artboard-{}-{k}", layer.id.0);
let mut edit: Option<Value> = None;
- ui.label(egui::RichText::new("Artboard").font(crate::theme::semibold(12.0)).color(t.text));
+ ui.label(egui::RichText::new(tl!("Artboard")).font(crate::theme::semibold(12.0)).color(t.text));
ui.add_space(4.0);
let mut preset = a.preset.clone();
- let mut opts: Vec<(String, &str)> = vec![(String::new(), "Custom")];
+ let mut opts: Vec<(String, &str)> = vec![(String::new(), tl!("Custom"))];
opts.extend(photocraft_engine::artboard_cmds::PRESETS.iter().map(|(n, _, _)| (n.to_string(), *n)));
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Size").color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!("Size")).color(t.text_dim).size(12.0));
if crate::widgets::dropdown(ui, &key("preset"), &mut preset, &opts, 150.0) && !preset.is_empty() {
edit = Some(json!({"layer": layer.id.0, "preset": preset}));
}
});
let num = |ui: &mut egui::Ui, label: &str, v: &mut f32, range: std::ops::RangeInclusive<f32>| -> bool {
- ui.label(egui::RichText::new(label).color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim).size(12.0));
crate::widgets::value_field(ui, v, range, "px", 64.0).changed()
};
let r = a.rect;
@@ -110,11 +110,11 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
});
ui.add_space(4.0);
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Artboard Background Color").color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!("Artboard Background Color")).color(t.text_dim).size(12.0));
});
ui.horizontal(|ui| {
let mut bg = a.background.name().to_string();
- let opts = [("white".to_string(), "White"), ("black".to_string(), "Black"), ("transparent".to_string(), "Transparent"), ("custom".to_string(), "Other…")];
+ let opts = [("white".to_string(), tl!("White")), ("black".to_string(), tl!("Black")), ("transparent".to_string(), tl!("Transparent")), ("custom".to_string(), tl!("Other…"))];
if crate::widgets::dropdown(ui, &key("bg"), &mut bg, &opts, 120.0) {
edit = Some(json!({"layer": layer.id.0, "background": bg}));
}
diff --git a/crates/ui-egui/src/brush_panel.rs b/crates/ui-egui/src/brush_panel.rs
index f438094e7..3e7459f10 100644
--- a/crates/ui-egui/src/brush_panel.rs
+++ b/crates/ui-egui/src/brush_panel.rs
@@ -273,7 +273,8 @@ fn section_list(app: &mut PhotocraftApp, ui: &mut egui::Ui, b: &mut BrushSetting
let tint = if *lock { t.text } else { t.text_faint };
icons::paint(ui, lr, if *lock { "lock" } else { "lock-open" }, 12.0, tint);
}
- let tip = if *lock { "Unlock: picking a preset replaces these settings" } else { "Lock: keep these settings when picking another preset" };
+ let tip =
+ if *lock { tl!("Unlock: picking a preset replaces these settings") } else { tl!("Lock: keep these settings when picking another preset") };
if lresp.on_hover_text(tip).clicked() {
*lock = !*lock;
lock_clicked = true;
@@ -318,11 +319,11 @@ fn settings_tab(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let tex = brush_preview::stroke_texture(ui.ctx(), "settings-strip", &b, STRIP.0, STRIP.1, t.text);
ui.painter().image(tex.id(), r, full_uv(), Color32::WHITE);
ui.vertical(|ui| {
- if icons::button(ui, "square-plus", 24.0, false, "Create new brush from these settings").clicked() {
+ if icons::button(ui, "square-plus", 24.0, false, tl!("Create new brush from these settings")).clicked() {
let name = new_preset_name(&app.session.tools.presets);
run_or_status(app, "brush.presets.save", json!({ "name": name, "brush": serde_json::to_value(&b).unwrap_or(Value::Null) }));
}
- if icons::button(ui, "undo-2", 24.0, false, "Reset the brush to the defaults").clicked() {
+ if icons::button(ui, "undo-2", 24.0, false, tl!("Reset the brush to the defaults")).clicked() {
b = BrushSettings { color: b.color, background: b.background, smoothing: b.smoothing.clone(), locks: b.locks.clone(), ..Default::default() };
}
});
@@ -343,7 +344,7 @@ pub fn window(app: &mut PhotocraftApp, ctx: &egui::Context) {
.inner_margin(egui::Margin::same(10));
let canvas = app.last_canvas_rect;
let mut open = true;
- egui::Window::new("Brush Settings")
+ egui::Window::new(tl!("Brush Settings"))
.id(egui::Id::new("brush-settings"))
.title_bar(false)
.resizable(false)
@@ -353,14 +354,14 @@ pub fn window(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.set_width(WIDTH);
ui.horizontal(|ui| {
let mut tab = app.ui.brush_tab;
- for (i, name) in ["Brush Settings", "Brushes"].iter().enumerate() {
+ for (i, name) in [tl!("Brush Settings"), tl!("Brushes")].iter().enumerate() {
if widgets::pill_tab(ui, name, tab == i).clicked() {
tab = i;
}
}
app.ui.brush_tab = tab;
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
open = false;
}
});
diff --git a/crates/ui-egui/src/brush_picker.rs b/crates/ui-egui/src/brush_picker.rs
index 52aea2b95..184dc5a84 100644
--- a/crates/ui-egui/src/brush_picker.rs
+++ b/crates/ui-egui/src/brush_picker.rs
@@ -94,7 +94,7 @@ pub fn body(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset]) -
ui.set_width(WIDTH);
// Size: value field plus a logarithmic slider (small sizes get most of the travel).
ui.horizontal(|ui| {
- ui.label(RichText::new("Size").color(t.text_dim));
+ ui.label(RichText::new(tl!("Size")).color(t.text_dim));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let mut size = b.size;
if widgets::value_field(ui, &mut size, 1.0..=5000.0, "px", 72.0).changed() {
@@ -117,7 +117,7 @@ pub fn body(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset]) -
ui.horizontal(|ui| {
icons::paint(ui, egui::Rect::from_min_size(ui.cursor().min + vec2(0.0, 3.0), vec2(16.0, 16.0)), "search", 14.0, t.text_faint);
ui.add_space(20.0);
- ui.add(egui::TextEdit::singleline(&mut view.filter).hint_text("Search Brushes").desired_width(WIDTH - 90.0).id_salt("brush-picker-search"));
+ ui.add(egui::TextEdit::singleline(&mut view.filter).hint_text(tl!("Search Brushes")).desired_width(WIDTH - 90.0).id_salt("brush-picker-search"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if named(icons::button(ui, "square-plus", 24.0, false, "Create new brush preset from the current settings"), "New Brush Preset").clicked() {
pick = Some(Pick::NewPreset);
@@ -157,7 +157,7 @@ pub fn body(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset]) -
ui.add_space(3.0);
}
if presets.is_empty() {
- ui.label(RichText::new("No brush presets").color(t.text_faint));
+ ui.label(RichText::new(tl!("No brush presets")).color(t.text_faint));
}
});
ui.data_mut(|d| d.insert_temp(view_id(), view));
diff --git a/crates/ui-egui/src/brush_resize.rs b/crates/ui-egui/src/brush_resize.rs
index 9613d5ca5..44b33cf5a 100644
--- a/crates/ui-egui/src/brush_resize.rs
+++ b/crates/ui-egui/src/brush_resize.rs
@@ -116,7 +116,7 @@ pub fn draw(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform) -> boo
painter.ctx(),
"brush-resize-readout",
at,
- ["Diameter:", "Hardness:"],
+ [tl!("Diameter:"), tl!("Hardness:")],
[format!("{} px", b.size.round() as i64), format!("{}%", (b.hardness * 100.0).round() as i64)],
);
true
diff --git a/crates/ui-egui/src/brush_sections.rs b/crates/ui-egui/src/brush_sections.rs
index 8f90e32f2..8673c3192 100644
--- a/crates/ui-egui/src/brush_sections.rs
+++ b/crates/ui-egui/src/brush_sections.rs
@@ -71,12 +71,12 @@ fn dim(ui: &mut egui::Ui, s: &str) {
/// direction controls (Photoshop only has them for Angle Jitter).
fn control_row(ui: &mut egui::Ui, id: &str, d: &mut Dynamic, angle: bool) {
ui.horizontal(|ui| {
- dim(ui, "Control:");
+ dim(ui, tl!("Control:"));
let n = if angle || matches!(d.control, Control::InitialDirection | Control::Direction) { 8 } else { 6 };
widgets::dropdown(ui, id, &mut d.control, &CONTROLS[..n], 130.0);
if d.control == Control::Fade {
let mut steps = d.fade_steps as f32;
- if widgets::value_field(ui, &mut steps, 1.0..=9999.0, "", 56.0).on_hover_text("Fade steps").changed() {
+ if widgets::value_field(ui, &mut steps, 1.0..=9999.0, "", 56.0).on_hover_text(tl!("Fade steps")).changed() {
d.fade_steps = steps.round().clamp(1.0, 9999.0) as u32;
}
}
@@ -106,7 +106,7 @@ fn size_row(ui: &mut egui::Ui, label: &str, size: &mut f32, max: f32, restore: O
*size = s.round().clamp(1.0, max);
}
if let Some(orig) = restore
- && crate::icons::button(ui, "undo-2", 22.0, false, "Restore original size").clicked()
+ && crate::icons::button(ui, "undo-2", 22.0, false, tl!("Restore original size")).clicked()
{
*size = orig.clamp(1.0, max);
}
@@ -211,7 +211,7 @@ fn ellipse_widget(ui: &mut egui::Ui, angle: &mut f32, roundness: &mut f32) -> bo
p.circle_filled(c + h, 4.0, Color32::WHITE);
p.circle_stroke(c + h, 4.0, Stroke::new(1.0, t.accent));
}
- let _ = resp.on_hover_text("Drag the arrow to set the angle, the dots to set the roundness");
+ let _ = resp.on_hover_text(tl!("Drag the arrow to set the angle, the dots to set the roundness"));
changed
}
@@ -295,11 +295,11 @@ fn tip_shape(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset])
TipShape::Sampled(g) => Some(g.width.max(g.height) as f32),
TipShape::Round => None,
};
- size_row(ui, "Size", &mut b.size, 5000.0, orig);
+ size_row(ui, tl!("Size"), &mut b.size, 5000.0, orig);
ui.horizontal(|ui| {
- widgets::checkbox(ui, &mut b.flip_x, "Flip X");
+ widgets::checkbox(ui, &mut b.flip_x, tl!("Flip X"));
ui.add_space(8.0);
- widgets::checkbox(ui, &mut b.flip_y, "Flip Y");
+ widgets::checkbox(ui, &mut b.flip_y, tl!("Flip Y"));
});
ui.add_space(4.0);
ui.horizontal(|ui| {
@@ -308,7 +308,7 @@ fn tip_shape(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset])
ui.vertical(|ui| {
ui.add_space(10.0);
ui.horizontal(|ui| {
- ui.allocate_ui_with_layout(vec2(72.0, 24.0), egui::Layout::left_to_right(egui::Align::Center), |ui| dim(ui, "Angle:"));
+ ui.allocate_ui_with_layout(vec2(72.0, 24.0), egui::Layout::left_to_right(egui::Align::Center), |ui| dim(ui, tl!("Angle:")));
let mut a = b.angle;
if widgets::value_field(ui, &mut a, -180.0..=180.0, "°", 70.0).changed() {
b.angle = a.round().clamp(-180.0, 180.0);
@@ -316,7 +316,7 @@ fn tip_shape(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset])
});
ui.add_space(6.0);
ui.horizontal(|ui| {
- ui.allocate_ui_with_layout(vec2(72.0, 24.0), egui::Layout::left_to_right(egui::Align::Center), |ui| dim(ui, "Roundness:"));
+ ui.allocate_ui_with_layout(vec2(72.0, 24.0), egui::Layout::left_to_right(egui::Align::Center), |ui| dim(ui, tl!("Roundness:")));
let mut r = (b.roundness * 100.0).round();
if widgets::value_field(ui, &mut r, 1.0..=100.0, "%", 70.0).changed() {
b.roundness = (r.round() / 100.0).clamp(0.01, 1.0);
@@ -326,47 +326,47 @@ fn tip_shape(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset])
});
ui.add_space(6.0);
ui.add_enabled_ui(matches!(b.tip, TipShape::Round), |ui| {
- pct(ui, "Hardness", &mut b.hardness, 1.0);
+ pct(ui, tl!("Hardness"), &mut b.hardness, 1.0);
});
// Unchecked, the pointer's speed sets the spacing (Photoshop).
- widgets::checkbox(ui, &mut b.spacing_enabled, "Spacing").on_hover_text("Off: the speed of the pointer sets the spacing");
+ widgets::checkbox(ui, &mut b.spacing_enabled, tl!("Spacing")).on_hover_text(tl!("Off: the speed of the pointer sets the spacing"));
ui.add_space(2.0);
let on = b.spacing_enabled;
- ui.add_enabled_ui(on, |ui| signed_pct(ui, "Spacing", &mut b.spacing, 0.01, 10.0));
+ ui.add_enabled_ui(on, |ui| signed_pct(ui, tl!("Spacing"), &mut b.spacing, 0.01, 10.0));
}
fn shape_dynamics(ui: &mut egui::Ui, b: &mut BrushSettings) {
let sd = &mut b.shape_dynamics;
- pct(ui, "Size Jitter", &mut sd.size.jitter, 1.0);
+ pct(ui, tl!("Size Jitter"), &mut sd.size.jitter, 1.0);
control_row(ui, "brush-size-ctl", &mut sd.size, false);
- pct(ui, "Minimum Diameter", &mut sd.size.minimum, 1.0);
+ pct(ui, tl!("Minimum Diameter"), &mut sd.size.minimum, 1.0);
// Tilt Scale applies with the size control on Pen Tilt (greyed out otherwise, like Photoshop).
let tilt = sd.size.control == Control::PenTilt;
- ui.add_enabled_ui(tilt, |ui| pct(ui, "Tilt Scale", &mut sd.tilt_scale, 2.0));
+ ui.add_enabled_ui(tilt, |ui| pct(ui, tl!("Tilt Scale"), &mut sd.tilt_scale, 2.0));
ui.add_space(6.0);
- dynamic(ui, "brush-angle-ctl", "Angle Jitter", &mut sd.angle, 1.0, None, true);
- dynamic(ui, "brush-round-ctl", "Roundness Jitter", &mut sd.roundness, 1.0, Some("Minimum Roundness"), false);
+ dynamic(ui, "brush-angle-ctl", tl!("Angle Jitter"), &mut sd.angle, 1.0, None, true);
+ dynamic(ui, "brush-round-ctl", tl!("Roundness Jitter"), &mut sd.roundness, 1.0, Some(tl!("Minimum Roundness")), false);
ui.horizontal(|ui| {
- widgets::checkbox(ui, &mut sd.flip_x_jitter, "Flip X Jitter");
+ widgets::checkbox(ui, &mut sd.flip_x_jitter, tl!("Flip X Jitter"));
ui.add_space(8.0);
- widgets::checkbox(ui, &mut sd.flip_y_jitter, "Flip Y Jitter");
+ widgets::checkbox(ui, &mut sd.flip_y_jitter, tl!("Flip Y Jitter"));
});
ui.add_space(2.0);
- widgets::checkbox(ui, &mut sd.brush_projection, "Brush Projection").on_hover_text("Apply the pen's tilt and rotation to the tip shape");
+ widgets::checkbox(ui, &mut sd.brush_projection, tl!("Brush Projection")).on_hover_text(tl!("Apply the pen's tilt and rotation to the tip shape"));
}
fn scattering(ui: &mut egui::Ui, b: &mut BrushSettings) {
let sc = &mut b.scattering;
- pct(ui, "Scatter", &mut sc.scatter.jitter, 10.0);
- widgets::checkbox(ui, &mut sc.both_axes, "Both Axes");
+ pct(ui, tl!("Scatter"), &mut sc.scatter.jitter, 10.0);
+ widgets::checkbox(ui, &mut sc.both_axes, tl!("Both Axes"));
ui.add_space(2.0);
control_row(ui, "brush-scatter-ctl", &mut sc.scatter, false);
ui.add_space(6.0);
let mut c = sc.count as f32;
- if num(ui, "Count", &mut c, 1.0..=16.0, "") {
+ if num(ui, tl!("Count"), &mut c, 1.0..=16.0, "") {
sc.count = c as u32;
}
- dynamic(ui, "brush-count-ctl", "Count Jitter", &mut sc.count_jitter, 1.0, None, false);
+ dynamic(ui, "brush-count-ctl", tl!("Count Jitter"), &mut sc.count_jitter, 1.0, None, false);
}
/// The pattern swatch: the (adjusted) texture as the stroke sees it.
@@ -431,7 +431,7 @@ fn texture(ui: &mut egui::Ui, b: &mut BrushSettings) {
};
let mut opts: Vec<(Option<PatternStyle>, &str)> = PATTERNS.iter().map(|(s, l)| (Some(*s), *l)).collect();
if style.is_none() {
- opts.push((None, "Custom"));
+ opts.push((None, tl!("Custom")));
}
if widgets::dropdown(ui, "brush-pattern", &mut style, &opts, 110.0)
&& let Some(s) = style
@@ -443,38 +443,38 @@ fn texture(ui: &mut egui::Ui, b: &mut BrushSettings) {
tx.pattern = Pattern::Procedural { style: s, size, seed: 1 };
}
ui.add_space(4.0);
- widgets::checkbox(ui, &mut tx.invert, "Invert");
+ widgets::checkbox(ui, &mut tx.invert, tl!("Invert"));
});
});
ui.add_space(6.0);
if let Pattern::Procedural { size, .. } = &mut tx.pattern {
let mut s = *size as f32;
- if num(ui, "Pattern Size", &mut s, 16.0..=1024.0, "px") {
+ if num(ui, tl!("Pattern Size"), &mut s, 16.0..=1024.0, "px") {
*size = s as u32;
}
}
- pct(ui, "Scale", &mut tx.scale, 10.0);
+ pct(ui, tl!("Scale"), &mut tx.scale, 10.0);
let mut br = (tx.brightness * 150.0).round();
- if num(ui, "Brightness", &mut br, -150.0..=150.0, "") {
+ if num(ui, tl!("Brightness"), &mut br, -150.0..=150.0, "") {
tx.brightness = br / 150.0;
}
// Photoshop's -50..100 contrast onto the model's -1..1.
let mut ct = if tx.contrast < 0.0 { tx.contrast * 50.0 } else { tx.contrast * 100.0 }.round();
- if num(ui, "Contrast", &mut ct, -50.0..=100.0, "") {
+ if num(ui, tl!("Contrast"), &mut ct, -50.0..=100.0, "") {
tx.contrast = if ct < 0.0 { ct / 50.0 } else { ct / 100.0 };
}
- widgets::checkbox(ui, &mut tx.each_tip, "Texture Each Tip");
+ widgets::checkbox(ui, &mut tx.each_tip, tl!("Texture Each Tip"));
ui.add_space(4.0);
ui.horizontal(|ui| {
- dim(ui, "Mode:");
+ dim(ui, tl!("Mode:"));
widgets::dropdown(ui, "brush-texture-mode", &mut tx.mode, &MASK_MODES, 130.0);
});
ui.add_space(4.0);
- pct(ui, "Depth", &mut tx.depth, 1.0);
+ pct(ui, tl!("Depth"), &mut tx.depth, 1.0);
let each = tx.each_tip;
ui.add_enabled_ui(each, |ui| {
- pct(ui, "Minimum Depth", &mut tx.depth_jitter.minimum, 1.0);
- pct(ui, "Depth Jitter", &mut tx.depth_jitter.jitter, 1.0);
+ pct(ui, tl!("Minimum Depth"), &mut tx.depth_jitter.minimum, 1.0);
+ pct(ui, tl!("Depth Jitter"), &mut tx.depth_jitter.jitter, 1.0);
control_row(ui, "brush-depth-ctl", &mut tx.depth_jitter, false);
});
}
@@ -482,10 +482,10 @@ fn texture(ui: &mut egui::Ui, b: &mut BrushSettings) {
fn dual_brush(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset]) {
let d = &mut b.dual_brush;
ui.horizontal(|ui| {
- dim(ui, "Mode:");
+ dim(ui, tl!("Mode:"));
widgets::dropdown(ui, "brush-dual-mode", &mut d.mode, &MASK_MODES, 120.0);
ui.add_space(8.0);
- widgets::checkbox(ui, &mut d.flip, "Flip");
+ widgets::checkbox(ui, &mut d.flip, tl!("Flip"));
});
ui.add_space(4.0);
let (tip, size, hardness) = (d.tip.clone(), d.size, d.hardness);
@@ -502,37 +502,37 @@ fn dual_brush(ui: &mut egui::Ui, b: &mut BrushSettings, presets: &[BrushPreset])
TipShape::Sampled(g) => Some(g.width.max(g.height) as f32),
TipShape::Round => None,
};
- size_row(ui, "Size", &mut d.size, 2500.0, orig);
- signed_pct(ui, "Spacing", &mut d.spacing, 0.01, 10.0);
- pct(ui, "Scatter", &mut d.scatter, 10.0);
- widgets::checkbox(ui, &mut d.both_axes, "Both Axes");
+ size_row(ui, tl!("Size"), &mut d.size, 2500.0, orig);
+ signed_pct(ui, tl!("Spacing"), &mut d.spacing, 0.01, 10.0);
+ pct(ui, tl!("Scatter"), &mut d.scatter, 10.0);
+ widgets::checkbox(ui, &mut d.both_axes, tl!("Both Axes"));
ui.add_space(4.0);
let mut c = d.count as f32;
- if num(ui, "Count", &mut c, 1.0..=16.0, "") {
+ if num(ui, tl!("Count"), &mut c, 1.0..=16.0, "") {
d.count = c as u32;
}
}
fn color_dynamics(ui: &mut egui::Ui, b: &mut BrushSettings) {
let c = &mut b.color_dynamics;
- widgets::checkbox(ui, &mut c.per_tip, "Apply Per Tip");
+ widgets::checkbox(ui, &mut c.per_tip, tl!("Apply Per Tip"));
ui.add_space(6.0);
- dynamic(ui, "brush-fgbg-ctl", "Foreground/Background Jitter", &mut c.fg_bg, 1.0, None, false);
+ dynamic(ui, "brush-fgbg-ctl", tl!("Foreground/Background Jitter"), &mut c.fg_bg, 1.0, None, false);
let mut h = (c.hue_jitter * 100.0).round();
- if widgets::slider_row(ui, "Hue Jitter", &mut h, 0.0..=100.0, "%", Some(&widgets::hue_stops())).changed() {
+ if widgets::slider_row(ui, tl!("Hue Jitter"), &mut h, 0.0..=100.0, "%", Some(&widgets::hue_stops())).changed() {
c.hue_jitter = (h.round() / 100.0).clamp(0.0, 1.0);
}
- pct(ui, "Saturation Jitter", &mut c.saturation_jitter, 1.0);
- pct(ui, "Brightness Jitter", &mut c.brightness_jitter, 1.0);
- signed_pct(ui, "Purity", &mut c.purity, -1.0, 1.0);
+ pct(ui, tl!("Saturation Jitter"), &mut c.saturation_jitter, 1.0);
+ pct(ui, tl!("Brightness Jitter"), &mut c.brightness_jitter, 1.0);
+ signed_pct(ui, tl!("Purity"), &mut c.purity, -1.0, 1.0);
}
fn transfer(ui: &mut egui::Ui, b: &mut BrushSettings) {
let tr = &mut b.transfer;
- dynamic(ui, "brush-opacity-ctl", "Opacity Jitter", &mut tr.opacity, 1.0, Some("Minimum"), false);
- dynamic(ui, "brush-flow-ctl", "Flow Jitter", &mut tr.flow, 1.0, Some("Minimum"), false);
- dynamic(ui, "brush-wet-ctl", "Wetness Jitter", &mut tr.wetness, 1.0, Some("Minimum"), false);
- dynamic(ui, "brush-mix-ctl", "Mix Jitter", &mut tr.mix, 1.0, Some("Minimum"), false);
+ dynamic(ui, "brush-opacity-ctl", tl!("Opacity Jitter"), &mut tr.opacity, 1.0, Some(tl!("Minimum")), false);
+ dynamic(ui, "brush-flow-ctl", tl!("Flow Jitter"), &mut tr.flow, 1.0, Some(tl!("Minimum")), false);
+ dynamic(ui, "brush-wet-ctl", tl!("Wetness Jitter"), &mut tr.wetness, 1.0, Some(tl!("Minimum")), false);
+ dynamic(ui, "brush-mix-ctl", tl!("Mix Jitter"), &mut tr.mix, 1.0, Some(tl!("Minimum")), false);
}
/// The Mixer Brush options the brush carries (Photoshop shows them in the Mixer Brush's options
@@ -542,13 +542,13 @@ fn mixer_options(ui: &mut egui::Ui, b: &mut BrushSettings) {
ui.add_space(4.0);
widgets::hairline(ui);
ui.add_space(4.0);
- ui.label(RichText::new("Mixer Brush").font(theme::semibold(11.5)).color(t.text_dim));
+ ui.label(RichText::new(tl!("Mixer Brush")).font(theme::semibold(11.5)).color(t.text_dim));
ui.add_space(2.0);
let m = &mut b.mixer;
- pct(ui, "Wet", &mut m.wet, 1.0);
- pct(ui, "Load", &mut m.load, 1.0);
- pct(ui, "Mix", &mut m.mix, 1.0);
- pct(ui, "Flow", &mut m.flow, 1.0);
+ pct(ui, tl!("Wet"), &mut m.wet, 1.0);
+ pct(ui, tl!("Load"), &mut m.load, 1.0);
+ pct(ui, tl!("Mix"), &mut m.mix, 1.0);
+ pct(ui, tl!("Flow"), &mut m.flow, 1.0);
widgets::checkbox(ui, &mut m.sample_all_layers, "Sample All Layers");
}
@@ -562,24 +562,24 @@ fn tilt(ui: &mut egui::Ui, label: &str, deg: &mut f32) {
fn pose(ui: &mut egui::Ui, b: &mut BrushSettings) {
let p = &mut b.pose;
- tilt(ui, "Tilt X", &mut p.tilt_x);
- tilt(ui, "Tilt Y", &mut p.tilt_y);
- widgets::checkbox(ui, &mut p.override_tilt, "Override Tilt");
+ tilt(ui, tl!("Tilt X"), &mut p.tilt_x);
+ tilt(ui, tl!("Tilt Y"), &mut p.tilt_y);
+ widgets::checkbox(ui, &mut p.override_tilt, tl!("Override Tilt"));
ui.add_space(8.0);
- num(ui, "Rotation", &mut p.rotation, 0.0..=360.0, "°");
- widgets::checkbox(ui, &mut p.override_rotation, "Override Rotation");
+ num(ui, tl!("Rotation"), &mut p.rotation, 0.0..=360.0, "°");
+ widgets::checkbox(ui, &mut p.override_rotation, tl!("Override Rotation"));
ui.add_space(8.0);
- pct(ui, "Pressure", &mut p.pressure, 1.0);
- widgets::checkbox(ui, &mut p.override_pressure, "Override Pressure");
+ pct(ui, tl!("Pressure"), &mut p.pressure, 1.0);
+ widgets::checkbox(ui, &mut p.override_pressure, tl!("Override Pressure"));
}
fn smoothing(ui: &mut egui::Ui, b: &mut BrushSettings) {
let s = &mut b.smoothing;
- pct(ui, "Smoothing", &mut s.amount, 1.0);
- widgets::checkbox(ui, &mut s.pulled_string, "Pulled String Mode");
- widgets::checkbox(ui, &mut s.catch_up, "Stroke Catch-up");
- widgets::checkbox(ui, &mut s.catch_up_on_end, "Catch-up on Stroke End");
- widgets::checkbox(ui, &mut s.adjust_for_zoom, "Adjust for Zoom");
+ pct(ui, tl!("Smoothing"), &mut s.amount, 1.0);
+ widgets::checkbox(ui, &mut s.pulled_string, tl!("Pulled String Mode"));
+ widgets::checkbox(ui, &mut s.catch_up, tl!("Stroke Catch-up"));
+ widgets::checkbox(ui, &mut s.catch_up_on_end, tl!("Catch-up on Stroke End"));
+ widgets::checkbox(ui, &mut s.adjust_for_zoom, tl!("Adjust for Zoom"));
}
/// Controls for section `i` (see [`crate::brush_panel::SECTIONS`]). `presets` feed the tip grids.
@@ -603,9 +603,9 @@ pub fn section_body(ui: &mut egui::Ui, b: &mut BrushSettings, i: usize, presets:
8 => note(ui, "Adds extra randomness to the soft edges of the brush tip. No options: turn it on in the list."),
9 => note(ui, "Builds up paint along the edges of the stroke for a watercolour look. No options: turn it on in the list."),
10 => {
- note(ui, "Airbrush: keeps depositing paint while the pointer rests.");
+ note(ui, tl!("Airbrush: keeps depositing paint while the pointer rests."));
ui.add_space(6.0);
- num(ui, "Rate", &mut b.build_up_rate, 1.0..=200.0, "/s");
+ num(ui, tl!("Rate"), &mut b.build_up_rate, 1.0..=200.0, "/s");
}
11 => smoothing(ui, b),
_ => note(ui, "Keeps the current pattern and scale when you switch to another textured brush preset."),
diff --git a/crates/ui-egui/src/brushes_tab.rs b/crates/ui-egui/src/brushes_tab.rs
index 471755b16..39d5e0139 100644
--- a/crates/ui-egui/src/brushes_tab.rs
+++ b/crates/ui-egui/src/brushes_tab.rs
@@ -129,11 +129,11 @@ fn preset_interactions(ui: &egui::Ui, resp: &egui::Response, r: egui::Rect, p: &
acts.push(Action::Select(p.name.clone()));
}
resp.context_menu(|ui| {
- if ui.button("Rename Brush…").clicked() {
+ if ui.button(tl!("Rename Brush…")).clicked() {
acts.push(Action::Rename(Renaming { group: false, name: p.name.clone(), text: String::new() }));
ui.close();
}
- if ui.button("Delete Brush").clicked() {
+ if ui.button(tl!("Delete Brush")).clicked() {
acts.push(Action::Delete(p.name.clone()));
ui.close();
}
@@ -243,11 +243,11 @@ fn group_header(ui: &mut egui::Ui, label: &str, key: &str, open: bool, count: us
acts.push(Action::ToggleGroup(label.to_string()));
}
resp.context_menu(|ui| {
- if ui.button("Rename Group…").clicked() {
+ if ui.button(tl!("Rename Group…")).clicked() {
acts.push(Action::Rename(Renaming { group: true, name: key.to_string(), text: String::new() }));
ui.close();
}
- if ui.button("Delete Group").clicked() {
+ if ui.button(tl!("Delete Group")).clicked() {
acts.push(Action::DeleteGroup(key.to_string()));
ui.close();
}
@@ -264,7 +264,7 @@ fn rename_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, acts: &mut Vec<Action>
}
let mut cancel = false;
ui.horizontal(|ui| {
- ui.label(RichText::new(if r.group { "Group name" } else { "Brush name" }).color(t.text_dim));
+ ui.label(RichText::new(if r.group { tl!("Group name") } else { tl!("Brush name") }).color(t.text_dim));
let resp = ui.add(egui::TextEdit::singleline(&mut r.text).desired_width(WIDTH - 230.0).id_salt("brush-rename"));
if !resp.has_focus() && !resp.lost_focus() {
resp.request_focus();
@@ -290,7 +290,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let before = app.session.tools.brush.clone();
let mut b = before.clone();
ui.horizontal(|ui| {
- ui.label(RichText::new("Size").color(t.text_dim));
+ ui.label(RichText::new(tl!("Size")).color(t.text_dim));
let mut lv = b.size.max(1.0).ln();
ui.add_sized(vec2(WIDTH - 140.0, 18.0), |ui: &mut egui::Ui| {
let r = widgets::slider(ui, &mut lv, 0.0..=5000f32.ln(), None);
@@ -309,7 +309,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
icons::paint(ui, egui::Rect::from_min_size(ui.cursor().min + vec2(0.0, 3.0), vec2(16.0, 16.0)), "search", 14.0, t.text_faint);
ui.add_space(20.0);
- ui.add(egui::TextEdit::singleline(&mut app.ui.brushes_panel.filter).hint_text("Search Brushes").desired_width(WIDTH - 120.0));
+ ui.add(egui::TextEdit::singleline(&mut app.ui.brushes_panel.filter).hint_text(tl!("Search Brushes")).desired_width(WIDTH - 120.0));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
let view = &mut app.ui.brushes_panel.view;
if icons::button(ui, "grid-2x2", 24.0, *view == BrushesView::Grid, "Grid view").clicked() {
diff --git a/crates/ui-egui/src/camera_raw_ui.rs b/crates/ui-egui/src/camera_raw_ui.rs
index f9dbadee3..fbe1ed716 100644
--- a/crates/ui-egui/src/camera_raw_ui.rs
+++ b/crates/ui-egui/src/camera_raw_ui.rs
@@ -186,7 +186,7 @@ pub fn menu(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Val
}
fn commit(app: &mut PhotocraftApp) -> Result<Value, String> {
- let d = app.camera_raw.take().ok_or("Camera Raw isn't open")?;
+ let d = app.camera_raw.take().ok_or(tl!("Camera Raw isn't open"))?;
let mut p = d.command_params();
p["layer"] = json!(d.layer.0);
app.run("filter.cameraRaw", p)
@@ -212,15 +212,15 @@ fn row(ui: &mut egui::Ui, dirty: &mut bool, label: &str, v: &mut f32, range: std
}
fn section(ui: &mut egui::Ui, title: &str, open: bool, body: impl FnOnce(&mut egui::Ui)) {
- egui::CollapsingHeader::new(egui::RichText::new(title).font(FontId::proportional(13.0))).default_open(open).show(ui, body);
+ egui::CollapsingHeader::new(egui::RichText::new(tl!(&title)).font(FontId::proportional(13.0))).default_open(open).show(ui, body);
}
fn wheel(ui: &mut egui::Ui, dirty: &mut bool, title: &str, w: &mut Wheel) {
widgets::section_label(ui, title);
let hs = widgets::hue_stops();
- row(ui, dirty, "Hue", &mut w.hue, 0.0..=360.0, Some(&hs));
- row(ui, dirty, "Saturation", &mut w.sat, 0.0..=100.0, None);
- row(ui, dirty, "Luminance", &mut w.lum, -100.0..=100.0, None);
+ row(ui, dirty, tl!("Hue"), &mut w.hue, 0.0..=360.0, Some(&hs));
+ row(ui, dirty, tl!("Saturation"), &mut w.sat, 0.0..=100.0, None);
+ row(ui, dirty, tl!("Luminance"), &mut w.lum, -100.0..=100.0, None);
}
/// Small point-curve editor (master channel): click to add, drag to move, right-click to delete.
@@ -325,46 +325,46 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.spacing_mut().item_spacing.y = 4.0;
let p = &mut d.params;
let (ts, tn) = (temp_stops(), tint_stops());
- section(ui, "Basic", true, |ui| {
- widgets::section_label(ui, "White Balance: As Shot");
- row(ui, &mut dirty, "Temperature", &mut p.temperature, -100.0..=100.0, Some(&ts));
- row(ui, &mut dirty, "Tint", &mut p.tint, -100.0..=100.0, Some(&tn));
- row(ui, &mut dirty, "Exposure", &mut p.exposure, -5.0..=5.0, None);
- row(ui, &mut dirty, "Contrast", &mut p.contrast, -100.0..=100.0, None);
- row(ui, &mut dirty, "Highlights", &mut p.highlights, -100.0..=100.0, None);
- row(ui, &mut dirty, "Shadows", &mut p.shadows, -100.0..=100.0, None);
- row(ui, &mut dirty, "Whites", &mut p.whites, -100.0..=100.0, None);
- row(ui, &mut dirty, "Blacks", &mut p.blacks, -100.0..=100.0, None);
+ section(ui, tl!("Basic"), true, |ui| {
+ widgets::section_label(ui, tl!("White Balance: As Shot"));
+ row(ui, &mut dirty, tl!("Temperature"), &mut p.temperature, -100.0..=100.0, Some(&ts));
+ row(ui, &mut dirty, tl!("Tint"), &mut p.tint, -100.0..=100.0, Some(&tn));
+ row(ui, &mut dirty, tl!("Exposure"), &mut p.exposure, -5.0..=5.0, None);
+ row(ui, &mut dirty, tl!("Contrast"), &mut p.contrast, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Highlights"), &mut p.highlights, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Shadows"), &mut p.shadows, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Whites"), &mut p.whites, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Blacks"), &mut p.blacks, -100.0..=100.0, None);
widgets::hairline(ui);
- row(ui, &mut dirty, "Texture", &mut p.texture, -100.0..=100.0, None);
- row(ui, &mut dirty, "Clarity", &mut p.clarity, -100.0..=100.0, None);
- row(ui, &mut dirty, "Dehaze", &mut p.dehaze, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Texture"), &mut p.texture, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Clarity"), &mut p.clarity, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Dehaze"), &mut p.dehaze, -100.0..=100.0, None);
widgets::hairline(ui);
- row(ui, &mut dirty, "Vibrance", &mut p.vibrance, -100.0..=100.0, None);
- row(ui, &mut dirty, "Saturation", &mut p.saturation, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Vibrance"), &mut p.vibrance, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Saturation"), &mut p.saturation, -100.0..=100.0, None);
});
- section(ui, "Curve", false, |ui| {
+ section(ui, tl!("Curve"), false, |ui| {
curve_editor(ui, p, &mut dirty);
- row(ui, &mut dirty, "Highlights", &mut p.curve_highlights, -100.0..=100.0, None);
- row(ui, &mut dirty, "Lights", &mut p.curve_lights, -100.0..=100.0, None);
- row(ui, &mut dirty, "Darks", &mut p.curve_darks, -100.0..=100.0, None);
- row(ui, &mut dirty, "Shadows", &mut p.curve_shadows, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Highlights"), &mut p.curve_highlights, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Lights"), &mut p.curve_lights, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Darks"), &mut p.curve_darks, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Shadows"), &mut p.curve_shadows, -100.0..=100.0, None);
});
- section(ui, "Detail", false, |ui| {
- widgets::section_label(ui, "Sharpening");
- row(ui, &mut dirty, "Amount", &mut p.sharpen_amount, 0.0..=150.0, None);
- row(ui, &mut dirty, "Radius", &mut p.sharpen_radius, 0.5..=3.0, None);
- row(ui, &mut dirty, "Detail", &mut p.sharpen_detail, 0.0..=100.0, None);
- row(ui, &mut dirty, "Masking", &mut p.sharpen_masking, 0.0..=100.0, None);
- widgets::section_label(ui, "Noise Reduction");
- row(ui, &mut dirty, "Luminance", &mut p.noise_luminance, 0.0..=100.0, None);
- row(ui, &mut dirty, "Luminance Detail", &mut p.noise_luminance_detail, 0.0..=100.0, None);
- row(ui, &mut dirty, "Color", &mut p.noise_color, 0.0..=100.0, None);
- row(ui, &mut dirty, "Color Detail", &mut p.noise_color_detail, 0.0..=100.0, None);
+ section(ui, tl!("Detail"), false, |ui| {
+ widgets::section_label(ui, tl!("Sharpening"));
+ row(ui, &mut dirty, tl!("Amount"), &mut p.sharpen_amount, 0.0..=150.0, None);
+ row(ui, &mut dirty, tl!("Radius"), &mut p.sharpen_radius, 0.5..=3.0, None);
+ row(ui, &mut dirty, tl!("Detail"), &mut p.sharpen_detail, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Masking"), &mut p.sharpen_masking, 0.0..=100.0, None);
+ widgets::section_label(ui, tl!("Noise Reduction"));
+ row(ui, &mut dirty, tl!("Luminance"), &mut p.noise_luminance, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Luminance Detail"), &mut p.noise_luminance_detail, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Color"), &mut p.noise_color, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Color Detail"), &mut p.noise_color_detail, 0.0..=100.0, None);
});
- section(ui, "Color Mixer", false, |ui| {
+ section(ui, tl!("Color Mixer"), false, |ui| {
ui.horizontal(|ui| {
- for (i, name) in ["Hue", "Saturation", "Luminance"].iter().enumerate() {
+ for (i, name) in [tl!("Hue"), tl!("Saturation"), tl!("Luminance")].iter().enumerate() {
if widgets::pill_tab(ui, name, d.mixer_tab == i).clicked() {
d.mixer_tab = i;
}
@@ -382,40 +382,40 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
row(ui, &mut dirty, name, &mut arr[k], -100.0..=100.0, Some(&grad));
}
});
- section(ui, "Color Grading", false, |ui| {
- wheel(ui, &mut dirty, "Shadows", &mut p.grade_shadows);
- wheel(ui, &mut dirty, "Midtones", &mut p.grade_midtones);
- wheel(ui, &mut dirty, "Highlights", &mut p.grade_highlights);
- wheel(ui, &mut dirty, "Global", &mut p.grade_global);
- row(ui, &mut dirty, "Blending", &mut p.grade_blending, 0.0..=100.0, None);
- row(ui, &mut dirty, "Balance", &mut p.grade_balance, -100.0..=100.0, None);
+ section(ui, tl!("Color Grading"), false, |ui| {
+ wheel(ui, &mut dirty, tl!("Shadows"), &mut p.grade_shadows);
+ wheel(ui, &mut dirty, tl!("Midtones"), &mut p.grade_midtones);
+ wheel(ui, &mut dirty, tl!("Highlights"), &mut p.grade_highlights);
+ wheel(ui, &mut dirty, tl!("Global"), &mut p.grade_global);
+ row(ui, &mut dirty, tl!("Blending"), &mut p.grade_blending, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Balance"), &mut p.grade_balance, -100.0..=100.0, None);
});
- section(ui, "Effects", false, |ui| {
- widgets::section_label(ui, "Grain");
- row(ui, &mut dirty, "Amount", &mut p.grain_amount, 0.0..=100.0, None);
- row(ui, &mut dirty, "Size", &mut p.grain_size, 0.0..=100.0, None);
- row(ui, &mut dirty, "Roughness", &mut p.grain_roughness, 0.0..=100.0, None);
- widgets::section_label(ui, "Vignetting");
+ section(ui, tl!("Effects"), false, |ui| {
+ widgets::section_label(ui, tl!("Grain"));
+ row(ui, &mut dirty, tl!("Amount"), &mut p.grain_amount, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Size"), &mut p.grain_size, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Roughness"), &mut p.grain_roughness, 0.0..=100.0, None);
+ widgets::section_label(ui, tl!("Vignetting"));
let mut style = p.vignette_style.clone();
if widgets::dropdown(
ui,
"cr-vig-style",
&mut style,
&[
- ("highlightPriority".to_string(), "Highlight Priority"),
- ("colorPriority".to_string(), "Color Priority"),
- ("paintOverlay".to_string(), "Paint Overlay"),
+ ("highlightPriority".to_string(), tl!("Highlight Priority")),
+ ("colorPriority".to_string(), tl!("Color Priority")),
+ ("paintOverlay".to_string(), tl!("Paint Overlay")),
],
200.0,
) {
p.vignette_style = style;
dirty = true;
}
- row(ui, &mut dirty, "Amount", &mut p.vignette_amount, -100.0..=100.0, None);
- row(ui, &mut dirty, "Midpoint", &mut p.vignette_midpoint, 0.0..=100.0, None);
- row(ui, &mut dirty, "Roundness", &mut p.vignette_roundness, -100.0..=100.0, None);
- row(ui, &mut dirty, "Feather", &mut p.vignette_feather, 0.0..=100.0, None);
- row(ui, &mut dirty, "Highlights", &mut p.vignette_highlights, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Amount"), &mut p.vignette_amount, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Midpoint"), &mut p.vignette_midpoint, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Roundness"), &mut p.vignette_roundness, -100.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Feather"), &mut p.vignette_feather, 0.0..=100.0, None);
+ row(ui, &mut dirty, tl!("Highlights"), &mut p.vignette_highlights, 0.0..=100.0, None);
});
});
d.dirty |= dirty;
@@ -424,14 +424,14 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
painter.rect_filled(foot, 0.0, t.dock);
painter.line_segment([foot.left_top(), foot.right_top()], Stroke::new(1.0, t.separator));
let mut fu = ui.new_child(egui::UiBuilder::new().max_rect(foot.shrink2(vec2(16.0, 9.0))).layout(egui::Layout::right_to_left(egui::Align::Center)));
- if widgets::primary_button(&mut fu, "OK", 90.0).clicked() {
+ if widgets::primary_button(&mut fu, tl!("OK"), 90.0).clicked() {
action = Some("ok");
}
- if widgets::secondary_button(&mut fu, "Cancel", 90.0).clicked() {
+ if widgets::secondary_button(&mut fu, tl!("Cancel"), 90.0).clicked() {
action = Some("cancel");
}
fu.add_space(12.0);
- widgets::checkbox(&mut fu, &mut d.show_before, "Before (Y)");
+ widgets::checkbox(&mut fu, &mut d.show_before, tl!("Before (Y)"));
fu.label(egui::RichText::new(format!("{:.0} ms", d.render_ms)).color(t.text_faint));
});
if ctx.input(|i| i.key_pressed(egui::Key::Y))
diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs
index 4286c9f50..66c3917c6 100644
--- a/crates/ui-egui/src/canvas.rs
+++ b/crates/ui-egui/src/canvas.rs
@@ -887,7 +887,7 @@ fn pro_tabs(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let active_layer = st.active_layer.and_then(|id| st.doc.layer(id)).filter(|l| !(l.name == "Background" && l.locks.transparency));
let is_active_doc = app.session.active_index() == Some(i);
let mask = is_active_doc && app.ui.mask_target && active_layer.is_some_and(|l| l.mask.is_some());
- let model = if mask { "Layer Mask".to_string() } else { mode_label(&st.doc).to_string() };
+ let model = if mask { tl!("Layer Mask").to_string() } else { mode_label(&st.doc).to_string() };
let layer = active_layer.map(|l| format!("{}, ", l.name)).unwrap_or_default();
let title = format!("{} @ {}% ({layer}{model}/{}){}", st.doc.name, fmt_zoom(zoom), st.doc.depth.bits(), if st.is_dirty() { "*" } else { "" });
let g = ui.painter().layout_no_wrap(title, egui::FontId::proportional(11.5), t.text);
@@ -985,7 +985,7 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.scope_builder(egui::UiBuilder::new().max_rect(card), |ui| {
ui.vertical_centered(|ui| {
ui.horizontal(|ui| {
- let title = ui.painter().layout_no_wrap("PhotoCraft".into(), crate::theme::semibold(38.0), t.text);
+ let title = ui.painter().layout_no_wrap(tl!("PhotoCraft").into(), crate::theme::semibold(38.0), t.text);
let by = ui.painter().layout_no_wrap("open source".into(), egui::FontId::proportional(13.0), t.text_faint);
let total = title.size().x + by.size().x + 10.0;
ui.add_space(((card.width() - total) / 2.0).max(0.0));
@@ -995,7 +995,7 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.painter().galley(egui::pos2(r2.left() + 10.0, r.bottom() - by.size().y - 8.0), by, t.text_faint);
});
ui.add_space(6.0);
- ui.label(egui::RichText::new("Create a new document or open an existing file.").color(t.text_dim).size(14.0));
+ ui.label(egui::RichText::new(tl!("Create a new document or open an existing file.")).color(t.text_dim).size(14.0));
ui.add_space(22.0);
ui.horizontal(|ui| {
ui.add_space(((card.width() - 2.0 * 190.0 - 12.0) / 2.0).max(0.0));
@@ -1009,7 +1009,7 @@ fn start_screen(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
});
ui.add_space(22.0);
ui.horizontal(|ui| {
- let msg = "Drop an image or PSD anywhere to open it.";
+ let msg = tl!("Drop an image or PSD anywhere to open it.");
let g = ui.painter().layout_no_wrap(msg.into(), egui::FontId::proportional(12.5), t.text_faint);
ui.add_space(((card.width() - g.size().x - 24.0) / 2.0).max(0.0));
let (r, _) = ui.allocate_exact_size(egui::vec2(18.0, 18.0), Sense::hover());
@@ -1040,7 +1040,7 @@ fn home_recent(app: &mut PhotocraftApp, ui: &mut egui::Ui, recent: &[String]) {
ui.horizontal(|ui| {
// Line the heading up with the file icons.
ui.add_space(((ui.available_width() - width) / 2.0).max(0.0) + 8.0);
- ui.label(egui::RichText::new("Recent").font(crate::theme::semibold(12.5)).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Recent")).font(crate::theme::semibold(12.5)).color(t.text_dim));
});
ui.add_space(4.0);
let mut open = None;
diff --git a/crates/ui-egui/src/channels_panel.rs b/crates/ui-egui/src/channels_panel.rs
index 2dde85582..3d1cfc98c 100644
--- a/crates/ui-egui/src/channels_panel.rs
+++ b/crates/ui-egui/src/channels_panel.rs
@@ -48,7 +48,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
ui.add_space(6.0);
- ui.label(RichText::new("No document").color(t.text_faint));
+ ui.label(RichText::new(tl!("No document")).color(t.text_faint));
return;
};
let doc = st.doc.clone();
@@ -136,7 +136,7 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if row != Row::LayerMask || visible || eye_resp.hovered() {
icons::paint(ui, eye, if visible { "eye" } else { "eye-off" }, 14.0, if visible { t.icon } else { t.text_faint });
}
- let eye_resp = eye_resp.on_hover_text(if row == Row::LayerMask { "Show the layer mask as an overlay" } else { "Toggle visibility" });
+ let eye_resp = eye_resp.on_hover_text(if row == Row::LayerMask { tl!("Show the layer mask as an overlay") } else { tl!("Toggle visibility") });
eye_resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, format!("Visibility {name}")));
let layer_id = masked.as_ref().map(|l| l.id.0);
if eye_resp.clicked() {
@@ -276,17 +276,17 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ChannelTarget::Color(k) => json!({ "color": k }),
ChannelTarget::Composite => json!("composite"),
};
- if icons::button(ui, "circle-dashed", 26.0, false, "Load channel as selection").clicked() {
+ if icons::button(ui, "circle-dashed", 26.0, false, tl!("Load channel as selection")).clicked() {
actions.push(("select.loadSelection".into(), json!({ "channel": target_ref })));
}
- if icons::button(ui, "square-dashed", 26.0, false, "Save selection as channel").clicked() {
+ if icons::button(ui, "square-dashed", 26.0, false, tl!("Save selection as channel")).clicked() {
actions.push(("select.saveSelection".into(), json!({})));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if icons::button(ui, "trash", 26.0, false, "Delete current channel").clicked() {
+ if icons::button(ui, "trash", 26.0, false, tl!("Delete current channel")).clicked() {
actions.push(("channel.delete".into(), json!({})));
}
- if icons::button(ui, "plus", 26.0, false, "Create new channel").clicked() {
+ if icons::button(ui, "plus", 26.0, false, tl!("Create new channel")).clicked() {
actions.push(("channel.new".into(), json!({})));
}
});
@@ -327,7 +327,7 @@ pub fn fit_thumb(cell: Rect, w: u32, h: u32) -> (Rect, Rect) {
}
fn item(ui: &mut egui::Ui, actions: &mut Vec<(String, Value)>, label: &str, cmd: &str, p: Value) {
- if ui.button(label).clicked() {
+ if ui.button(tl!(&label)).clicked() {
actions.push((cmd.into(), p));
ui.close();
}
@@ -343,16 +343,22 @@ fn indicates_items(ui: &mut egui::Ui, actions: &mut Vec<(String, Value)>, channe
/// Overlay colour presets (Channel Options › Color) and opacity.
fn overlay_colors(ui: &mut egui::Ui, actions: &mut Vec<(String, Value)>, channel: Value) {
- ui.menu_button("Overlay Color", |ui| {
- for (label, hex) in [("Red", "#ff0000"), ("Green", "#00c000"), ("Blue", "#0050ff"), ("Cyan", "#00d0e0"), ("Magenta", "#e000c0"), ("Yellow", "#f0d000")]
- {
- if ui.button(label).clicked() {
+ ui.menu_button(tl!("Overlay Color"), |ui| {
+ for (label, hex) in [
+ (tl!("Red"), "#ff0000"),
+ (tl!("Green"), "#00c000"),
+ (tl!("Blue"), "#0050ff"),
+ (tl!("Cyan"), "#00d0e0"),
+ (tl!("Magenta"), "#e000c0"),
+ (tl!("Yellow"), "#f0d000"),
+ ] {
+ if ui.button(tl!(&label)).clicked() {
actions.push(("channel.options".into(), json!({ "channel": channel.clone(), "color": hex })));
ui.close();
}
}
});
- ui.menu_button("Overlay Opacity", |ui| {
+ ui.menu_button(tl!("Overlay Opacity"), |ui| {
for o in [25, 50, 75, 100] {
if ui.button(format!("{o}%")).clicked() {
actions.push(("channel.options".into(), json!({ "channel": channel.clone(), "opacity": o })));
diff --git a/crates/ui-egui/src/chrome_ui.rs b/crates/ui-egui/src/chrome_ui.rs
index 1049f143b..bec143bac 100644
--- a/crates/ui-egui/src/chrome_ui.rs
+++ b/crates/ui-egui/src/chrome_ui.rs
@@ -79,27 +79,30 @@ pub fn status_info_text(doc: &Document, key: &str, tool: &str, profile: &str) ->
match key {
"sizes" => {
let (flat, layered) = document_sizes(doc);
- format!("Doc: {}/{}", fmt_bytes(flat), fmt_bytes(layered))
+ crate::i18n::fmt(tl!("Doc: {flat}/{layered}"), &[("flat", &fmt_bytes(flat)), ("layered", &fmt_bytes(layered))])
}
"profile" => format!("{profile} ({bits}bpc)"),
"measurementScale" => "1 pixel = 1.0000 pixels".into(),
"scratch" => {
let (_, layered) = document_sizes(doc);
- format!("Scratch: {}", fmt_bytes(layered))
+ crate::i18n::fmt(tl!("Scratch: {size}"), &[("size", &fmt_bytes(layered))])
}
- "efficiency" => "Efficiency: 100%".into(),
+ "efficiency" => tl!("Efficiency: 100%").into(),
"tool" => tool.to_string(),
"layers" => {
let n = doc.layer_count();
- format!("{n} {}", if n == 1 { "Layer" } else { "Layers" })
+ crate::i18n::trn(crate::i18n::current(), n as u64, "{n} Layer", "{n} Layers")
}
- _ => format!("{} px x {} px ({} ppi)", doc.size.width, doc.size.height, widgets::fmt_num(doc.resolution_dpi as f64)),
+ _ => crate::i18n::fmt(
+ tl!("{w} px x {h} px ({ppi} ppi)"),
+ &[("w", &doc.size.width.to_string()), ("h", &doc.size.height.to_string()), ("ppi", &widgets::fmt_num(doc.resolution_dpi as f64))],
+ ),
}
}
fn profile_name(doc: &Document) -> String {
if doc.icc_profile.is_none() {
- return format!("Untagged {}", crate::canvas::mode_label(doc));
+ return crate::i18n::fmt(tl!("Untagged {mode}"), &[("mode", tl!(&crate::canvas::mode_label(doc)))]);
}
photocraft_engine::color_cmds::document_profile(doc).description.clone()
}
@@ -108,23 +111,23 @@ fn profile_name(doc: &Document) -> String {
pub fn status_bar_pro(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let (Some(st), Some(i)) = (app.session.active(), app.session.active_index()) else {
- ui.label(RichText::new("No document").color(t.text_dim));
+ ui.label(RichText::new(tl!("No document")).color(t.text_dim));
return;
};
- let text = status_info_text(&st.doc, &app.ui.chrome.status_info, app.ui.tool.label(), &profile_name(&st.doc));
+ let text = status_info_text(&st.doc, &app.ui.chrome.status_info, tl!(app.ui.tool.label()), &profile_name(&st.doc));
let mut pct = app.ui.views[i].zoom * 100.0;
if widgets::value_field(ui, &mut pct, 1.0..=3200.0, "%", 64.0).changed() {
app.ui.views[i].zoom = pct / 100.0;
app.ui.views[i].fit_pending = false;
}
ui.add_space(12.0);
- ui.label(RichText::new(text).color(t.text_dim).size(12.0));
+ ui.label(RichText::new(tl!(&text)).color(t.text_dim).size(12.0));
let (r, resp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::click());
if resp.hovered() {
ui.painter().rect_filled(r, t.radius_sm, t.hover);
}
icons::paint(ui, r, "chevron-right", 11.0, t.text_dim);
- let resp = resp.on_hover_text("Show");
+ let resp = resp.on_hover_text(tl!("Show"));
egui::Popup::menu(&resp).show(|ui| {
ui.set_min_width(200.0);
for (key, label) in STATUS_INFO {
@@ -151,7 +154,7 @@ pub fn home_button(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let on = app.ui.chrome.shows_home(n, auto);
// With no documents and auto-show on, Home can't be dismissed (there's nothing behind it).
let can_toggle = n > 0 || !auto;
- if icons::button(ui, "house", 26.0, on && can_toggle, "Home").clicked() && can_toggle {
+ if icons::button(ui, "house", 26.0, on && can_toggle, tl!("Home")).clicked() && can_toggle {
app.ui.chrome.home = if on { None } else { Some(n) };
}
}
diff --git a/crates/ui-egui/src/color_picker_ui.rs b/crates/ui-egui/src/color_picker_ui.rs
index a569d0f44..7391bb09d 100644
--- a/crates/ui-egui/src/color_picker_ui.rs
+++ b/crates/ui-egui/src/color_picker_ui.rs
@@ -222,7 +222,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.add_space(14.0);
ui.vertical(|ui| {
// new / current swatches.
- ui.label(egui::RichText::new("new").size(11.0).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("new")).size(11.0).color(t.text_dim));
let (sw, _) = ui.allocate_exact_size(vec2(64.0, 72.0), Sense::hover());
let orig = f.get("__orig").and_then(Value::as_str).and_then(parse_hex).unwrap_or(rgb);
ui.painter().rect_filled(Rect::from_min_size(sw.min, vec2(64.0, 36.0)), 0.0, c32(rgb));
@@ -230,13 +230,13 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.painter().rect_filled(cur, 0.0, c32(orig));
ui.painter().rect_stroke(sw, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);
let click_cur = ui.interact(cur, ui.id().with("cp-current"), Sense::click());
- if click_cur.on_hover_text("Click to restore the current colour").clicked() {
+ if click_cur.on_hover_text(tl!("Click to restore the current colour")).clicked() {
set_rgb(f, orig, None);
}
- ui.label(egui::RichText::new("current").size(11.0).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("current")).size(11.0).color(t.text_dim));
ui.add_space(10.0);
let mut web = f.get("__webOnly").and_then(Value::as_bool).unwrap_or(false);
- if widgets::checkbox(ui, &mut web, "Only Web Colors").changed() {
+ if widgets::checkbox(ui, &mut web, tl!("Only Web Colors")).changed() {
f.insert("__webOnly".into(), json!(web));
set_rgb(f, rgb, None);
}
@@ -268,7 +268,7 @@ fn fields(ui: &mut egui::Ui, f: &mut Map<String, Value>, mode: &str, rgb: [f32;
if resp.clicked() {
new_mode = Some(key);
}
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim));
let mut v = vals[i].round();
if widgets::value_field(ui, &mut v, ranges[i].clone(), "", 54.0).changed() {
let (mut h, mut c) = (hsv, rgb);
@@ -286,7 +286,7 @@ fn fields(ui: &mut egui::Ui, f: &mut Map<String, Value>, mode: &str, rgb: [f32;
}
for (i, (label, v, range)) in [("L:", lab[0], 0.0..=100.0), ("a:", lab[1], -128.0..=127.0), ("b:", lab[2], -128.0..=127.0)].into_iter().enumerate() {
ui.label("");
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim));
let mut x = v.round();
if widgets::value_field(ui, &mut x, range, "", 54.0).changed() {
let mut l = lab;
@@ -298,7 +298,7 @@ fn fields(ui: &mut egui::Ui, f: &mut Map<String, Value>, mode: &str, rgb: [f32;
}
for (i, label) in ["C:", "M:", "Y:", "K:"].into_iter().enumerate() {
ui.label("");
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim));
let mut x = (cmyk[i] * 100.0).round();
if widgets::value_field(ui, &mut x, 0.0..=100.0, "", 54.0).changed() {
let mut k = cmyk;
diff --git a/crates/ui-egui/src/color_range_ui.rs b/crates/ui-egui/src/color_range_ui.rs
index 5f0dd5847..f9b12e779 100644
--- a/crates/ui-egui/src/color_range_ui.rs
+++ b/crates/ui-egui/src/color_range_ui.rs
@@ -82,7 +82,7 @@ pub fn controls(f: &Map<String, Value>) -> Controls {
/// Open the dialog with Photoshop's defaults (Sampled Colors, Fuzziness 40, the foreground colour
/// as the sample until the eyedropper picks one).
pub fn open(app: &mut PhotocraftApp) -> u64 {
- let label = photocraft_engine::commands::find(COMMAND).map_or("Color Range…", |c| c.label);
+ let label = photocraft_engine::commands::find(COMMAND).map_or(tl!("Color Range…"), |c| c.label);
let mut f = Map::new();
f.insert("__colorRange".into(), json!(true));
f.insert("__label".into(), json!(label));
@@ -295,7 +295,7 @@ fn radio(ui: &mut egui::Ui, on: bool, label: &str) -> egui::Response {
if on {
ui.painter().circle_filled(r.center(), 3.0, t.accent);
}
- let l = ui.add(egui::Label::new(egui::RichText::new(label).color(t.text_dim)).sense(Sense::click()));
+ let l = ui.add(egui::Label::new(egui::RichText::new(tl!(&label)).color(t.text_dim)).sense(Sense::click()));
resp.union(l)
})
.inner
@@ -323,7 +323,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
let c = controls(f);
let select = s(f, "select", "sampledColors").to_string();
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Select:").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Select:")).color(t.text_dim));
let mut cur: &str = &select;
if widgets::dropdown(ui, "color-range-select", &mut cur, SELECTS, 170.0) {
f.insert("select".into(), json!(cur));
@@ -332,7 +332,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
ui.add_space(4.0);
ui.add_enabled_ui(c.sampling, |ui| {
let mut on = flag(f, "localized");
- if widgets::checkbox(ui, &mut on, "Localized Color Clusters").changed() {
+ if widgets::checkbox(ui, &mut on, tl!("Localized Color Clusters")).changed() {
f.insert("localized".into(), json!(on));
}
});
@@ -340,19 +340,19 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
ui.add_enabled_ui(c.fuzziness, |ui| {
if c.tonal {
let mut v = num(f, "toneFuzziness", 20.0);
- if widgets::slider_row(ui, "Fuzziness:", &mut v, 0.0..=100.0, "%", None).changed() {
+ if widgets::slider_row(ui, tl!("Fuzziness:"), &mut v, 0.0..=100.0, "%", None).changed() {
f.insert("toneFuzziness".into(), json!(v.round()));
}
} else {
let mut v = num(f, "fuzziness", 40.0);
- if widgets::slider_row(ui, "Fuzziness:", &mut v, 0.0..=200.0, "", None).changed() {
+ if widgets::slider_row(ui, tl!("Fuzziness:"), &mut v, 0.0..=200.0, "", None).changed() {
f.insert("fuzziness".into(), json!(v.round()));
}
}
});
if c.range {
let mut v = num(f, "range", 100.0);
- if widgets::slider_row(ui, "Range:", &mut v, 0.0..=100.0, "%", None).changed() {
+ if widgets::slider_row(ui, tl!("Range:"), &mut v, 0.0..=100.0, "%", None).changed() {
f.insert("range".into(), json!(v.round()));
}
}
@@ -367,8 +367,8 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
"shadows" => level(ui, "shadowsLevel", "Shadows up to:", 65.0),
"highlights" => level(ui, "highlightsLevel", "Highlights from:", 190.0),
_ => {
- level(ui, "midtonesLow", "Midtones from:", 105.0);
- level(ui, "midtonesHigh", "Midtones to:", 150.0);
+ level(ui, "midtonesLow", tl!("Midtones from:"), 105.0);
+ level(ui, "midtonesHigh", tl!("Midtones to:"), 150.0);
}
}
}
@@ -405,7 +405,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
ui.painter().rect_stroke(frame, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);
let label = match app.color_range.as_ref().and_then(|p| p.error.as_deref()) {
Some(e) => format!("Color Range preview unavailable: {e}"),
- None => "Color Range preview".to_string(),
+ None => tl!("Color Range preview").to_string(),
};
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Image, ui.is_enabled(), &label));
ui.add_space(10.0);
@@ -413,7 +413,9 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
ui.add_enabled_ui(c.sampling, |ui| {
let tool = s(f, "__tool", "sample").to_string();
ui.horizontal(|ui| {
- for (id, badge, label) in [("sample", "", "Eyedropper"), ("add", "+", "Add to Sample"), ("subtract", "−", "Subtract from Sample")] {
+ for (id, badge, label) in
+ [("sample", "", tl!("Eyedropper")), ("add", "+", tl!("Add to Sample")), ("subtract", "−", tl!("Subtract from Sample"))]
+ {
if eyedropper(ui, badge, tool == id, label).clicked() {
f.insert("__tool".into(), json!(id));
}
@@ -421,19 +423,22 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
});
let (add, sub) = (points(f, "points").len(), points(f, "subtractPoints").len());
let what = match (add, sub) {
- (0, 0) => "Sample: foreground colour".to_string(),
- (a, 0) => format!("{a} sample{}", if a == 1 { "" } else { "s" }),
- (a, s) => format!("{a} sample{}, {s} subtracted", if a == 1 { "" } else { "s" }),
+ (0, 0) => tl!("Sample: foreground colour").to_string(),
+ (a, 0) => crate::i18n::trn(crate::i18n::current(), a as u64, "{n} sample", "{n} samples"),
+ (a, s) => crate::i18n::fmt(
+ tl!("{added}, {removed} subtracted"),
+ &[("added", &crate::i18n::trn(crate::i18n::current(), a as u64, "{n} sample", "{n} samples")), ("removed", &s.to_string())],
+ ),
};
ui.label(egui::RichText::new(what).size(11.0).color(t.text_faint));
- if add + sub > 0 && widgets::secondary_button(ui, "Clear Samples", 0.0).clicked() {
+ if add + sub > 0 && widgets::secondary_button(ui, tl!("Clear Samples"), 0.0).clicked() {
set_points(f, "points", &[]);
set_points(f, "subtractPoints", &[]);
}
});
ui.add_space(8.0);
let mut inv = flag(f, "invert");
- if widgets::checkbox(ui, &mut inv, "Invert").changed() {
+ if widgets::checkbox(ui, &mut inv, tl!("Invert")).changed() {
f.insert("invert".into(), json!(inv));
}
});
@@ -450,7 +455,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
}
});
if app.session.active().is_none() {
- ui.label(egui::RichText::new("Open a document to select a colour range.").color(t.text_faint));
+ ui.label(egui::RichText::new(tl!("Open a document to select a colour range.")).color(t.text_faint));
}
}
diff --git a/crates/ui-egui/src/comps_ui.rs b/crates/ui-egui/src/comps_ui.rs
index b22805aa7..73b12bc01 100644
--- a/crates/ui-egui/src/comps_ui.rs
+++ b/crates/ui-egui/src/comps_ui.rs
@@ -28,7 +28,7 @@ fn run(app: &mut PhotocraftApp, id: &str, p: Value) {
pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- ui.label(egui::RichText::new("No document").color(t.text_faint).size(11.5));
+ ui.label(egui::RichText::new(tl!("No document")).color(t.text_faint).size(11.5));
return;
};
let doc = st.doc.clone();
@@ -51,7 +51,13 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if applied.is_none() {
crate::icons::paint(ui, marker, "check", 10.0, t.icon);
}
- ui.painter().text(pos2(rect.left() + 30.0, rect.center().y), Align2::LEFT_CENTER, "Last Document State", egui::FontId::proportional(12.0), t.text_dim);
+ ui.painter().text(
+ pos2(rect.left() + 30.0, rect.center().y),
+ Align2::LEFT_CENTER,
+ tl!("Last Document State"),
+ egui::FontId::proportional(12.0),
+ t.text_dim,
+ );
if resp.clicked() && doc.last_document_state.is_some() && applied.is_some() {
action = Some(("layerComp.restoreLastDocumentState", json!({})));
}
@@ -60,7 +66,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if doc.layer_comps.is_empty() {
ui.add_space(6.0);
ui.label(
- egui::RichText::new("Capture the visibility, position and style of every layer with + below, then switch between versions.")
+ egui::RichText::new(tl!("Capture the visibility, position and style of every layer with + below, then switch between versions."))
.color(t.text_faint)
.size(11.5),
);
@@ -80,9 +86,9 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
// The three apply toggles, right-aligned.
let toggles = [
- ("eye", "Visibility", c.apply_visibility, "visibility"),
- ("move", "Position", c.apply_position, "position"),
- ("sparkles", "Appearance (Layer Style)", c.apply_appearance, "appearance"),
+ ("eye", tl!("Visibility"), c.apply_visibility, "visibility"),
+ ("move", tl!("Position"), c.apply_position, "position"),
+ ("sparkles", tl!("Appearance (Layer Style)"), c.apply_appearance, "appearance"),
];
let mut x = rect.right() - 14.0;
let mut toggle_hit = false;
@@ -139,22 +145,22 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let has = !doc.layer_comps.is_empty();
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
- if crate::icons::button(ui, "chevrons-left", 24.0, false, "Apply previous selected layer comp").clicked() && has {
+ if crate::icons::button(ui, "chevrons-left", 24.0, false, tl!("Apply previous selected layer comp")).clicked() && has {
action = Some(("layerComp.previous", json!({})));
}
- if crate::icons::button(ui, "chevrons-right", 24.0, false, "Apply next selected layer comp").clicked() && has {
+ if crate::icons::button(ui, "chevrons-right", 24.0, false, tl!("Apply next selected layer comp")).clicked() && has {
action = Some(("layerComp.next", json!({})));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 24.0, false, "Delete layer comp").clicked()
+ if crate::icons::button(ui, "trash", 24.0, false, tl!("Delete layer comp")).clicked()
&& let Some(id) = selected
{
action = Some(("layerComp.delete", json!({"comp": id})));
}
- if crate::icons::button(ui, "file-plus", 24.0, false, "Create new layer comp").clicked() {
+ if crate::icons::button(ui, "file-plus", 24.0, false, tl!("Create new layer comp")).clicked() {
action = Some(("layerComp.new", json!({})));
}
- if crate::icons::button(ui, "rotate-cw", 24.0, false, "Update layer comp (visibility, position and appearance)").clicked()
+ if crate::icons::button(ui, "rotate-cw", 24.0, false, tl!("Update layer comp (visibility, position and appearance)")).clicked()
&& let Some(id) = selected
{
action = Some(("layerComp.update", json!({"comp": id})));
diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs
index 6b28e004c..55b91000c 100644
--- a/crates/ui-egui/src/dialogs.rs
+++ b/crates/ui-egui/src/dialogs.rs
@@ -43,7 +43,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
for d in dialogs {
let mut fields = d.fields.clone();
let mut outcome: Option<bool> = None; // Some(true)=OK, Some(false)=Cancel
- let title = title(&d);
+ let title = display_title(&d);
let id = egui::Id::new(("dialog", d.id));
// Offset from centre, moved by dragging the title bar (view state only, so egui memory).
let offset: egui::Vec2 = ctx.data(|m| m.get_temp(id)).unwrap_or_default();
@@ -89,8 +89,8 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
}
DialogKind::About => {
- ui.label("PhotoCraft — an open-source, native image editor written in Rust.");
- ui.label(format!("Version {}", photocraft_engine::build_info::long_version()));
+ ui.label(tl!("PhotoCraft — an open-source, native image editor written in Rust."));
+ ui.label(crate::i18n::fmt(tl!("Version {version}"), &[("version", &photocraft_engine::build_info::long_version())]));
ui.add_space(12.0);
ui.vertical_centered(|ui| {
crate::links::discord_button(app, ui, 220.0);
@@ -122,14 +122,14 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
ui.spacing_mut().item_spacing.x = 10.0;
if matches!(d.kind, DialogKind::About | DialogKind::Error) {
- if crate::widgets::primary_button(ui, "OK", 84.0).clicked() {
+ if crate::widgets::primary_button(ui, tl!("OK"), 84.0).clicked() {
outcome = Some(false);
}
} else {
let ok_label = if d.kind == DialogKind::NewDocument {
- "Create"
+ tl!("Create")
} else if d.fields.contains_key("__export") {
- "Export"
+ tl!("Export")
} else {
crate::file_ui::ok_label(&d.fields).unwrap_or("OK")
};
@@ -176,6 +176,20 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ctx.data_mut(|m| m.insert_temp(egui::Id::new(RECTS), shown));
}
+/// The dialog title as shown: [`title`] in the UI language.
+fn display_title(d: &Dialog) -> String {
+ match d.kind {
+ DialogKind::Command => {
+ let label = d.fields.get("__label").and_then(Value::as_str).unwrap_or("Command");
+ // Dialog labels are catalogued with their "…" ("Export As…"); some commands omit it.
+ let with_dots = format!("{}…", label.trim_end_matches('…'));
+ let shown = if crate::i18n::has(crate::i18n::current(), label) { tl!(label) } else { tl!(&with_dots) };
+ shown.trim_end_matches('…').to_string()
+ }
+ _ => tl!(&title(d)).to_string(),
+ }
+}
+
pub fn title(d: &Dialog) -> String {
match d.kind {
DialogKind::NewDocument => "New Document".into(),
diff --git a/crates/ui-egui/src/discard_ui.rs b/crates/ui-egui/src/discard_ui.rs
index cb64cbe52..44017286a 100644
--- a/crates/ui-egui/src/discard_ui.rs
+++ b/crates/ui-egui/src/discard_ui.rs
@@ -71,7 +71,7 @@ pub fn intercept(app: &mut PhotocraftApp, id: &str, params: &Value) -> bool {
// Repeated quit requests (the X pressed again) keep the prompt, and the answers so far.
Some(open) if open.id == id => {}
Some(_) => {
- app.ui.status = "Answer the unsaved-changes prompt first".into();
+ app.ui.status = tl!("Answer the unsaved-changes prompt first").into();
app.ui.status_error = true;
}
}
@@ -140,15 +140,19 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
return;
};
let (title, message) = if reverts {
- ("Revert", format!("Revert “{name}” to the last saved version? Your changes will be lost."))
+ ("Revert", crate::i18n::fmt(tl!("Revert “{name}” to the last saved version? Your changes will be lost."), &[("name", &name)]))
} else {
- let verb = if exits { "quitting" } else { "closing" };
- ("Unsaved changes", format!("Do you want to save the changes you made to “{name}” before {verb}?"))
+ let template = if exits {
+ tl!("Do you want to save the changes you made to “{name}” before quitting?")
+ } else {
+ tl!("Do you want to save the changes you made to “{name}” before closing?")
+ };
+ (tl!("Unsaved changes"), crate::i18n::fmt(template, &[("name", &name)]))
};
let (mut save_it, mut discard_it, mut cancel) = (false, false, false);
let modal = egui::Modal::new(egui::Id::new("discard-prompt")).show(ctx, |ui| {
ui.set_max_width(420.0);
- ui.label(egui::RichText::new(title).font(crate::theme::semibold(15.0)));
+ ui.label(egui::RichText::new(tl!(&title)).font(crate::theme::semibold(15.0)));
ui.add_space(4.0);
crate::widgets::hairline(ui);
ui.add_space(8.0);
@@ -157,12 +161,12 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.spacing_mut().item_spacing.x = 10.0;
if reverts {
- discard_it = crate::widgets::primary_button(ui, "Revert", 84.0).clicked();
- cancel = crate::widgets::secondary_button(ui, "Cancel", 84.0).clicked();
+ discard_it = crate::widgets::primary_button(ui, tl!("Revert"), 84.0).clicked();
+ cancel = crate::widgets::secondary_button(ui, tl!("Cancel"), 84.0).clicked();
} else {
- save_it = crate::widgets::primary_button(ui, "Save", 84.0).clicked();
- cancel = crate::widgets::secondary_button(ui, "Cancel", 84.0).clicked();
- discard_it = crate::widgets::secondary_button(ui, "Don't Save", 100.0).clicked();
+ save_it = crate::widgets::primary_button(ui, tl!("Save"), 84.0).clicked();
+ cancel = crate::widgets::secondary_button(ui, tl!("Cancel"), 84.0).clicked();
+ discard_it = crate::widgets::secondary_button(ui, tl!("Don't Save"), 100.0).clicked();
}
});
});
diff --git a/crates/ui-egui/src/doc_props_ui.rs b/crates/ui-egui/src/doc_props_ui.rs
index ac61db4d8..8a28a2dac 100644
--- a/crates/ui-egui/src/doc_props_ui.rs
+++ b/crates/ui-egui/src/doc_props_ui.rs
@@ -124,20 +124,20 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let (r, _) = ui.allocate_exact_size(vec2(24.0, 24.0), Sense::hover());
ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
icons::paint(ui, r, "file", 15.0, t.icon);
- ui.label(RichText::new("Document").color(t.text));
+ ui.label(RichText::new(tl!("Document")).color(t.text));
});
ui.add_space(4.0);
widgets::hairline(ui);
ui.add_space(2.0);
let label_w = 44.0;
- if section(ui, "canvas", "Canvas") {
+ if section(ui, "canvas", tl!("Canvas")) {
let link_key = egui::Id::new("doc-props-link");
let linked = ui.data(|d| d.get_temp::<bool>(link_key)).unwrap_or(false);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 4.0;
ui.vertical(|ui| {
ui.add_space(14.0);
- if icons::button(ui, if linked { "link" } else { "unlink" }, 22.0, linked, "Link width and height").clicked() {
+ if icons::button(ui, if linked { "link" } else { "unlink" }, 22.0, linked, tl!("Link width and height")).clicked() {
ui.data_mut(|d| d.insert_temp(link_key, !linked));
}
});
@@ -167,18 +167,18 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if icons::button(ui, "rectangle-vertical", 26.0, portrait, "Portrait").clicked() && !portrait && w != h {
run.push(("image.canvasSize".into(), json!({"width": h, "height": w, "anchor": "center"})));
}
- if icons::button(ui, "rectangle-horizontal", 26.0, !portrait, "Landscape").clicked() && portrait {
+ if icons::button(ui, "rectangle-horizontal", 26.0, !portrait, tl!("Landscape")).clicked() && portrait {
run.push(("image.canvasSize".into(), json!({"width": h, "height": w, "anchor": "center"})));
}
});
ui.add_space(2.0);
ui.horizontal(|ui| {
ui.add_space(label_w + 6.0);
- ui.label(RichText::new(format!("Resolution: {} pixels/inch", widgets::fmt_num(dpi as f64))).color(t.text));
+ ui.label(RichText::new(crate::i18n::fmt(tl!("Resolution: {dpi} pixels/inch"), &[("dpi", &widgets::fmt_num(dpi as f64))])).color(t.text));
});
ui.add_space(2.0);
ui.horizontal(|ui| {
- field_label(ui, "Mode", label_w);
+ field_label(ui, tl!("Mode"), label_w);
let mut m = mode;
let opts: Vec<(ColorMode, &str)> = MODES.iter().map(|(m, l, _)| (*m, *l)).collect();
if widgets::dropdown(ui, "doc-props-mode", &mut m, &opts, 150.0)
@@ -198,20 +198,20 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
});
ui.horizontal(|ui| {
- field_label(ui, "Fill", label_w);
+ field_label(ui, tl!("Fill"), label_w);
let (r, _) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::hover());
ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
// The canvas fill is only editable for documents without a Background layer.
ui.add_enabled_ui(!has_bg, |ui| {
let mut f = 0u8;
- widgets::dropdown(ui, "doc-props-fill", &mut f, &[(0u8, "Background Color")], 124.0);
+ widgets::dropdown(ui, "doc-props-fill", &mut f, &[(0u8, tl!("Background Color"))], 124.0);
});
});
ui.add_space(4.0);
}
widgets::hairline(ui);
ui.add_space(2.0);
- if section(ui, "rulers", "Rulers & Grids") {
+ if section(ui, "rulers", tl!("Rulers & Grids")) {
ui.horizontal(|ui| {
ui.add_space(8.0);
ui.spacing_mut().item_spacing.x = 6.0;
@@ -236,7 +236,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
widgets::hairline(ui);
ui.add_space(2.0);
- if section(ui, "guides", "Guides") {
+ if section(ui, "guides", tl!("Guides")) {
ui.horizontal(|ui| {
ui.add_space(8.0);
ui.spacing_mut().item_spacing.x = 6.0;
@@ -249,7 +249,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
run.push((id.to_string(), Value::Null));
}
}
- for (label, id) in [("New Guide…", "view.newGuide"), ("Clear", "view.clearGuides")] {
+ for (label, id) in [(tl!("New Guide…"), "view.newGuide"), (tl!("Clear"), "view.clearGuides")] {
if crate::menus::is_enabled(app, id) && widgets::secondary_button(ui, label, 0.0).clicked() {
run.push((id.to_string(), Value::Null));
}
diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs
index 4fb43c5cf..9ab9a05de 100644
--- a/crates/ui-egui/src/dock.rs
+++ b/crates/ui-egui/src/dock.rs
@@ -413,21 +413,21 @@ pub fn show(app: &mut PhotocraftApp, ui: &mut egui::Ui, shown: &[Group], mut bod
crate::layer_row_ui::panel_menu(app, ui);
ui.separator();
}
- if ui.button(if collapsed { "Expand Panel Group" } else { "Collapse Panel Group" }).clicked() {
+ if ui.button(if collapsed { tl!("Expand Panel Group") } else { tl!("Collapse Panel Group") }).clicked() {
actions.push(Action::ToggleCollapse(g));
ui.close();
}
let pos = order.iter().position(|x| *x == g).unwrap_or(0);
- if ui.add_enabled(!locked && pos > 0, egui::Button::new("Move Group Up")).clicked() {
+ if ui.add_enabled(!locked && pos > 0, egui::Button::new(tl!("Move Group Up"))).clicked() {
actions.push(Action::Move(g, order.get(pos.saturating_sub(1)).copied()));
ui.close();
}
- if ui.add_enabled(!locked && pos + 1 < order.len(), egui::Button::new("Move Group Down")).clicked() {
+ if ui.add_enabled(!locked && pos + 1 < order.len(), egui::Button::new(tl!("Move Group Down"))).clicked() {
actions.push(Action::Move(g, order.get(pos + 2).copied()));
ui.close();
}
ui.separator();
- if ui.button("Close Tab Group").clicked() {
+ if ui.button(tl!("Close Tab Group")).clicked() {
actions.push(Action::Close(g));
ui.close();
}
diff --git a/crates/ui-egui/src/eraser_ui.rs b/crates/ui-egui/src/eraser_ui.rs
index 15638ed44..fed6ade74 100644
--- a/crates/ui-egui/src/eraser_ui.rs
+++ b/crates/ui-egui/src/eraser_ui.rs
@@ -55,7 +55,7 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]]) -
fn opt(ui: &mut egui::Ui, text: &str) {
let t = Tokens::get(ui.ctx());
- ui.label(egui::RichText::new(text).color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!(&text)).color(t.text_dim).size(12.0));
}
/// Options bar for the Magic Eraser and Background Eraser. Returns false for other tools.
@@ -63,22 +63,22 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
let o = &mut app.ui.tool_options;
match tool {
Tool::MagicEraser => {
- opt(ui, "Tolerance:");
+ opt(ui, tl!("Tolerance:"));
widgets::value_field(ui, &mut o.tolerance, 0.0..=255.0, "", 58.0);
- widgets::checkbox(ui, &mut o.anti_alias, "Anti-alias");
- widgets::checkbox(ui, &mut o.contiguous, "Contiguous");
- widgets::checkbox(ui, &mut o.sample_all_layers, "Sample All Layers");
+ widgets::checkbox(ui, &mut o.anti_alias, tl!("Anti-alias"));
+ widgets::checkbox(ui, &mut o.contiguous, tl!("Contiguous"));
+ widgets::checkbox(ui, &mut o.sample_all_layers, tl!("Sample All Layers"));
widgets::vline(ui, 22.0);
- opt(ui, "Opacity:");
+ opt(ui, tl!("Opacity:"));
widgets::value_field(ui, &mut o.magic_eraser_opacity, 1.0..=100.0, "%", 62.0);
}
Tool::BackgroundEraser => {
// Sampling: Continuous / Once / Background Swatch, as icon toggles (Photoshop).
ui.spacing_mut().item_spacing.x = 2.0;
for (k, icon, tip) in [
- ("continuous", "pipette", "Sampling: Continuous"),
- ("once", "circle-dot", "Sampling: Once"),
- ("backgroundSwatch", "square", "Sampling: Background Swatch"),
+ ("continuous", "pipette", tl!("Sampling: Continuous")),
+ ("once", "circle-dot", tl!("Sampling: Once")),
+ ("backgroundSwatch", "square", tl!("Sampling: Background Swatch")),
] {
if icons::button(ui, icon, 24.0, o.bg_sampling == k, tip).clicked() {
o.bg_sampling = k.into();
@@ -86,12 +86,16 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
}
ui.spacing_mut().item_spacing.x = 8.0;
widgets::vline(ui, 22.0);
- opt(ui, "Limits:");
- let limits = [("discontiguous".to_string(), "Discontiguous"), ("contiguous".to_string(), "Contiguous"), ("findEdges".to_string(), "Find Edges")];
+ opt(ui, tl!("Limits:"));
+ let limits = [
+ ("discontiguous".to_string(), tl!("Discontiguous")),
+ ("contiguous".to_string(), tl!("Contiguous")),
+ ("findEdges".to_string(), tl!("Find Edges")),
+ ];
widgets::dropdown(ui, "bg-eraser-limits", &mut o.bg_limits, &limits, 110.0);
- opt(ui, "Tolerance:");
+ opt(ui, tl!("Tolerance:"));
widgets::value_field(ui, &mut o.bg_tolerance, 0.0..=100.0, "%", 62.0);
- widgets::checkbox(ui, &mut o.bg_protect_fg, "Protect Foreground Color");
+ widgets::checkbox(ui, &mut o.bg_protect_fg, tl!("Protect Foreground Color"));
}
_ => return false,
}
diff --git a/crates/ui-egui/src/export_dialog.rs b/crates/ui-egui/src/export_dialog.rs
index c6029a60c..4ba452494 100644
--- a/crates/ui-egui/src/export_dialog.rs
+++ b/crates/ui-egui/src/export_dialog.rs
@@ -117,9 +117,9 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
// Left: settings.
ui.vertical(|ui| {
ui.set_width(220.0);
- ui.label(egui::RichText::new("File Settings").font(crate::theme::semibold(12.0)).color(t.text));
+ ui.label(egui::RichText::new(tl!("File Settings")).font(crate::theme::semibold(12.0)).color(t.text));
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Format").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Format")).color(t.text_dim));
let mut fmt = s_fmt(f);
let opts: Vec<(String, &str)> = FORMATS.iter().map(|(k, l)| (k.to_string(), *l)).collect();
if crate::widgets::dropdown(ui, "export-format", &mut fmt, &opts, 130.0) {
@@ -129,18 +129,18 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
let fmt = s_fmt(f);
if fmt == "jpg" {
let mut q = n(f, "quality", 85.0) as f32;
- crate::widgets::slider_row(ui, "Quality", &mut q, 1.0..=100.0, "%", None);
+ crate::widgets::slider_row(ui, tl!("Quality"), &mut q, 1.0..=100.0, "%", None);
f.insert("quality".into(), json!(q.round()));
} else {
let mut tr = f.get("transparency").and_then(Value::as_bool).unwrap_or(true);
- crate::widgets::checkbox(ui, &mut tr, "Transparency");
+ crate::widgets::checkbox(ui, &mut tr, tl!("Transparency"));
f.insert("transparency".into(), json!(tr));
}
ui.add_space(8.0);
- ui.label(egui::RichText::new("Image Size").font(crate::theme::semibold(12.0)).color(t.text));
+ ui.label(egui::RichText::new(tl!("Image Size")).font(crate::theme::semibold(12.0)).color(t.text));
let mut sc = n(f, "scale", 100.0) as f32;
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Scale").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Scale")).color(t.text_dim));
crate::widgets::value_field(ui, &mut sc, 1.0..=1000.0, "%", 70.0);
});
f.insert("scale".into(), json!(sc.round()));
diff --git a/crates/ui-egui/src/file_ui.rs b/crates/ui-egui/src/file_ui.rs
index 1afe3ef08..1eefef472 100644
--- a/crates/ui-egui/src/file_ui.rs
+++ b/crates/ui-egui/src/file_ui.rs
@@ -23,7 +23,7 @@ fn default_dir(app: &PhotocraftApp) -> String {
}
fn doc_stem(app: &PhotocraftApp) -> String {
- app.session.active().map(|d| d.doc.name.rsplit_once('.').map_or(d.doc.name.clone(), |(a, _)| a.to_string())).unwrap_or_else(|| "Untitled".into())
+ app.session.active().map(|d| d.doc.name.rsplit_once('.').map_or(d.doc.name.clone(), |(a, _)| a.to_string())).unwrap_or_else(|| tl!("Untitled").into())
}
/// A generic form dialog for `command` (rendered by `view_cmds::form_body`).
@@ -63,7 +63,7 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &V
"file.automate.contactSheetII" => form(
app,
id,
- "Contact Sheet II",
+ tl!("Contact Sheet II"),
json!({"input": dir, "units": "inches", "width": 8.0, "height": 10.0, "resolution": 300.0, "mode": "rgb", "depth": 8, "columns": 5, "rows": 6, "placeAcrossFirst": true, "autoSpacing": true, "rotateForBestFit": false, "caption": true, "font": photocraft_text::fonts::DEFAULT_FAMILY, "fontSize": 12.0, "flatten": false}),
json!({"units": ["inches", "cm", "pixels"], "mode": ["rgb", "gray", "cmyk", "lab"]}),
),
@@ -78,7 +78,7 @@ pub fn invoke(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &V
form(
app,
id,
- "Create Droplet",
+ tl!("Create Droplet"),
json!({"path": format!("{dir}/{name}.pcdroplet"), "name": name, "steps": steps, "output": format!("{dir}/droplet-output"), "format": "same"}),
json!({"format": ["same", "png", "jpg", "psd", "tiff"]}),
)
@@ -141,9 +141,9 @@ pub fn dialog_width(f: &Map<String, Value>) -> Option<f32> {
pub fn ok_label(f: &Map<String, Value>) -> Option<&'static str> {
if f.contains_key("__web") {
- Some("Save…")
+ Some(tl!("Save…"))
} else if f.contains_key("__print") {
- Some("Print")
+ Some(tl!("Print"))
} else {
None
}
@@ -332,7 +332,7 @@ fn check(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str,
fn number(ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str, range: std::ops::RangeInclusive<f32>, unit: &str, d: f64) {
let t = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim));
let mut v = n(f, key, d) as f32;
crate::widgets::value_field(ui, &mut v, range, unit, 64.0);
f.insert(key.into(), json!(v.round()));
@@ -344,8 +344,8 @@ fn web_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
let Some(doc) = app.session.active().map(|d| d.doc.clone()) else { return };
ui.horizontal(|ui| {
let mut view = s(f, "__view", "2up");
- for (k, l) in [("original", "Original"), ("optimized", "Optimized"), ("2up", "2-Up"), ("4up", "4-Up")] {
- if ui.selectable_label(view == k, l).clicked() {
+ for (k, l) in [("original", tl!("Original")), ("optimized", tl!("Optimized")), ("2up", "2-Up"), ("4up", "4-Up")] {
+ if ui.selectable_label(view == k, tl!(&l)).clicked() {
view = k.into();
}
}
@@ -386,7 +386,7 @@ fn web_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
// Settings.
ui.vertical(|ui| {
ui.set_width(250.0);
- ui.label(egui::RichText::new("Preset").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Preset")).color(t.text_dim));
let mut preset = s(f, "__preset", "");
let mut opts: Vec<(String, &str)> = vec![("".into(), "[Unnamed]")];
opts.extend(web_cmds::PRESETS.iter().map(|p| (p.to_string(), *p)));
@@ -408,45 +408,52 @@ fn web_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
f,
"palette",
&[
- ("perceptual", "Perceptual"),
- ("selective", "Selective"),
- ("adaptive", "Adaptive"),
- ("restrictive", "Restrictive (Web)"),
- ("exact", "Exact"),
+ ("perceptual", tl!("Perceptual")),
+ ("selective", tl!("Selective")),
+ ("adaptive", tl!("Adaptive")),
+ ("restrictive", tl!("Restrictive (Web)")),
+ ("exact", tl!("Exact")),
],
150.0,
);
- number(ui, f, "colors", "Colors", 2.0..=256.0, "", 128.0);
+ number(ui, f, "colors", tl!("Colors"), 2.0..=256.0, "", 128.0);
dropdown_str(
ui,
"web-dither",
f,
"dither",
- &[("none", "No Dither"), ("diffusion", "Diffusion"), ("pattern", "Pattern"), ("noise", "Noise")],
+ &[("none", tl!("No Dither")), ("diffusion", tl!("Diffusion")), ("pattern", tl!("Pattern")), ("noise", tl!("Noise"))],
150.0,
);
- number(ui, f, "ditherAmount", "Dither", 0.0..=100.0, "%", 88.0);
- check(ui, f, "transparency", "Transparency", true);
- check(ui, f, "interlaced", "Interlaced", false);
- number(ui, f, "webSnap", "Web Snap", 0.0..=100.0, "%", 0.0);
+ number(ui, f, "ditherAmount", tl!("Dither"), 0.0..=100.0, "%", 88.0);
+ check(ui, f, "transparency", tl!("Transparency"), true);
+ check(ui, f, "interlaced", tl!("Interlaced"), false);
+ number(ui, f, "webSnap", tl!("Web Snap"), 0.0..=100.0, "%", 0.0);
}
"jpeg" => {
- number(ui, f, "quality", "Quality", 0.0..=100.0, "", 60.0);
- check(ui, f, "progressive", "Progressive", false);
- check(ui, f, "optimized", "Optimized", true);
- check(ui, f, "embedIcc", "Embed Color Profile", false);
+ number(ui, f, "quality", tl!("Quality"), 0.0..=100.0, "", 60.0);
+ check(ui, f, "progressive", tl!("Progressive"), false);
+ check(ui, f, "optimized", tl!("Optimized"), true);
+ check(ui, f, "embedIcc", tl!("Embed Color Profile"), false);
}
"wbmp" => {
- dropdown_str(ui, "web-dither", f, "dither", &[("none", "No Dither"), ("diffusion", "Diffusion"), ("pattern", "Pattern")], 150.0);
+ dropdown_str(
+ ui,
+ "web-dither",
+ f,
+ "dither",
+ &[("none", tl!("No Dither")), ("diffusion", tl!("Diffusion")), ("pattern", tl!("Pattern"))],
+ 150.0,
+ );
}
_ => {
- check(ui, f, "transparency", "Transparency", true);
- check(ui, f, "interlaced", "Interlaced", false);
+ check(ui, f, "transparency", tl!("Transparency"), true);
+ check(ui, f, "interlaced", tl!("Interlaced"), false);
}
}
if fmt != "png24" || !b(f, "transparency", true) {
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Matte").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Matte")).color(t.text_dim));
let mut m = s(f, "matte", "#ffffff");
if ui.add(egui::TextEdit::singleline(&mut m).desired_width(80.0)).changed() {
f.insert("matte".into(), json!(m));
@@ -454,21 +461,21 @@ fn web_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
});
}
ui.add_space(6.0);
- check(ui, f, "convertToSrgb", "Convert to sRGB", true);
+ check(ui, f, "convertToSrgb", tl!("Convert to sRGB"), true);
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Metadata").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Metadata")).color(t.text_dim));
dropdown_str(
ui,
"web-meta",
f,
"metadata",
- &[("none", "None"), ("copyright", "Copyright"), ("copyrightAndContact", "Copyright and Contact Info"), ("all", "All")],
+ &[("none", tl!("None")), ("copyright", tl!("Copyright")), ("copyrightAndContact", tl!("Copyright and Contact Info")), ("all", tl!("All"))],
160.0,
);
});
ui.add_space(8.0);
- ui.label(egui::RichText::new("Image Size").font(crate::theme::semibold(12.0)).color(t.text));
- number(ui, f, "percent", "Percent", 1.0..=1000.0, "%", 100.0);
+ ui.label(egui::RichText::new(tl!("Image Size")).font(crate::theme::semibold(12.0)).color(t.text));
+ number(ui, f, "percent", tl!("Percent"), 1.0..=1000.0, "%", 100.0);
let pct = n(f, "percent", 100.0) / 100.0;
ui.label(
egui::RichText::new(format!("W: {} px H: {} px", (f64::from(doc.size.width) * pct).round(), (f64::from(doc.size.height) * pct).round()))
@@ -479,8 +486,8 @@ fn web_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Valu
if !doc.slices.is_empty() {
ui.add_space(6.0);
ui.label(egui::RichText::new(format!("{nslices} slices")).color(t.text_dim));
- check(ui, f, "html", "Save HTML and Images", true);
- dropdown_str(ui, "web-slices", f, "slices", &[("all", "All Slices"), ("user", "All User Slices")], 150.0);
+ check(ui, f, "html", tl!("Save HTML and Images"), true);
+ dropdown_str(ui, "web-slices", f, "slices", &[("all", tl!("All Slices")), ("user", tl!("All User Slices"))], 150.0);
}
});
});
@@ -614,30 +621,30 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
ui.add_space(4.0);
ui.label(egui::RichText::new(s).font(crate::theme::semibold(12.0)).color(t.text));
};
- head(ui, "Printer Setup");
+ head(ui, tl!("Printer Setup"));
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Printer").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Printer")).color(t.text_dim));
let mut pr = s(f, "printer", "");
- if ui.add(egui::TextEdit::singleline(&mut pr).hint_text("Default printer").desired_width(180.0)).changed() {
+ if ui.add(egui::TextEdit::singleline(&mut pr).hint_text(tl!("Default printer")).desired_width(180.0)).changed() {
f.insert("printer".into(), json!(pr));
}
});
- number(ui, f, "copies", "Copies", 1.0..=999.0, "", 1.0);
+ number(ui, f, "copies", tl!("Copies"), 1.0..=999.0, "", 1.0);
ui.horizontal(|ui| {
let papers: Vec<(&str, &str)> = photocraft_engine::print_cmds::PAPERS.iter().map(|p| (p.0, p.0)).collect();
dropdown_str(ui, "print-paper", f, "paper", &papers, 110.0);
- dropdown_str(ui, "print-orient", f, "orientation", &[("portrait", "Portrait"), ("landscape", "Landscape")], 110.0);
+ dropdown_str(ui, "print-orient", f, "orientation", &[("portrait", tl!("Portrait")), ("landscape", tl!("Landscape"))], 110.0);
});
- head(ui, "Color Management");
+ head(ui, tl!("Color Management"));
dropdown_str(
ui,
"print-color",
f,
"colorHandling",
&[
- ("printerManages", "Printer Manages Colors"),
- ("photocraftManages", "PhotoCraft Manages Colors"),
- ("noColorManagement", "No Color Management"),
+ ("printerManages", tl!("Printer Manages Colors")),
+ ("photocraftManages", tl!("PhotoCraft Manages Colors")),
+ ("noColorManagement", tl!("No Color Management")),
],
240.0,
);
@@ -648,11 +655,11 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
f,
"printerProfile",
&[
- ("coated-cmyk", "Coated CMYK"),
+ ("coated-cmyk", tl!("Coated CMYK")),
("srgb", "sRGB IEC61966-2.1"),
- ("adobe-rgb-compat", "Adobe RGB (1998) compatible"),
- ("display-p3", "Display P3"),
- ("gray-gamma-2.2", "Gray Gamma 2.2"),
+ ("adobe-rgb-compat", tl!("Adobe RGB (1998) compatible")),
+ ("display-p3", tl!("Display P3")),
+ ("gray-gamma-2.2", tl!("Gray Gamma 2.2")),
],
240.0,
);
@@ -663,41 +670,41 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
f,
"intent",
&[
- ("perceptual", "Perceptual"),
- ("relative", "Relative Colorimetric"),
- ("saturation", "Saturation"),
- ("absolute", "Absolute Colorimetric"),
+ ("perceptual", tl!("Perceptual")),
+ ("relative", tl!("Relative Colorimetric")),
+ ("saturation", tl!("Saturation")),
+ ("absolute", tl!("Absolute Colorimetric")),
],
170.0,
);
- check(ui, f, "bpc", "Black Point Compensation", true);
+ check(ui, f, "bpc", tl!("Black Point Compensation"), true);
});
}
- head(ui, "Position and Size");
- check(ui, f, "center", "Center", true);
+ head(ui, tl!("Position and Size"));
+ check(ui, f, "center", tl!("Center"), true);
if !b(f, "center", true) {
ui.horizontal(|ui| {
- number(ui, f, "top", "Top", 0.0..=100.0, "in", 0.0);
- number(ui, f, "left", "Left", 0.0..=100.0, "in", 0.0);
+ number(ui, f, "top", tl!("Top"), 0.0..=100.0, "in", 0.0);
+ number(ui, f, "left", tl!("Left"), 0.0..=100.0, "in", 0.0);
});
}
- check(ui, f, "scaleToFit", "Scale to Fit Media", false);
+ check(ui, f, "scaleToFit", tl!("Scale to Fit Media"), false);
if !b(f, "scaleToFit", false) {
- number(ui, f, "scale", "Scale", 1.0..=1000.0, "%", 100.0);
+ number(ui, f, "scale", tl!("Scale"), 1.0..=1000.0, "%", 100.0);
}
- head(ui, "Printing Marks");
+ head(ui, tl!("Printing Marks"));
ui.horizontal(|ui| {
- check(ui, f, "cornerCropMarks", "Corner Crop Marks", false);
- check(ui, f, "centerCropMarks", "Center Crop Marks", false);
+ check(ui, f, "cornerCropMarks", tl!("Corner Crop Marks"), false);
+ check(ui, f, "centerCropMarks", tl!("Center Crop Marks"), false);
});
ui.horizontal(|ui| {
- check(ui, f, "registrationMarks", "Registration Marks", false);
- check(ui, f, "description", "Description", false);
- check(ui, f, "labels", "Labels", false);
+ check(ui, f, "registrationMarks", tl!("Registration Marks"), false);
+ check(ui, f, "description", tl!("Description"), false);
+ check(ui, f, "labels", tl!("Labels"), false);
});
- head(ui, "Save as PDF");
+ head(ui, tl!("Save as PDF"));
let mut out = s(f, "output", "");
- if ui.add(egui::TextEdit::singleline(&mut out).hint_text("(print to the printer)").desired_width(300.0)).changed() {
+ if ui.add(egui::TextEdit::singleline(&mut out).hint_text(tl!("(print to the printer)")).desired_width(300.0)).changed() {
f.insert("output".into(), json!(out));
}
});
diff --git a/crates/ui-egui/src/filter_dialog.rs b/crates/ui-egui/src/filter_dialog.rs
index 12cc28824..5389ea55b 100644
--- a/crates/ui-egui/src/filter_dialog.rs
+++ b/crates/ui-egui/src/filter_dialog.rs
@@ -323,7 +323,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
f.get("__docs").and_then(Value::as_array).map(|a| a.iter().filter_map(|v| v.as_str().map(str::to_string)).collect()).unwrap_or_default();
let cur = f.get(&p.key).and_then(Value::as_i64).unwrap_or(-1);
let mut sel = cur.to_string();
- let mut opts: Vec<(String, &str)> = vec![("-1".to_string(), "None")];
+ let mut opts: Vec<(String, &str)> = vec![("-1".to_string(), tl!("None"))];
opts.extend(names.iter().enumerate().map(|(i, n)| (i.to_string(), n.as_str())));
ui.horizontal(|ui| {
ui.label(egui::RichText::new(label(&p.key)).color(t.text_dim));
@@ -363,7 +363,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
if let Some(mut preview) = f.get("__preview").and_then(Value::as_bool) {
ui.add_space(4.0);
- crate::widgets::checkbox(ui, &mut preview, "Preview");
+ crate::widgets::checkbox(ui, &mut preview, tl!("Preview"));
f.insert("__preview".into(), json!(preview));
}
}
diff --git a/crates/ui-egui/src/gallery_ui.rs b/crates/ui-egui/src/gallery_ui.rs
index ac685b27e..d88364c46 100644
--- a/crates/ui-egui/src/gallery_ui.rs
+++ b/crates/ui-egui/src/gallery_ui.rs
@@ -356,7 +356,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let title = ERect::from_min_size(full.min, vec2(full.width(), 30.0));
painter.rect_filled(title, 0.0, t.dock);
painter.line_segment([title.left_bottom(), title.right_bottom()], Stroke::new(1.0, t.separator));
- let pct = if d.zoom > 0.0 { format!("{:.0}%", d.zoom * 100.0) } else { "Fit".into() };
+ let pct = if d.zoom > 0.0 { format!("{:.0}%", d.zoom * 100.0) } else { tl!("Fit").into() };
let name = d.effects.get(d.selected).map_or("", |e| e.filter.name());
painter.text(title.center(), Align2::CENTER_CENTER, format!("{name} ({}, {pct})", d.layer_name), FontId::proportional(13.0), t.text);
let body = ERect::from_min_max(pos2(full.left(), title.bottom()), full.max);
@@ -383,14 +383,15 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
painter.rect_filled(zoom_bar, 0.0, t.dock);
let mut zb = ui.new_child(egui::UiBuilder::new().max_rect(zoom_bar.shrink2(vec2(10.0, 3.0))).layout(egui::Layout::left_to_right(egui::Align::Center)));
let steps = [0.0f32, 0.125, 0.25, 0.5, 1.0, 2.0, 4.0];
- if crate::icons::button(&mut zb, "minus", 22.0, false, "Zoom out").clicked() {
+ if crate::icons::button(&mut zb, "minus", 22.0, false, tl!("Zoom out")).clicked() {
d.zoom = steps.iter().rev().copied().find(|&s| s > 0.0 && s < d.zoom.max(0.0) - 1e-3).unwrap_or(0.0);
}
- if crate::icons::button(&mut zb, "plus", 22.0, false, "Zoom in").clicked() {
+ if crate::icons::button(&mut zb, "plus", 22.0, false, tl!("Zoom in")).clicked() {
d.zoom = steps.iter().copied().find(|&s| s > d.zoom + 1e-3).unwrap_or(4.0);
}
let mut z = d.zoom;
- let opts: Vec<(f32, &str)> = vec![(0.0, "Fit in View"), (0.125, "12.5%"), (0.25, "25%"), (0.5, "50%"), (1.0, "100%"), (2.0, "200%"), (4.0, "400%")];
+ let opts: Vec<(f32, &str)> =
+ vec![(0.0, tl!("Fit in View")), (0.125, "12.5%"), (0.25, "25%"), (0.5, "50%"), (1.0, "100%"), (2.0, "200%"), (4.0, "400%")];
if widgets::dropdown(&mut zb, "gallery-zoom", &mut z, &opts, 110.0) {
d.zoom = z;
}
@@ -456,10 +457,10 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut ru = ui.new_child(egui::UiBuilder::new().max_rect(inner));
ru.spacing_mut().item_spacing.y = 6.0;
ru.horizontal(|ui| {
- if widgets::primary_button(ui, "OK", 120.0).clicked() {
+ if widgets::primary_button(ui, tl!("OK"), 120.0).clicked() {
action = Some("ok");
}
- if widgets::secondary_button(ui, "Cancel", 120.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Cancel"), 120.0).clicked() {
action = Some("cancel");
}
});
@@ -488,7 +489,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let labels: Vec<String> = options.iter().map(|o| crate::filter_dialog::label(o)).collect();
let opts: Vec<(String, &str)> = options.iter().cloned().zip(labels.iter().map(String::as_str)).collect();
ui.horizontal(|ui| {
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim));
widgets::dropdown(ui, &format!("gallery-{}", p.key), &mut c, &opts, 140.0);
});
e.params.insert(p.key, json!(c));
@@ -508,7 +509,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let neon = photocraft_algo::GalleryEffect::new(GalleryFilter::NeonGlow).color;
let mut rgb = c.map_or([neon[0], neon[1], neon[2]], |v| [v[0], v[1], v[2]]);
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Glow Color").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Glow Color")).color(t.text_dim));
ui.color_edit_button_rgb(&mut rgb);
});
e.params.insert("glowColor".into(), json!([rgb[0], rgb[1], rgb[2], 1.0]));
@@ -517,7 +518,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
}
if e.filter.uses_colours() {
- ui.label(egui::RichText::new("Uses the foreground and background colours.").color(t.text_faint).size(11.0));
+ ui.label(egui::RichText::new(tl!("Uses the foreground and background colours.")).color(t.text_faint).size(11.0));
}
});
// Effect layers (top of the list = applied last).
@@ -555,19 +556,19 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
});
lu.horizontal(|ui| {
- if crate::icons::button(ui, "chevron-up", 24.0, false, "Move effect layer up").clicked() {
+ if crate::icons::button(ui, "chevron-up", 24.0, false, tl!("Move effect layer up")).clicked() {
let s = d.selected;
d.move_to(s, (s + 1).min(d.effects.len() - 1));
}
- if crate::icons::button(ui, "chevron-down", 24.0, false, "Move effect layer down").clicked() {
+ if crate::icons::button(ui, "chevron-down", 24.0, false, tl!("Move effect layer down")).clicked() {
let s = d.selected;
d.move_to(s, s.saturating_sub(1));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 24.0, false, "Delete effect layer").clicked() {
+ if crate::icons::button(ui, "trash", 24.0, false, tl!("Delete effect layer")).clicked() {
d.delete();
}
- if crate::icons::button(ui, "file-plus", 24.0, false, "New effect layer").clicked() {
+ if crate::icons::button(ui, "file-plus", 24.0, false, tl!("New effect layer")).clicked() {
d.add();
}
});
diff --git a/crates/ui-egui/src/gradient_ui.rs b/crates/ui-egui/src/gradient_ui.rs
index 2a0f260eb..bdaa62af2 100644
--- a/crates/ui-egui/src/gradient_ui.rs
+++ b/crates/ui-egui/src/gradient_ui.rs
@@ -568,7 +568,7 @@ pub fn preset_swatch(ui: &mut egui::Ui, stops: &[(f32, [f32; 4])]) {
let (r, resp) = ui.allocate_exact_size(vec2(96.0, 20.0), Sense::hover());
paint_ramp(ui.painter(), r, |u| photocraft_algo::paint::sample_stops(stops, u));
ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);
- let _ = resp.on_hover_text("The current gradient (pick one in Window › Gradients)");
+ let _ = resp.on_hover_text(tl!("The current gradient (pick one in Window › Gradients)"));
}
/// Live mode: style, reverse and dither changes in the options bar also edit the selected
@@ -615,7 +615,7 @@ fn field(ui: &mut egui::Ui, id: &str, current: f32, range: std::ops::RangeInclus
fn label(ui: &mut egui::Ui, text: &str) {
let t = Tokens::get(ui.ctx());
let (r, _) = ui.allocate_exact_size(vec2(PROP_LABEL_W, 22.0), Sense::hover());
- ui.painter().text(pos2(r.left(), r.center().y), egui::Align2::LEFT_CENTER, text, egui::FontId::proportional(12.0), t.text_dim);
+ ui.painter().text(pos2(r.left(), r.center().y), egui::Align2::LEFT_CENTER, tl!(text), egui::FontId::proportional(12.0), t.text_dim);
}
/// Properties panel sections for a gradient fill layer (`props_layout::section` headers):
@@ -677,7 +677,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
}
});
ui.add_space(crate::theme::ROW_GAP);
- if widgets::secondary_button(ui, "Reset Alignment", ui.available_width()).on_hover_text("Centre the gradient (offset 0, 0)").clicked() {
+ if widgets::secondary_button(ui, "Reset Alignment", ui.available_width()).on_hover_text(tl!("Centre the gradient (offset 0, 0)")).clicked() {
runs.push(json!({"offset": [0, 0]}));
}
ui.add_space(crate::theme::ROW_GAP);
diff --git a/crates/ui-egui/src/i18n/catalog.rs b/crates/ui-egui/src/i18n/catalog.rs
new file mode 100644
index 000000000..22552aa4a
--- /dev/null
+++ b/crates/ui-egui/src/i18n/catalog.rs
@@ -0,0 +1,120 @@
+//! Parser and lookup tables for translation catalogs (`*.tsv`, format documented in `ja.tsv`).
+
+use std::collections::HashMap;
+
+/// A parsed catalog. Values are owned for the life of the process (catalogs are built once).
+#[derive(Debug, Default)]
+pub struct Catalog {
+ /// context-free strings: English source → translation (the hot path, looked up every frame)
+ plain: HashMap<String, String>,
+ /// strings with a disambiguating context, keyed `context \u{1} source`
+ contextual: HashMap<String, String>,
+ /// command-id keyed strings
+ ids: HashMap<String, String>,
+ /// plural messages: `one|other` → forms
+ plurals: HashMap<String, Vec<String>>,
+}
+
+/// A catalog entry as read from the file: (context, source, translation).
+pub type Entry = (String, String, String);
+
+fn unescape(s: &str) -> String {
+ let mut out = String::with_capacity(s.len());
+ let mut it = s.chars();
+ while let Some(c) = it.next() {
+ if c != '\\' {
+ out.push(c);
+ continue;
+ }
+ match it.next() {
+ Some('n') => out.push('\n'),
+ Some('t') => out.push('\t'),
+ Some('\\') => out.push('\\'),
+ Some(o) => {
+ out.push('\\');
+ out.push(o);
+ }
+ None => out.push('\\'),
+ }
+ }
+ out
+}
+
+/// Read the entries of a catalog file. Malformed lines are returned as errors (and skipped), so
+/// a bad translation never breaks the UI; the tests insist the bundled catalogs have none.
+pub fn parse_entries(text: &str) -> (Vec<Entry>, Vec<String>) {
+ let mut entries = Vec::new();
+ let mut errors = Vec::new();
+ for (n, line) in text.lines().enumerate() {
+ if line.trim().is_empty() || line.starts_with('#') {
+ continue;
+ }
+ let mut cols = line.split('\t');
+ match (cols.next(), cols.next(), cols.next(), cols.next()) {
+ (Some(ctx), Some(src), Some(tr), None) if !src.is_empty() && !tr.is_empty() => {
+ entries.push((unescape(ctx), unescape(src), unescape(tr)));
+ }
+ _ => errors.push(format!("line {}: expected `context<TAB>source<TAB>translation`", n + 1)),
+ }
+ }
+ (entries, errors)
+}
+
+impl Catalog {
+ pub fn parse(text: &str) -> Catalog {
+ let mut c = Catalog::default();
+ for (ctx, src, tr) in parse_entries(text).0 {
+ match ctx.as_str() {
+ "" => {
+ c.plain.insert(src, tr);
+ }
+ "@id" => {
+ c.ids.insert(src, tr);
+ }
+ "@plural" => {
+ c.plurals.insert(src, tr.split('|').map(str::to_string).collect());
+ }
+ _ => {
+ c.contextual.insert(format!("{ctx}\u{1}{src}"), tr);
+ }
+ }
+ }
+ c
+ }
+
+ pub fn plain(&self, s: &str) -> Option<&str> {
+ self.plain.get(s).map(String::as_str)
+ }
+
+ pub fn contextual(&self, ctx: &str, s: &str) -> Option<&str> {
+ self.contextual.get(&format!("{ctx}\u{1}{s}")).map(String::as_str)
+ }
+
+ pub fn id(&self, id: &str) -> Option<&str> {
+ self.ids.get(id).map(String::as_str)
+ }
+
+ /// The plural form `index` of the message whose English forms are `one|other`.
+ pub fn plural(&self, one: &str, other: &str, index: usize) -> Option<&str> {
+ let forms = self.plurals.get(&format!("{one}|{other}"))?;
+ forms.get(index.min(forms.len().saturating_sub(1))).map(String::as_str)
+ }
+}
+
+/// `{name}` placeholders of a template, in order of appearance.
+#[cfg(test)]
+pub fn placeholders(s: &str) -> Vec<&str> {
+ let mut out = Vec::new();
+ let mut rest = s;
+ while let Some(a) = rest.find('{') {
+ let after = &rest[a + 1..];
+ match after.find('}') {
+ Some(b) => {
+ out.push(&after[..b]);
+ rest = &after[b + 1..];
+ }
+ None => break,
+ }
+ }
+ out
+}
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
new file mode 100644
index 000000000..50fd61bf7
--- /dev/null
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -0,0 +1,1965 @@
+# Japanese (ja) catalog. Columns, separated by a TAB: context <TAB> source <TAB> translation
+#
+# context empty a plain UI string; `source` is the English text in the code
+# @id a command id (e.g. file.saveAs): wins over the English text for
+# that menu item, so one id can read differently from its twin
+# @plural `source` is "one|other" (English forms); the translation lists the
+# language's forms separated by "|" (see `plural` in i18n/mod.rs)
+# anything else a disambiguating context passed to `tr_ctx`
+# escapes \n \t \\ inside a column. `{name}` placeholders must appear in both columns.
+# lines starting with # and blank lines are ignored.
+#
+# Clean-room: every entry was written from the plain meaning of the English label using ordinary
+# Japanese computing vocabulary (レイヤー, ぼかし, 選択範囲 ...). No proprietary localisation
+# resource, string table or product UI was consulted or copied; add entries the same way.
+# Product and technology names (PhotoCraft, ArtCraft, OpenType, CMYK, Lab ...) stay in Latin
+# letters; the trailing "…" of dialog commands is kept.
+
+ File ファイル
+ Edit 編集
+ Image 画像
+ Layer レイヤー
+ Type 文字
+ Select 選択
+ Filter フィルター
+ View 表示
+ Window ウィンドウ
+ Help ヘルプ
+ (coming soon) (近日対応)
+ New… 新規…
+ Open… 開く…
+ Open As… 形式を指定して開く…
+ Open Recent 最近使ったファイルを開く
+ Clear Recent Files 最近使ったファイルを消去
+ Close 閉じる
+ Close All すべて閉じる
+ Close Others ほかを閉じる
+ Save 保存
+ Save As… 名前を付けて保存…
+ Save a Copy… コピーを保存…
+ Revert 復帰
+ Export 書き出し
+ Quick Export as PNG PNG としてクイック書き出し
+ Export As… 書き出し形式を指定…
+ Export Preferences… 書き出しの環境設定…
+ Save for Web (Legacy)… Web 用に保存(従来方式)…
+ Artboards to Files… アートボードをファイルへ…
+ Artboards to PDF… アートボードを PDF へ…
+ Layers to Files… レイヤーをファイルへ…
+ Layer Comps to Files… レイヤーカンプをファイルへ…
+ Color Lookup Tables… カラールックアップテーブル…
+ Data Sets as Files… データセットをファイルへ…
+ Paths to Illustrator… パスをベクター形式へ…
+ Render Video… ビデオを書き出し…
+ Generate 自動生成
+ Image Assets 画像アセット
+ Place Embedded… 埋め込みで配置…
+ Place Linked… リンクで配置…
+ Package… パッケージ化…
+ Automate 自動処理
+ Batch… バッチ処理…
+ Create Droplet… ドロップレットを作成…
+ Crop and Straighten Photos 写真を切り抜いて傾き補正
+ Contact Sheet II… コンタクトシート II…
+ Conditional Mode Change… 条件付きカラーモード変更…
+ Fit Image… 画像を枠に合わせる…
+ Lens Correction… レンズ補正…
+ Merge to HDR Pro… HDR 合成(Pro)…
+ Photomerge… 写真を貼り合わせ…
+ Scripts スクリプト
+ Image Processor… 画像プロセッサー…
+ Delete All Empty Layers 空のレイヤーをすべて削除
+ Flatten All Layer Effects すべてのレイヤー効果を統合
+ Flatten All Masks すべてのマスクを統合
+ Script Events Manager… スクリプトイベント管理…
+ Import 読み込み
+ Browse… 参照…
+ Reveal in Finder Finder で表示
+ File Info… ファイル情報…
+ Print… プリント…
+ Print One Copy 1 部プリント
+ Exit 終了
+ Undo 取り消し
+ Redo やり直し
+ Toggle Last State 直前の状態と切り替え
+ Fade… フェード…
+ Cut 切り取り
+ Copy コピー
+ Copy Merged 統合部分をコピー
+ Paste 貼り付け
+ Paste Special 特殊貼り付け
+ Paste in Place 同じ位置に貼り付け
+ Paste Into 選択範囲内に貼り付け
+ Paste Outside 選択範囲外に貼り付け
+ Paste Lorem Ipsum ダミーテキストを貼り付け
+ Clear 消去
+ Search… 検索…
+ Check Spelling… スペルチェック…
+ Find and Replace Text… テキストを検索して置換…
+ Fill… 塗りつぶし…
+ Stroke… 境界線を描く…
+ Content-Aware Fill… コンテンツに応じた塗りつぶし…
+ Content-Aware Scale コンテンツに応じた拡大・縮小
+ Puppet Warp パペットワープ
+ Perspective Warp 遠近法ワープ
+ Free Transform 自由変形
+ Transform 変形
+ Again もう一度
+ Scale 拡大・縮小
+ Rotate 回転
+ Skew 斜体
+ Distort ゆがみ
+ Perspective 遠近法
+ Warp ワープ
+ Flip Horizontal 水平方向に反転
+ Flip Vertical 垂直方向に反転
+ Rotate 180° 180°回転
+ Rotate 90° Clockwise 時計回りに 90°回転
+ Rotate 90° Counter Clockwise 反時計回りに 90°回転
+ 180° 180°
+ 90° Clockwise 時計回りに 90°
+ 90° Counter Clockwise 反時計回りに 90°
+ Arbitrary… 角度を指定…
+ Auto-Align Layers… レイヤーを自動整列…
+ Auto-Blend Layers… レイヤーを自動合成…
+ Define Brush Preset… ブラシプリセットを定義…
+ Define Pattern… パターンを定義…
+ Define Custom Shape… カスタムシェイプを定義…
+ Purge メモリを解放
+ Clipboard クリップボード
+ Histories ヒストリー
+ Video Cache ビデオキャッシュ
+ All すべて
+ Presets プリセット
+ Preset Manager… プリセットマネージャー…
+ Migrate Presets プリセットを移行
+ Export/Import Presets… プリセットの書き出し/読み込み…
+ Color Settings… カラー設定…
+ Assign Profile… プロファイルを割り当て…
+ Convert to Profile… プロファイルを変換…
+ Keyboard Shortcuts… キーボードショートカット…
+ Menus… メニュー…
+ Toolbar… ツールバー…
+ Preferences 環境設定
+ General… 一般…
+ Interface… インターフェイス…
+ Workspace… ワークスペース…
+ Tools… ツール…
+ History Log… ヒストリーログ…
+ File Handling… ファイル管理…
+ Export… 書き出し…
+ Performance… パフォーマンス…
+ Scratch Disks… スクラッチディスク…
+ Cursors… カーソル…
+ Transparency & Gamut… 透明部分・色域…
+ Units & Rulers… 単位・定規…
+ Guides, Grid & Slices… ガイド・グリッド・スライス…
+ Plug-ins… プラグイン…
+ Type… 文字…
+ Enhanced Controls… 拡張コントロール…
+ Camera Raw… Camera Raw…
+ Raw Defaults… RAW の既定値…
+ Integrations… 連携…
+ AI Integrations… AI 連携…
+ Install Plug-in… プラグインをインストール…
+ Language Options 言語オプション
+ Settings… 設定…
+ Mode モード
+ Bitmap ビットマップ
+ Grayscale グレースケール
+ Duotone ダブルトーン
+ Indexed Color インデックスカラー
+ RGB Color RGB カラー
+ CMYK Color CMYK カラー
+ Lab Color Lab カラー
+ Multichannel マルチチャンネル
+ 8 Bits/Channel 8 ビット/チャンネル
+ 16 Bits/Channel 16 ビット/チャンネル
+ 32 Bits/Channel 32 ビット/チャンネル
+ Color Table… カラーテーブル…
+ Bitmap… ビットマップ…
+ Duotone… ダブルトーン…
+ Indexed Color… インデックスカラー…
+ Adjustments 色調補正
+ Brightness/Contrast… 明るさ・コントラスト…
+ Levels… レベル補正…
+ Curves… トーンカーブ…
+ Exposure… 露光量…
+ Vibrance… 自然な彩度…
+ Hue/Saturation… 色相・彩度…
+ Color Balance… カラーバランス…
+ Black & White… 白黒…
+ Photo Filter… 写真フィルター…
+ Channel Mixer… チャンネルミキサー…
+ Color Lookup… カラールックアップ…
+ Invert 階調の反転
+ Posterize… ポスタリゼーション…
+ Threshold… 2 階調化…
+ Gradient Map… グラデーションマップ…
+ Selective Color… 特定色域の選択…
+ Shadows/Highlights… シャドウ・ハイライト…
+ HDR Toning… HDR トーン…
+ Desaturate 彩度を下げる
+ Match Color… カラーを一致…
+ Replace Color… 色を置き換え…
+ Equalize 平均化
+ Auto Tone 自動トーン補正
+ Auto Contrast 自動コントラスト
+ Auto Color 自動カラー補正
+ Image Size… 画像サイズ…
+ Canvas Size… カンバスサイズ…
+ Image Rotation 画像の回転
+ Flip Canvas Horizontal カンバスを水平方向に反転
+ Flip Canvas Vertical カンバスを垂直方向に反転
+ Crop 切り抜き
+ Trim… トリミング…
+ Reveal All すべてのコンテンツを表示
+ Duplicate… 複製…
+ Apply Image… 画像を適用…
+ Calculations… 演算…
+ Variables 変数
+ Define… 定義…
+ Data Sets… データセット…
+ Apply Data Set… データセットを適用…
+ Variable Data Sets… 変数データセット…
+ Trap… トラップ…
+ Analysis 分析
+ Set Measurement Scale… 測定スケールを設定…
+ Select Data Points… データポイントを選択…
+ Record Measurements 測定値を記録
+ Ruler Tool 定規ツール
+ Count Tool カウントツール
+ Place Scale Marker… スケールマーカーを配置…
+ Custom… カスタム…
+ New 新規
+ Layer… レイヤー…
+ Group… グループ…
+ Group from Layers… レイヤーからグループ…
+ Artboard… アートボード…
+ Artboard from Group… グループからアートボード…
+ Artboard from Layers… レイヤーからアートボード…
+ Layer via Copy コピーしたレイヤー
+ Layer via Cut 切り取ったレイヤー
+ Layer From Background… 背景からレイヤーへ…
+ Layer from Background… 背景からレイヤーへ…
+ New Shape Layer 新規シェイプレイヤー
+ New Type Layer 新規文字レイヤー
+ New Fill Layer 新規塗りつぶしレイヤー
+ New Adjustment Layer 新規色調補正レイヤー
+ New Layer Based Slice レイヤーに基づく新規スライス
+ New Smart Object via Copy コピーしたスマートオブジェクト
+ New Blank Video Layer 新規空白ビデオレイヤー
+ New Video Layer from File… ファイルから新規ビデオレイヤー…
+ Duplicate Layer… レイヤーを複製…
+ Delete Layer レイヤーを削除
+ Delete 削除
+ Rename Layer レイヤー名を変更
+ Create Layer レイヤーを作成
+ Layer Style レイヤースタイル
+ Blending Options… レイヤー効果の描画オプション…
+ Bevel & Emboss… ベベルとエンボス…
+ Inner Shadow… シャドウ(内側)…
+ Inner Glow… 光彩(内側)…
+ Satin… サテン…
+ Color Overlay… カラーオーバーレイ…
+ Gradient Overlay… グラデーションオーバーレイ…
+ Pattern Overlay… パターンオーバーレイ…
+ Outer Glow… 光彩(外側)…
+ Drop Shadow… ドロップシャドウ…
+ Copy Layer Style レイヤースタイルをコピー
+ Paste Layer Style レイヤースタイルを貼り付け
+ Clear Layer Style レイヤースタイルを消去
+ Global Light… グローバル光源…
+ Hide All Effects すべての効果を非表示
+ Scale Effects… 効果を拡大・縮小…
+ Smart Filter スマートフィルター
+ Convert for Smart Filters スマートフィルター用に変換
+ Clear Smart Filters スマートフィルターを消去
+ Disable Smart Filters スマートフィルターを無効にする
+ Delete Filter Mask フィルターマスクを削除
+ Disable Filter Mask フィルターマスクを無効にする
+ Solid Color… べた塗り…
+ Gradient… グラデーション…
+ Pattern… パターン…
+ Layer Mask レイヤーマスク
+ Vector Mask ベクトルマスク
+ Reveal Selection 選択範囲を表示
+ Hide Selection 選択範囲を非表示
+ Hide All すべて非表示
+ From Transparency 透明部分から
+ Delete Vector Mask ベクトルマスクを削除
+ Enable Layer Mask レイヤーマスクを有効にする
+ Disable Layer Mask レイヤーマスクを無効にする
+ Enable Vector Mask ベクトルマスクを有効にする
+ Link Layer Mask レイヤーマスクをリンク
+ Unlink Layer Mask レイヤーマスクのリンクを解除
+ Link Vector Mask ベクトルマスクをリンク
+ Add Vector Mask ベクトルマスクを追加
+ Vector Mask from Current Path 現在のパスからベクトルマスク
+ Create Clipping Mask クリッピングマスクを作成
+ Release Clipping Mask クリッピングマスクを解除
+ Smart Objects スマートオブジェクト
+ Smart Object スマートオブジェクト
+ Convert to Smart Object スマートオブジェクトに変換
+ Convert to Embedded 埋め込みに変換
+ Convert to Linked… リンクに変換…
+ Edit Contents コンテンツを編集
+ Replace Contents… コンテンツを置き換え…
+ Relink to File… ファイルに再リンク…
+ Export Contents… コンテンツを書き出し…
+ Update Modified Content 変更されたコンテンツを更新
+ Update All Modified Content 変更されたコンテンツをすべて更新
+ Stack Mode スタックモード
+ Entropy エントロピー
+ Kurtosis 尖度
+ Maximum 最大値
+ Mean 平均
+ Median 中央値
+ Minimum 最小値
+ Range 範囲
+ Skewness 歪度
+ Standard Deviation 標準偏差
+ Summation 総和
+ Variance 分散
+ Video Layers ビデオレイヤー
+ Interpret Footage… 素材を解釈…
+ Replace Footage… 素材を置き換え…
+ Reload Frame フレームを再読み込み
+ Show Altered Video 変更されたビデオを表示
+ Restore Frame フレームを復元
+ Restore All Frames すべてのフレームを復元
+ Insert Blank Frame 空白フレームを挿入
+ Delete Frame フレームを削除
+ Duplicate Frame フレームを複製
+ Frame from Layers レイヤーからフレーム
+ Video Frames to Layers… ビデオフレームをレイヤーへ…
+ Rasterize ラスタライズ
+ Rasterize Type 文字をラスタライズ
+ Rasterize Type Layer 文字レイヤーをラスタライズ
+ Rasterize Shape シェイプをラスタライズ
+ New Guide Layout… 新規ガイドレイアウト…
+ New Guides From Shape シェイプから新規ガイド
+ Lock Layers… レイヤーをロック…
+ Link Layers レイヤーをリンク
+ Select Linked Layers リンクしたレイヤーを選択
+ Merge Layers レイヤーを結合
+ Merge Down 下のレイヤーと結合
+ Merge Visible 表示レイヤーを結合
+ Flatten Image 画像を統合
+ Matting マット処理
+ Color Decontaminate… カラーの混入を除去…
+ Remove Black Matte 黒マットを削除
+ Remove White Matte 白マットを削除
+ Defringe… フリンジ削除…
+ Group Layers レイヤーをグループ化
+ Ungroup Layers レイヤーのグループ化を解除
+ Hide Layers レイヤーを非表示
+ Arrange 重ね順
+ Bring to Front 最前面へ
+ Bring Forward 前面へ
+ Send Backward 背面へ
+ Send to Back 最背面へ
+ Reverse 反転
+ Combine Shapes シェイプを合成
+ Unite Shapes シェイプを結合
+ Subtract Front Shape 前面シェイプで型抜き
+ Intersect Shape Areas シェイプの重なりを抽出
+ Exclude Overlapping Shapes シェイプの重なりを除外
+ Merge Shape Components シェイプの構成要素を結合
+ Align 整列
+ Top Edges 上端
+ Vertical Centers 垂直方向の中央
+ Bottom Edges 下端
+ Left Edges 左端
+ Horizontal Centers 水平方向の中央
+ Right Edges 右端
+ Distribute 分布
+ Vertically 垂直方向
+ Horizontally 水平方向
+ Layer Edges レイヤーの端
+ Isolate Layers レイヤーを単独表示
+ Layer Content Options… レイヤーコンテンツのオプション…
+ Fill Content 塗りの内容
+ Deselect Layers レイヤーの選択を解除
+ Find Layers レイヤーを検索
+ Layer Comps レイヤーカンプ
+ Layers レイヤー
+ All Layers すべてのレイヤー
+ Hidden Layers 非表示のレイヤー
+ Mask All Objects すべてのオブジェクトをマスク
+ Subject 被写体
+ Sky 空
+ Panels パネル
+ Character Panel 文字パネル
+ Paragraph Panel 段落パネル
+ Character Styles Panel 文字スタイルパネル
+ Paragraph Styles Panel 段落スタイルパネル
+ Glyphs Panel 字形パネル
+ Anti-Alias アンチエイリアス
+ Sharp シャープ
+ Crisp 鮮明
+ Strong 強く
+ Smooth 滑らか
+ Windows LCD Windows LCD
+ Windows Windows
+ Orientation 方向
+ Horizontal 横書き
+ Vertical 縦書き
+ OpenType OpenType
+ Standard Ligatures 標準合字
+ Contextual Alternates 文脈検索代替字形
+ Discretionary Ligatures 任意の合字
+ Swash スワッシュ
+ Oldstyle オールドスタイル数字
+ Stylistic Alternates スタイル代替字形
+ Titling Alternates タイトル用代替字形
+ Ornaments 装飾記号
+ Ordinals 序数
+ Fractions 分数
+ Create Work Path 作業用パスを作成
+ Convert to Shape シェイプに変換
+ Warp Text… 文字ワープ…
+ Convert to Point Text ポイント文字に変換
+ Convert to Paragraph Text 段落文字に変換
+ Default Features 既定の機能
+ East Asian Features 東アジア言語の機能
+ Middle Eastern Features 中東言語の機能
+ Middle Eastern & South Asian Composer 中東・南アジア言語の組版エンジン
+ Update All Text Layers すべての文字レイヤーを更新
+ Replace All Missing Fonts 不足しているフォントをすべて置き換え
+ Resolve Missing Fonts… 不足しているフォントを解決…
+ Font Preview Size フォントのプレビューサイズ
+ None なし
+ Small 小
+ Medium 中
+ Large 大
+ Extra Large 特大
+ Huge 最大
+ Load Default Type Styles 既定の文字スタイルを読み込み
+ Save Default Type Styles 既定の文字スタイルを保存
+ Deselect 選択を解除
+ Reselect 再選択
+ Inverse 選択範囲を反転
+ Inverse Selection 選択範囲を反転
+ Similar 近似色を選択
+ Color Range… 色域指定…
+ Focus Area… 焦点領域…
+ Select and Mask… 選択とマスク…
+ Modify 選択範囲を修正
+ Border… 境界…
+ Smooth… 滑らかに…
+ Expand… 拡張…
+ Contract… 縮小…
+ Feather… 境界をぼかす…
+ Grow 選択範囲を広げる
+ Transform Selection 選択範囲を変形
+ Edit in Quick Mask Mode クイックマスクモードで編集
+ Load Selection… 選択範囲を読み込む…
+ Save Selection… 選択範囲を保存…
+ Match All すべて一致
+ Last Filter 直前のフィルター
+ Filter Gallery… フィルターギャラリー…
+ Adaptive Wide Angle… 広角補正…
+ Camera Raw Filter… Camera Raw フィルター…
+ Liquify… ゆがみ…
+ Vanishing Point… 消点…
+ Blur ぼかし
+ Blur Gallery ぼかしギャラリー
+ Field Blur… フィールドぼかし…
+ Iris Blur… 虹彩絞りぼかし…
+ Tilt-Shift… チルトシフト…
+ Path Blur… パスぼかし…
+ Spin Blur… 回転ぼかし…
+ Blur More ぼかし(強)
+ Box Blur… ぼかし(ボックス)…
+ Gaussian Blur… ぼかし(ガウス)…
+ Lens Blur… ぼかし(レンズ)…
+ Motion Blur… ぼかし(移動)…
+ Radial Blur… ぼかし(円形)…
+ Shape Blur… ぼかし(シェイプ)…
+ Smart Blur… ぼかし(詳細)…
+ Surface Blur… ぼかし(表面)…
+ Average 平均
+ Displace… 置き換え…
+ Pinch… つまみ…
+ Polar Coordinates… 極座標…
+ Ripple… 波紋…
+ Shear… シアー…
+ Spherize… 球面…
+ Twirl… 渦巻き…
+ Wave… 波形…
+ ZigZag… ジグザグ…
+ Noise ノイズ
+ Add Noise… ノイズを加える…
+ Despeckle ダスト除去
+ Dust & Scratches… ダスト&スクラッチ…
+ Median… メディアン…
+ Reduce Noise… ノイズを軽減…
+ Pixelate ピクセレート
+ Color Halftone… カラーハーフトーン…
+ Crystallize… 水晶…
+ Facet ファセット
+ Fragment フラグメント
+ Mezzotint… メゾティント…
+ Mosaic… モザイク…
+ Pointillize… ポインティリスト…
+ Render 描画
+ Clouds 雲模様
+ Difference Clouds 雲模様(差の絶対値)
+ Fibers… 繊維…
+ Flame… 炎…
+ Lens Flare… レンズフレア…
+ Lighting Effects… 照明効果…
+ Picture Frame… フレーム…
+ Tree… 木…
+ Sharpen シャープ
+ Sharpen Edges 輪郭のみシャープ
+ Sharpen More シャープ(強)
+ Smart Sharpen… スマートシャープ…
+ Unsharp Mask… アンシャープマスク…
+ High Pass… ハイパス…
+ Stylize 表現手法
+ Diffuse… 拡散…
+ Emboss… エンボス…
+ Extrude… 押し出し…
+ Find Edges 輪郭検出
+ Oil Paint… 油彩画…
+ Solarize ソラリゼーション
+ Tiles… タイル…
+ Trace Contour… 輪郭のトレース…
+ Wind… 風…
+ Video ビデオ
+ De-Interlace… インターレース解除…
+ NTSC Colors NTSC カラー
+ Other その他
+ Maximum… 最大値…
+ Minimum… 最小値…
+ Offset… オフセット…
+ Plug-ins プラグイン
+ Proof Setup 校正設定
+ Proof Colors 色の校正
+ Gamut Warning 色域外警告
+ Working CMYK 作業用 CMYK
+ Working Cyan Plate 作業用シアン版
+ Working Magenta Plate 作業用マゼンタ版
+ Working Yellow Plate 作業用イエロー版
+ Working Black Plate 作業用ブラック版
+ Working CMY Plate 作業用 CMY 版
+ Legacy Macintosh RGB 旧 Macintosh RGB
+ Internet Standard RGB インターネット標準 RGB
+ Monitor RGB モニター RGB
+ Color Blindness — Protanopia-type 色覚特性 — 1 型(P 型)
+ Color Blindness — Deuteranopia-type 色覚特性 — 2 型(D 型)
+ Zoom In 拡大
+ Zoom Out 縮小
+ Fit on Screen 画面サイズに合わせる
+ Fit Layer(s) on Screen レイヤーを画面サイズに合わせる
+ Fit Artboard on Screen アートボードを画面サイズに合わせる
+ 100% 100%
+ 200% 200%
+ Print Size 印刷サイズ
+ Pixel Aspect Ratio ピクセル縦横比
+ Pixel Aspect Ratio Correction ピクセル縦横比を補正
+ Custom Pixel Aspect Ratio… ピクセル縦横比をカスタム…
+ Square 正方形ピクセル
+ D1/DV NTSC (0.91) D1/DV NTSC (0.91)
+ D1/DV NTSC Widescreen (1.21) D1/DV NTSC ワイド (1.21)
+ D1/DV PAL (1.09) D1/DV PAL (1.09)
+ D1/DV PAL Widescreen (1.46) D1/DV PAL ワイド (1.46)
+ Anamorphic 2:1 (2) アナモルフィック 2:1 (2)
+ HDV 1080/DVCPRO HD 720 (1.33) HDV 1080/DVCPRO HD 720 (1.33)
+ DVCPRO HD 1080/HDV 1080 (1.5) DVCPRO HD 1080/HDV 1080 (1.5)
+ 32-bit Preview Options… 32 ビットプレビューオプション…
+ Screen Mode スクリーンモード
+ Standard Screen Mode 標準スクリーンモード
+ Full Screen Mode With Menu Bar メニューバーありのフルスクリーンモード
+ Full Screen Mode フルスクリーンモード
+ Cycle Screen Mode スクリーンモードを切り替え
+ Show 表示する項目
+ Extras エクストラ
+ Selection Edges 選択範囲の境界線
+ Target Path ターゲットパス
+ Current Path 現在のパス
+ Grid グリッド
+ Guides ガイド
+ Canvas Guides カンバスガイド
+ Artboard Guides アートボードガイド
+ Count カウント
+ Smart Guides スマートガイド
+ Slices スライス
+ Notes 注釈
+ Pixel Grid ピクセルグリッド
+ Pixel Art ピクセルアート
+ Pixel Art Preview ピクセルアートのプレビュー
+ Pattern Preview パターンプレビュー
+ Brush Preview ブラシプレビュー
+ Mesh メッシュ
+ Edit Pins ピンを編集
+ Document Bounds ドキュメントの境界
+ Show Extras Options… エクストラの表示オプション…
+ Rulers 定規
+ Snap スナップ
+ Snap To スナップ先
+ Lock Guides ガイドをロック
+ Clear Guides ガイドを消去
+ Clear Selected Artboard Guides 選択したアートボードのガイドを消去
+ Clear Canvas Guides カンバスガイドを消去
+ New Guide… 新規ガイド…
+ Lock Slices スライスをロック
+ Clear Slices スライスを消去
+ Match Zoom ズームを一致
+ Match Location 位置を一致
+ Match Rotation 回転を一致
+ Cascade 重ねて表示
+ Tile 並べて表示
+ Tile All Horizontally すべてを横に並べる
+ Tile All Vertically すべてを縦に並べる
+ 2-up Horizontal 2 アップ(横)
+ 2-up Vertical 2 アップ(縦)
+ 3-up Horizontal 3 アップ(横)
+ 3-up Stacked 3 アップ(積み重ね)
+ 3-up Vertical 3 アップ(縦)
+ 4-up 4 アップ
+ 6-up 6 アップ
+ Consolidate All to Tabs すべてをタブに統合
+ Float in Window ウィンドウ内に浮動
+ Float All in Windows すべてをウィンドウ内に浮動
+ New Window for Document ドキュメントの新規ウィンドウ
+ Workspace ワークスペース
+ Essentials 基本
+ Graphic and Web グラフィックと Web
+ Painting ペイント
+ Photography 写真
+ New Workspace… 新規ワークスペース…
+ Delete Workspace… ワークスペースを削除…
+ Reset Workspace ワークスペースをリセット
+ Lock Workspace ワークスペースをロック
+ Theme テーマ
+ Pro Theme プロテーマ
+ Pro Medium Gray Theme プロ(中間グレー)テーマ
+ Studio Theme スタジオテーマ
+ Studio Light Theme スタジオ(ライト)テーマ
+ Classic Theme クラシックテーマ
+ Next Theme 次のテーマ
+ Actions アクション
+ Brush Settings ブラシ設定
+ Brushes ブラシ
+ Channels チャンネル
+ Character 文字
+ Character Styles 文字スタイル
+ Clone Source コピーソース
+ Color カラー
+ Glyphs 字形
+ Gradients グラデーション
+ Histogram ヒストグラム
+ History ヒストリー
+ Info 情報
+ Measurement Log 測定ログ
+ Modifier Keys 修飾キー
+ Navigator ナビゲーター
+ Options オプション
+ Paragraph 段落
+ Paragraph Styles 段落スタイル
+ Paths パス
+ Patterns パターン
+ Properties プロパティ
+ Shapes シェイプ
+ Styles スタイル
+ Swatches スウォッチ
+ Timeline タイムライン
+ Tool Presets ツールプリセット
+ Tools ツール
+ About PhotoCraft PhotoCraft について
+ PhotoCraft Website PhotoCraft の Web サイト
+ PhotoCraft on GitHub GitHub 上の PhotoCraft
+ ArtCraft Website ArtCraft の Web サイト
+ Join the ArtCraft Discord… ArtCraft の Discord に参加…
+ Report an Issue… 問題を報告…
+ WIA Support… WIA サポート…
+ Apply 適用
+ HSB/HSL HSB/HSL
+ Invert… 反転…
+ Load Files into Stack… ファイルをスタックに読み込み…
+ Motion モーション
+ Notes… 注釈…
+ Other… その他…
+ Remove Warp Split ワープ分割を削除
+ Shape シェイプ
+ Split Warp Crosswise ワープを十字に分割
+ Split Warp Horizontally ワープを水平方向に分割
+ Split Warp Vertically ワープを垂直方向に分割
+ Statistics… 統計情報…
+@plural {n} item|{n} items {n} 件
+ Auto 自動
+
+# Dialogs and panels
+ (print to the printer) (プリンターへ出力)
+ + Add variable + 変数を追加
+ 30 frames @ 30 fps 30 フレーム @ 30 fps
+ 3D LUT File 3D LUT ファイル
+ Absolute 絶対
+ Absolute Colorimetric 絶対的な色域を維持
+ Action アクション
+ Adaptive アダプティブ
+ Adaptive Wide Angle isn't open 広角補正は開いていません
+ Add 追加
+ Add Layer Mask レイヤーマスクを追加
+ Add Stop 分岐点を追加
+ Add a layer style レイヤースタイルを追加
+ Add a mask (from the selection; {key} inverts) マスクを追加(選択範囲から。{key} で反転)
+ Add an adjustment 色調補正を追加
+ Add disk ディスクを追加
+ Add space after paragraph 段落の後ろにスペースを追加
+ Add space before paragraph 段落の前にスペースを追加
+ Add to Sample サンプルに追加
+ Add to selection ({key}) 選択範囲に追加({key})
+ Adjust for Zoom ズームに合わせて調整
+ Adjustment visible 色調補正を表示
+ Adobe RGB (1998) compatible Adobe RGB (1998) 互換
+ Align and Distribute 整列と分布
+ Align and distribute 整列と分布
+ Align horizontal centers 水平方向の中央で整列
+ Align left edges 左端で整列
+ Align right edges 右端で整列
+ Aligned 位置合わせあり
+ All Caps すべて大文字
+ All Slices すべてのスライス
+ All User Slices すべてのユーザースライス
+ All shortcuts reset to Photoshop defaults. すべてのショートカットを初期状態に戻しました。
+ Alt Alt
+ Always use pressure for opacity 常に筆圧を不透明度に使う
+ Always use pressure for size 常に筆圧をサイズに使う
+ Amount 量
+ Anchor: 基準位置:
+ Angle 角度
+ Angle Gradient 円錐形グラデーション
+ Angle Jitter 角度のジッター
+ Answer the unsaved-changes prompt first 先に未保存の変更の確認に答えてください
+ Anti-alias アンチエイリアス
+ Appearance 外観
+ Appearance (Layer Style) 外観(レイヤースタイル)
+ Apply Layer Mask レイヤーマスクを適用
+ Apply Per Tip 先端ごとに適用
+ Apply next selected layer comp 次のレイヤーカンプを適用
+ Apply previous selected layer comp 前のレイヤーカンプを適用
+ Artboard アートボード
+ Artboard Background Color アートボードの背景色
+ Assign working space 作業用スペースを割り当て
+ Author: 作成者:
+ Auto Hide 自動的に隠す
+ Auto-Select: 自動選択:
+ Automatically level near-horizontal line segments 水平に近い線分を自動で水平にする
+ Automatically straighten and level 自動で傾きと水平を補正
+ Automatically straighten near-vertical line segments 垂直に近い線分を自動で垂直にする
+ Background 背景
+ Background Color 背景色
+ Background Contents 背景の内容
+ Balance バランス
+ Baseline ベースライン
+ Baseline shift ベースラインシフト
+ Basic 基本
+ Before (Y) 補正前(Y)
+ Begin recording 記録を開始
+ Bend: 曲げ:
+ Bicubic バイキュービック
+ Bicubic (smooth gradients) バイキュービック(滑らかな階調)
+ Bilinear バイリニア
+ Black 黒
+ Black & White 白黒
+ Black Point Compensation 黒点補正
+ Black, White 黒、白
+ Blacks ブラック
+ Blending 合成
+ Blending Options 描画オプション
+ Blue 青
+ Blue, Red, Yellow 青、赤、黄
+ Both 両方
+ Both Axes 両方の軸
+ Bottom 下
+ Brightness 明るさ
+ Brightness Jitter 明るさのジッター
+ Brightness/Contrast 明るさ・コントラスト
+ Bring the selected pin forward 選択したピンを前面へ
+ Brush Preset picker ブラシプリセットの選択
+ Brush Reconstruct Options ブラシの復元オプション
+ Brush Tool Options ブラシツールのオプション
+ Cache Level: キャッシュレベル:
+ Camera Raw isn't open Camera Raw は開いていません
+ Cancel キャンセル
+ Cancel (Esc) キャンセル(Esc)
+ Cancel any current edits (Esc) 現在の編集をキャンセル(Esc)
+ Cancel current crop operation (Esc) 現在の切り抜きをキャンセル(Esc)
+ Cancel transform (Esc) 変形をキャンセル(Esc)
+ Cancel warp (Esc) ワープをキャンセル(Esc)
+ Canvas カンバス
+ Canvas extension color: カンバス拡張カラー:
+ Capture 取り込み
+ Capture the visibility, position and style of every layer with + below, then switch between versions. 下の + で、各レイヤーの表示状態・位置・スタイルを取り込み、バージョンを切り替えられます。
+ Catch-up on Stroke End ストローク終了時に追いつく
+ Center 中央
+ Center Crop Marks 中央のトンボ
+ Center text 中央揃え
+ Change 変更
+ Change All すべて変更
+ Change Screen Mode (F) スクリーンモードを変更(F)
+ Change To: 変更後:
+ Channel Mixer チャンネルミキサー
+ Channel: チャンネル:
+ Check All Layers すべてのレイヤーをチェック
+ Check Spelling スペルチェック
+ Clarity 明瞭度
+ Clear All すべて消去
+ Clear Override 上書きを解除
+ Clear Samples サンプルを消去
+ Click sets foreground · right-click sets background クリックで前景色、右クリックで背景色を設定
+ Click the first point or press {key} to close · Esc cancels 最初の点をクリックするか {key} で閉じる · Esc でキャンセル
+ Click to add a point · drag off or {key}-click or Delete to remove クリックで点を追加 · 外へドラッグ、{key}+クリック、Delete で削除
+ Click to apply, {key}-click to clear overrides, double-click for Style Options クリックで適用、{key}+クリックで上書き解除、ダブルクリックでスタイルオプション
+ Click to edit the gradient クリックしてグラデーションを編集
+ Click to restore the current colour クリックして現在の色に戻す
+ Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out クリックで拡大 · {key}+クリックで縮小 · 右/左にドラッグで拡大/縮小
+ Click with the Note tool to add a note. 注釈ツールでクリックすると注釈を追加できます。
+ Click: corner · Drag: smooth · Click first point: close · {key} finish · Esc cancel クリック: 角 · ドラッグ: 滑らか · 最初の点をクリック: 閉じる · {key} 完了 · Esc キャンセル
+ Clip to layer below 下のレイヤーでクリッピング
+ Clipped クリッピング済み
+ Close Style Options スタイルオプションを閉じる
+ Cmd Cmd
+ Coated CMYK コート紙 CMYK
+ Color & Swatches カラーとスウォッチ
+ Color Balance カラーバランス
+ Color Detail カラーの精細度
+ Color Grading カラーグレーディング
+ Color Lookup カラールックアップ
+ Color Management カラーマネジメント
+ Color Mixer カラーミキサー
+ Color Mode カラーモード
+ Color Priority カラー優先
+ Color Range preview 色域指定のプレビュー
+ Color: カラー:
+ Colorize 色彩の統一
+ Colors カラー
+ Commit Perspective Warp ({key}) 遠近法ワープを確定({key})
+ Commit Puppet Warp ({key}) パペットワープを確定({key})
+ Commit any current edits ({key}) 現在の編集を確定({key})
+ Commit current crop operation ({key}) 現在の切り抜きを確定({key})
+ Commit transform ({key}) 変形を確定({key})
+ Commit warp ({key}) ワープを確定({key})
+ Constant 一定
+ Constrain proportions 縦横比を固定
+ Contact Sheet II コンタクトシート II
+ Content-Aware コンテンツに応じる
+ Contiguous 隣接
+ Contrast コントラスト
+ Control: コントロール:
+ Convert document's colors to the working space ドキュメントの色を作業用スペースに変換
+ Convert to sRGB sRGB に変換
+ Copies 部数
+ Copper 銅
+ Copyright 著作権
+ Copyright and Contact Info 著作権と連絡先
+ Corner Crop Marks 角のトンボ
+ Corner radius 角の半径
+ Correction 補正
+ Count Jitter 数のジッター
+ Create 作成
+ Create Droplet ドロップレットを作成
+ Create Texture テクスチャを作成
+ Create Video Timeline ビデオタイムラインを作成
+ Create a new count group 新しいカウントグループを作成
+ Create a new document or open an existing file. 新規ドキュメントを作成するか、既存のファイルを開きます。
+ Create a new group 新しいグループを作成
+ Create a new layer 新規レイヤーを作成
+ Create new action 新規アクションを作成
+ Create new channel 新規チャンネルを作成
+ Create new document from current state 現在の状態から新規ドキュメントを作成
+ Create new fill or adjustment layer 新規塗りつぶし/色調補正レイヤーを作成
+ Create new gradient 新規グラデーションを作成
+ Create new group 新規グループを作成
+ Create new layer comp 新規レイヤーカンプを作成
+ Create new pattern from the selection 選択範囲から新規パターンを作成
+ Create new shape from the current path 現在のパスから新規シェイプを作成
+ Create new snapshot 新規スナップショットを作成
+ Create new style (from the selected type) 新規スタイルを作成(選択した文字から)
+ Create new style from the selected layer 選択したレイヤーから新規スタイルを作成
+ Create new tool preset 新規ツールプリセットを作成
+ Crop Factor 切り抜き係数
+ Ctrl Ctrl
+ Current & Below 現在のレイヤーとその下
+ Current Layer 現在のレイヤー
+ Current Size 現在のサイズ
+ Current Tool Only 現在のツールのみ
+ Curve カーブ
+ Curves トーンカーブ
+ Custom カスタム
+ Custom Shapes カスタムシェイプ
+ Cyan シアン
+ Cyan · Red シアン · 赤
+ Darken 比較(暗)
+ Darks 暗部
+ Data Sets データセット
+ Default 既定
+ Default colours (D) 初期カラーに戻す(D)
+ Default printer 既定のプリンター
+ Default restored. 既定に戻しました。
+ Define 定義
+ Define at least one variable first. 先に変数を 1 つ以上定義してください。
+ Dehaze かすみの除去
+ Delete Cropped Pixels 切り抜かれたピクセルを削除
+ Delete Group グループを削除
+ Delete Layer Mask レイヤーマスクを削除
+ Delete Layers レイヤーを削除
+ Delete Shortcut ショートカットを削除
+ Delete Timeline タイムラインを削除
+ Delete Tool Preset ツールプリセットを削除
+ Delete count group カウントグループを削除
+ Delete current channel 現在のチャンネルを削除
+ Delete current state 現在の状態を削除
+ Delete effect layer 効果レイヤーを削除
+ Delete layer レイヤーを削除
+ Delete layer comp レイヤーカンプを削除
+ Delete note 注釈を削除
+ Delete selected measurements 選択した測定値を削除
+ Delete style スタイルを削除
+ Delete tool preset ツールプリセットを削除
+ Density 密度
+ Density: 密度:
+ Depth 深さ
+ Depth Jitter 深さのジッター
+ Description 説明
+ Deselect All すべての選択を解除
+ Detail ディテール
+ Diamond Gradient ダイヤモンド形グラデーション
+ Difference 差の絶対値
+ Diffusion 拡散
+ Discard the embedded profile (don't color manage) 埋め込みプロファイルを破棄(カラーマネジメントしない)
+ Discontiguous 不連続
+ Discord Discord
+ Dismiss 閉じる
+ Display P3 Display P3
+ Display Text 表示テキスト
+ Dither ディザ
+ Divide… 分割…
+ Document ドキュメント
+ Don't Save 保存しない
+ Done 完了
+ Dots ドット
+ Drag a rectangle around the object オブジェクトを囲む矩形をドラッグ
+ Drag on the image to add a constraint; Shift for horizontal/vertical; right-click to delete. 画像上をドラッグして制約を追加。Shift で水平/垂直、右クリックで削除。
+ Drag to move the active shape's path or the Work Path ドラッグして、アクティブなシェイプのパスまたは作業用パスを移動
+ Draw with the Pen tool (P) or make a work path from a selection. ペンツール(P)で描くか、選択範囲から作業用パスを作成します。
+ Drop an image or PSD anywhere to open it. 画像や PSD をここにドロップすると開きます。
+ Duplicate Layers… レイヤーを複製…
+ Duplicate style スタイルを複製
+ Edit Toolbar… ツールバーを編集…
+ Edit in Quick Mask Mode (Q) クイックマスクモードで編集(Q)
+ Edit in Standard Mode (Q) 標準モードで編集(Q)
+ Effects 効果
+ Embed Color Profile カラープロファイルを埋め込む
+ Embedded Profile Mismatch 埋め込みプロファイルの不一致
+ Enable airbrush-style build-up effects エアブラシ風の重ね塗り効果を有効にする
+ Enhance Edge エッジを強調
+ Entire Font フォント全体
+ Exact 正確
+ Expansion: 拡張:
+ Export Presets プリセットを書き出し
+ Export selected measurements (CSV) 選択した測定値を書き出し(CSV)
+ Exposure 露光量
+ Exposure and Gamma 露光量とガンマ
+ Exposure: 露光量:
+ Eyedropper スポイト
+ Factor: 係数:
+ Faux Bold 疑似ボールド
+ Faux Italic 疑似イタリック
+ Feather ぼかし
+ Fewer Points ポイントを減らす
+ File Settings ファイル設定
+ Fill 塗り
+ Fill: 塗り:
+ Filter for adjustment layers 色調補正レイヤーで絞り込み
+ Filter for pixel layers ピクセルレイヤーで絞り込み
+ Filter for shape layers シェイプレイヤーで絞り込み
+ Filter for smart objects スマートオブジェクトで絞り込み
+ Filter for type layers 文字レイヤーで絞り込み
+ Filter: フィルター:
+ Finger Painting 指先で描画
+ Fisheye 魚眼
+ Fit 合わせる
+ Fit Screen 画面に合わせる
+ Fit in View 表示に合わせる
+ Fixed 固定
+ Fixed Ratio 縦横比を固定
+ Fixed Size サイズを固定
+ Flip 反転
+ Flip X X 反転
+ Flip X Jitter X 反転のジッター
+ Flip Y Y 反転
+ Flip Y Jitter Y 反転のジッター
+ Flow 流量
+ Flow Jitter 流量のジッター
+ Focal Length 焦点距離
+ Font フォント
+ Font Size: フォントサイズ:
+ Font size フォントサイズ
+ Foreground 前景
+ Foreground to Background 描画色から背景色へ
+ Foreground/Background Jitter 描画色/背景色のジッター
+ Format 形式
+ Frame from Layers… レイヤーからフレーム…
+ Free 自由
+ Full Spherical 全球
+ Fuzziness: 許容量:
+ GPU GPU
+ Gamma Correction ガンマ補正
+ Gamma: ガンマ:
+ Global 全体
+ Glow Color 光彩のカラー
+ Gradient Map グラデーションマップ
+ Grain 粒子
+ Gray グレー
+ Gray Gamma 2.2 グレー ガンマ 2.2
+ Green 緑
+ Group グループ
+ Hardness 硬さ
+ Heart ハート
+ Height 高さ
+ Height: 高さ:
+ Hide Auto Slices 自動スライスを非表示
+ Hide Properties プロパティを隠す
+ Highlight Compression ハイライトの圧縮
+ Highlight Priority ハイライト優先
+ Highlights ハイライト
+ Home ホーム
+ Horizontal scale 水平比率
+ Hue 色相
+ Hue Jitter 色相のジッター
+ Hue/Saturation 色相・彩度
+ Hyphenate ハイフネーション
+ Ignore 無視
+ Ignore All すべて無視
+ Image Size 画像サイズ
+ Import Brushes… ブラシを読み込み…
+ Import Photoshop brushes (.abr) Photoshop ブラシ(.abr)を読み込み
+ Import Presets プリセットを読み込み
+ Imported 読み込み済み
+ Indent First 先頭行の字下げ
+ Indent Left 左の字下げ
+ Indent Right 右の字下げ
+ Indent first line 先頭行を字下げ
+ Indent left margin 左マージンを字下げ
+ Indent right margin 右マージンを字下げ
+ Input: 入力:
+ Inside 内側
+ Interlaced インターレース
+ Interpolation: 補間方法:
+ Intersect with selection ({key}) 選択範囲との共通部分({key})
+ Invert All すべて反転
+ Invert has no settings. 階調の反転には設定がありません。
+ Italic イタリック
+ Join us on Discord Discord に参加
+ Justify all 均等配置(最終行も)
+ Justify last centered 最終行中央揃えの両端揃え
+ Justify last left 最終行左揃えの両端揃え
+ Justify last right 最終行右揃えの両端揃え
+ Kerning カーニング
+ Keyboard Shortcuts キーボードショートカット
+ Keyboard Shortcuts and Menus キーボードショートカットとメニュー
+ Kind 種類
+ Label Size ラベルのサイズ
+ Labels ラベル
+ Lanczos (sharp) ランチョス(シャープ)
+ Landscape 横向き
+ Last Document State ドキュメントの最後の状態
+ Layout レイアウト
+ Leading 行送り
+ Leading (set to the font size × auto-leading when Auto) 行送り(自動のときはフォントサイズ × 自動行送り)
+ Leave as is (don't color manage) そのまま(カラーマネジメントしない)
+ Left 左
+ Left align text 左揃え
+ Length: 長さ:
+ Level レベル
+ Levels レベル補正
+ Lighten 比較(明)
+ Lightness 明度
+ Lights ライト
+ Limits: 制限:
+ Linear Gradient 線形グラデーション
+ Link layers レイヤーをリンク
+ Link width and height 幅と高さをリンク
+ Liquify is not open ゆがみは開いていません
+ Load 読み込み
+ Load 3D LUT… 3D LUT を読み込み…
+ Load Photoshop brushes (.abr) Photoshop ブラシ(.abr)を読み込み
+ Load channel as selection チャンネルを選択範囲として読み込み
+ Load… 読み込み…
+ Localized Color Clusters 近似色のクラスター化
+ Lock ロック
+ Lock all すべてをロック
+ Lock image pixels 画像ピクセルをロック
+ Lock layer レイヤーをロック
+ Lock position 位置をロック
+ Lock transparent pixels 透明ピクセルをロック
+ Lock: ロック:
+ Logical Length: 論理的な長さ:
+ Logical Units: 論理単位:
+ Luminance 輝度
+ Luminance Detail 輝度のディテール
+ Magenta マゼンタ
+ Magenta · Green マゼンタ · 緑
+ Maintain aspect ratio 縦横比を維持
+ Marker Size マーカーのサイズ
+ Mask All すべてマスク
+ Mask Options マスクオプション
+ Masking マスク処理
+ Master マスター
+ Matte マット
+ Median: 中央値:
+ Menus メニュー
+ Mesh Size メッシュのサイズ
+ Metadata メタデータ
+ Metrics メトリクス
+ Midpoint 中間点
+ Midtones 中間調
+ Midtones from: 中間調の開始:
+ Midtones to: 中間調の終了:
+ Minimum Depth 最小の深さ
+ Minimum Diameter 最小の直径
+ Minimum Roundness 最小の真円率
+ Mode: モード:
+ Monochrome モノクロ
+ More Points ポイントを増やす
+ Move effect layer down 効果レイヤーを下へ移動
+ Move effect layer up 効果レイヤーを上へ移動
+ Move to 移動先
+ Name 名前
+ Name: 名前:
+ Nearest Neighbor ニアレストネイバー
+ Nearest Neighbor (hard edges) ニアレストネイバー(ハードエッジ)
+ New Size 新しいサイズ
+ New document… 新規ドキュメント…
+ New effect layer 新規効果レイヤー
+ New selection 新規選択
+ Next frame 次のフレーム
+ Next note 次の注釈
+ No Color カラーなし
+ No Color Management カラーマネジメントなし
+ No Dither ディザなし
+ No author 作成者なし
+ No character style 文字スタイルなし
+ No document ドキュメントなし
+ No matching commands 一致するコマンドがありません
+ No presets for the current tool. 現在のツールのプリセットはありません。
+ No presets of this type. この種類のプリセットはありません。
+ No properties プロパティなし
+ No tool presets. ツールプリセットはありません。
+ Noise Reduction ノイズ軽減
+ Normal 通常
+ Not in Dictionary: 辞書にない語:
+ OK OK
+ Offset オフセット
+ Only Web Colors Web セーフカラーのみ
+ Opacity 不透明度
+ Opacity Jitter 不透明度のジッター
+ Opacity: 不透明度:
+ Open a document to define variables. 変数を定義するには、ドキュメントを開いてください。
+ Open a document to select a colour range. 色域を指定するには、ドキュメントを開いてください。
+ Open a document to use the timeline. タイムラインを使うには、ドキュメントを開いてください。
+ Optical オプティカル
+ Optimized 最適化
+ Option-click to define a source point to clone from Option+クリックでコピー元を指定
+ Original オリジナル
+ Output Channel: 出力チャンネル:
+ Output Levels: 出力レベル:
+ Output: 出力:
+ Outside 外側
+ Overlay Color オーバーレイカラー
+ Overlay Opacity オーバーレイの不透明度
+ Overlay: Rule of Thirds オーバーレイ: 三分割法
+ Override Pressure 筆圧を上書き
+ Override Rotation 回転を上書き
+ Override Tilt 傾きを上書き
+ PRESET DETAILS プリセットの詳細
+ PSD PSD
+ Paint Overlay ペイントオーバーレイ
+ Panel locations are saved in the workspace. Keyboard shortcuts, menus and toolbar are optional. パネルの位置はワークスペースに保存されます。キーボードショートカット、メニュー、ツールバーは任意です。
+ Paper 用紙
+ Path パス
+ Pattern パターン
+ Pattern Size パターンのサイズ
+ Pause 一時停止
+ Percent パーセント
+ Perceptual 知覚的
+ Perspective Warp is not active 遠近法ワープは有効ではありません
+ Perspective Warp: draw planes along the image's perspective, then switch to Warp 遠近法ワープ: 画像の遠近に沿って面を描き、ワープに切り替えます
+ Photo Filter 写真フィルター
+ PhotoCraft PhotoCraft
+ PhotoCraft Manages Colors PhotoCraft でカラーを管理
+ PhotoCraft — an open-source, native image editor written in Rust. PhotoCraft — Rust で書かれた、オープンソースのネイティブ画像エディター。
+ Pin Depth: ピンの深さ:
+ Pixel Length: ピクセル長:
+ Pixels/Centimeter ピクセル/センチメートル
+ Pixels/Inch ピクセル/インチ
+ Pixels: ピクセル:
+ Play 再生
+ Play selection 選択範囲を再生
+ Portrait 縦向き
+ Position 位置
+ Position and Size 位置とサイズ
+ Posterize ポスタリゼーション
+ Preserve Details ディテールを保持
+ Preserve Luminosity 輝度を保持
+ Preset プリセット
+ Preset Type プリセットの種類
+ Preset: プリセット:
+ Presets: プリセット:
+ Press keys… キーを押してください…
+ Pressure 筆圧
+ Pressure for Opacity 不透明度に筆圧を使用
+ Pressure for Size サイズに筆圧を使用
+ Prevent auto-nesting in and out of Artboards and Frames アートボードやフレームへの自動入れ子を防ぐ
+ Preview プレビュー
+ Previous frame 前のフレーム
+ Previous note 前の注釈
+ Print プリント
+ Printer プリンター
+ Printer Manages Colors プリンターでカラーを管理
+ Printer Setup プリンター設定
+ Printing Marks 印刷用マーク
+ Progressive プログレッシブ
+ Promote 昇格
+ Protect Detail ディテールを保護
+ Protect Foreground Color 描画色を保護
+ Protect Tones 階調を保護
+ Proximity Match 近接一致
+ Pulled String Mode 引き紐モード
+ Puppet Warp is not active パペットワープは有効ではありません
+ Purity 純度
+ Quality 画質
+ Quick Actions クイックアクション
+ Quick Export As PNG PNG としてクイック書き出し
+ Radial Gradient 円形グラデーション
+ Radius 半径
+ Radius: 半径:
+ Range: 範囲:
+ Rate 速度
+ Recently Used 最近使用したもの
+ Reconstruct 再構築
+ Record ● a sequence of edits, then play ▶ it on any document. 一連の編集を記録 ● し、任意のドキュメントで再生 ▶ できます。
+ Red 赤
+ Redefine style by current selection 現在の選択でスタイルを再定義
+ Reflected Gradient 反射形グラデーション
+ Registration Marks 見当合わせマーク
+ Regular レギュラー
+ Relative 相対
+ Relative Colorimetric 相対的な色域を維持
+ Remove 削除
+ Remove All Pins すべてのピンを削除
+ Remove Background 背景を削除
+ Remove Planes 面を削除
+ Remove stop 分岐点を削除
+ Remove variable 変数を削除
+ Rename 名前を変更
+ Rename Group… グループ名を変更…
+ Rename Layer… レイヤー名を変更…
+ Rename Tool Preset… ツールプリセット名を変更…
+ Rename… 名前を変更…
+ Resample 再サンプル
+ Reset All to Defaults すべて既定に戻す
+ Reset Section セクションをリセット
+ Reset Transform 変形をリセット
+ Reset to defaults 既定に戻す
+ Resolution 解像度
+ Resolution: 解像度:
+ Restore All すべて復元
+ Restore Defaults 既定に戻す
+ Restrictive (Web) 制限(Web)
+ Right 右
+ Right align text 右揃え
+ Rigid 剛体
+ Rotate: 回転:
+ Rotation 回転
+ Roughness 粗さ
+ Roundness 真円率
+ Roundness Jitter 真円率のジッター
+ Rulers & Grids 定規とグリッド
+ Sample All Layers すべてのレイヤーをサンプル
+ Sample: サンプル:
+ Sampling: Background Swatch サンプリング: 背景スウォッチ
+ Sampling: Continuous サンプリング: 連続
+ Sampling: Once サンプリング: 1 回
+ Saturate 彩度を上げる
+ Saturation 彩度
+ Saturation Jitter 彩度のジッター
+ Save HTML and Images HTML と画像を保存
+ Save as PDF PDF として保存
+ Save selection as channel 選択範囲をチャンネルとして保存
+ Save… 保存…
+ Scale to Fit Media メディアに合わせて拡大・縮小
+ Scatter 散布
+ Scratch disks スクラッチディスク
+ Search 検索
+ Search commands コマンドを検索
+ Search commands, tools and panels… コマンド、ツール、パネルを検索…
+ Search fonts フォントを検索
+ Select All すべてを選択
+ Select Subject 被写体を選択
+ Select a type layer or click into text to insert glyphs 文字レイヤーを選択するか、テキスト内をクリックして字形を挿入します
+ Select text to apply a character style 文字スタイルを適用するテキストを選択してください
+ Select: 選択:
+ Selections 選択範囲
+ Selective 特定色
+ Selective Color 特定色域の選択
+ Send the selected pin backward 選択したピンを背面へ
+ Set additional smoothing options 滑らかさの追加オプションを設定
+ Set background color 背景色を設定
+ Set foreground color 描画色を設定
+ Set painting symmetry options 対称描画のオプションを設定
+ Set shape fill type シェイプの塗りの種類を設定
+ Set shape stroke type シェイプの線の種類を設定
+ Set the text color 文字色を設定
+ Shadows シャドウ
+ Shape: シェイプ:
+ Sharpening シャープ
+ Shift Shift
+ Shortcut removed. ショートカットを削除しました。
+ Show All Menu Items すべてのメニュー項目を表示
+ Show Backdrop 背景を表示
+ Show Guides ガイドを表示
+ Show Mask マスクを表示
+ Show Mesh メッシュを表示
+ Show Overlay オーバーレイを表示
+ Show Transform Controls バウンディングボックスを表示
+ Show or hide the Notes panel 注釈パネルを表示/非表示
+ Show: 表示:
+ Sides 辺の数
+ Sides: 辺の数:
+ Size サイズ
+ Size Jitter サイズのジッター
+ Size: サイズ:
+ Slice Options… スライスオプション…
+ Slices From Guides ガイドからスライス
+ Slices are locked (View › Lock Slices) スライスはロックされています(表示 › スライスをロック)
+ Small Caps スモールキャップ
+ Smoothing スムージング
+ Space After 後ろのスペース
+ Space Before 前のスペース
+ Spacing 間隔
+ Spell check complete. スペルチェックが完了しました。
+ Split: 分割:
+ Star ratio 星の比率
+ Stop playing/recording 再生/記録を停止
+ Straighten 角度補正
+ Straighten Layer レイヤーの角度補正
+ Strength: 強さ:
+ Strikethrough 取り消し線
+ Stroke 線
+ Stroke Catch-up ストロークの追従
+ Stroke: 線:
+ Style スタイル
+ Style Options スタイルオプション
+ Style Options… スタイルオプション…
+ Style: Normal スタイル: 通常
+ Subtract from Sample サンプルから削除
+ Subtract from selection ({key}) 選択範囲から削除({key})
+ Suggestions: 候補:
+ Swap colours (X) 描画色と背景色を入れ替え(X)
+ Swaps height and width 高さと幅を入れ替えます
+ Switch between free transform and warp modes 自由変形とワープのモードを切り替え
+ Switch theme テーマを切り替え
+ Temperature 色温度
+ Tetrahedral 四面体
+ Text Position: テキストの位置:
+ Texture テクスチャ
+ Texture Each Tip 先端ごとにテクスチャ
+ Threshold しきい値
+ Threshold Level しきい値レベル
+ Thumbnail size (smallest: list) サムネールのサイズ(最小: リスト)
+ Tilt X 傾き X
+ Tilt Y 傾き Y
+ Tint 色かぶり補正
+ Toggle count group visibility カウントグループの表示を切り替え
+ Toggle text orientation 文字の方向を切り替え
+ Tolerance 許容値
+ Tolerance: 許容値:
+ Tone: トーン:
+ Toolbar ツールバー
+ Top 上
+ Total: 合計:
+ Tracking トラッキング
+ Tracking (1/1000 em) トラッキング(1/1000 em)
+ Transparency 透明
+ Transparent 透明
+ Trilinear トライリニア
+ Type Styles 文字スタイル
+ Type: 種類:
+ Underline 下線
+ Untitled 名称未設定
+ Untitled-1 名称未設定-1
+ Update layer comp (visibility, position and appearance) レイヤーカンプを更新(表示状態・位置・外観)
+ Use Default 既定を使用
+ Use Legacy 従来方式を使用
+ Use Measurement Scale 測定スケールを使用
+ Use the embedded profile (instead of the working space) 埋め込みプロファイルを使用(作業用スペースの代わり)
+ Variables bind a layer's visibility, text or pixels to a named data slot. 変数は、レイヤーの表示状態・テキスト・ピクセルを、名前付きのデータ枠に結び付けます。
+ Vertical scale 垂直比率
+ Vibrance 自然な彩度
+ View Options 表示オプション
+ Vignetting 周辺光量
+ Violet, Orange 紫、オレンジ
+ Visibility 表示状態
+ Visible 表示
+ Warp: ワープ:
+ Web Snap Web スナップ
+ Weight ウェイト
+ Weight: ウェイト:
+ White 白
+ White Balance: As Shot ホワイトバランス: 撮影時の設定
+ Whites 白レベル
+ Width 幅
+ Width: 幅:
+ Work Path 作業用パス
+ Yellow イエロー
+ Yellow · Blue 黄 · 青
+ Zoom ズーム
+ Zoom in 拡大
+ Zoom out 縮小
+ command or shortcut コマンドまたはショートカット
+ current 現在
+ image file path 画像ファイルのパス
+ modified 変更あり
+ name 名前
+ new 新規
+ {name} options {name} のオプション
+ ↑↓ navigate {key} run esc close ↑↓ 移動 {key} 実行 esc 閉じる
+ Version {version} バージョン {version}
+ New Document 新規ドキュメント
+ Error エラー
+ Command コマンド
+
+# Tool names, brush and style option tables
+ Adjustment layers have nothing to transform 色調補正レイヤーには変形するものがありません
+ Altitude 高度
+ Android 1080p Android 1080p
+ Apple Watch 45mm Apple Watch 45mm
+ Aqua アクア
+ Art & Illustration アート・イラスト
+ ArtCraft ArtCraft
+ Background Eraser Tool 背景消しゴムツール
+ Bevel & Emboss ベベルとエンボス
+ Blend Mode 描画モード
+ Blues ブルー系
+ Blur Tool ぼかしツール
+ Bold ボールド
+ Brush ブラシ
+ Brush Pose ブラシの姿勢
+ Brush Tip Shape ブラシ先端のシェイプ
+ Brush Tool ブラシツール
+ Build-up 重ね塗り
+ Burn Tool 焼き込みツール
+ Centimeters センチメートル
+ Choke 境界のぼかし幅
+ Classic クラシック
+ Click to add text クリックしてテキストを追加
+ Click to fill similar colours クリックして近い色を塗りつぶし
+ Clone Stamp Tool コピースタンプツール
+ Color Burn 焼き込みカラー
+ Color Dodge 覆い焼きカラー
+ Color Dynamics カラーの変化
+ Color Overlay カラーオーバーレイ
+ Comic Book コミック
+ Conform 適合
+ Content-Aware Fill needs a selection on a pixel layer コンテンツに応じた塗りつぶしには、ピクセルレイヤー上の選択範囲が必要です
+ Could not transform: the layer is empty 変形できません: レイヤーが空です
+ Could not use Perspective Warp: the layer is empty 遠近法ワープを使えません: レイヤーが空です
+ Could not use Puppet Warp: no opaque pixels パペットワープを使えません: 不透明なピクセルがありません
+ Could not use Puppet Warp: the layer is empty パペットワープを使えません: レイヤーが空です
+ Crop Tool 切り抜きツール
+ Crosswise 十字
+ Current Tool 現在のツール
+ Custom Shape Tool カスタムシェイプツール
+ Cyans シアン系
+ Default Photoshop Size 既定サイズ
+ Delete Workspace ワークスペースを削除
+ Diamond ダイヤモンド形
+ Dimensions: 寸法:
+ Direction 方向
+ Distance 距離
+ Document Dimensions ドキュメントの寸法
+ Document Profile ドキュメントのプロファイル
+ Document Sizes ドキュメントのサイズ
+ Dodge Tool 覆い焼きツール
+ Down 下
+ Drag to draw a gradient ドラッグしてグラデーションを描画
+ Drag to move the active layer ドラッグしてアクティブなレイヤーを移動
+ Drag to pan · hold Space with any tool ドラッグでパン · どのツールでも Space を押しながら
+ Drop Shadow ドロップシャドウ
+ Dual Brush デュアルブラシ
+ Edge エッジ
+ Efficiency 効率
+ Efficiency: 100% 効率: 100%
+ Ellipse Tool 楕円形ツール
+ Elliptical Marquee Tool 楕円形選択ツール
+ Emboss エンボス
+ Eraser 消しゴム
+ Eraser Tool 消しゴムツール
+ ExtraBold エクストラボールド
+ ExtraLight エクストラライト
+ Eyedropper Tool スポイトツール
+ Fade フェード
+ Fill Opacity 塗りの不透明度
+ Film & Video フィルム・ビデオ
+ From 開始
+ General 一般
+ GitHub GitHub
+ Gradient Overlay グラデーションオーバーレイ
+ Gradient Tool グラデーションツール
+ Greens グリーン系
+ Hand Tool 手のひらツール
+ Hard ハード
+ Hard Mix ハードミックス
+ Healing Brush Tool 修復ブラシツール
+ Highlights from: ハイライトの開始:
+ History Brush Tool ヒストリーブラシツール
+ Horizontal Type Tool 横書き文字ツール
+ Image Size: 画像サイズ:
+ Inches インチ
+ Indexed インデックス
+ Initial Direction 初期の方向
+ Inner Bevel 内側ベベル
+ Inner Glow 光彩(内側)
+ Inner Shadow シャドウ(内側)
+ Lab Lab
+ Landscape, 10 x 8 横向き、10 x 8
+ Landscape, 6 x 4 横向き、6 x 4
+ Landscape, 7 x 5 横向き、7 x 5
+ Lasso 投げ縄
+ Lasso Tool 投げ縄ツール
+ Layer Count レイヤー数
+ Layer Knocks Out Drop Shadow レイヤーでドロップシャドウを抜く
+ Legal リーガル
+ Letter レター
+ Light ライト
+ Line Tool 直線ツール
+ Linear 線形
+ Linear Burn 焼き込み(リニア)
+ Linear Height 線形の高さ
+ Link with Layer レイヤーとリンク
+ Lorem Ipsum ダミーテキスト
+ Magentas マゼンタ系
+ Magic Eraser Tool 背景消しゴム(自動)ツール
+ Magic Wand Tool 自動選択ツール
+ Marquee 選択
+ Mean: 平均:
+ Measurement Scale 測定スケール
+ Measurement Scale Marker 測定スケールマーカー
+ Millimeters ミリメートル
+ Mobile モバイル
+ Move Tool 移動ツール
+ Multiply 乗算
+ My Brushes マイブラシ
+ Neutrals 中間色系
+ New Workspace 新規ワークスペース
+ Note Tool 注釈ツール
+ Object Selection Tool オブジェクト選択ツール
+ Off オフ
+ Open 開く
+ Orange オレンジ
+ Original Ratio 元の縦横比
+ Out Of Gamut 色域外
+ Outer Bevel 外側ベベル
+ Outer Glow 光彩(外側)
+ Overlay オーバーレイ
+ Paint Bucket Tool 塗りつぶしツール
+ Paints from the document's opening state ドキュメントを開いた時点の状態から描画します
+ Path Selection Tool パスコンポーネント選択ツール
+ Pattern Overlay パターンオーバーレイ
+ Pen Pressure ペンの筆圧
+ Pen Tilt ペンの傾き
+ Pen Tool ペンツール
+ Photo 写真
+ PhotoCraft website PhotoCraft の Web サイト
+ Picas パイカ
+ Pillow Emboss ピローエンボス
+ Pixel Replacement ピクセルの置き換え
+ Pixels ピクセル
+ Points ポイント
+ Polygon Tool 多角形ツール
+ Polygonal Lasso Tool 多角形選択ツール
+ Portrait, 4 x 6 縦向き、4 x 6
+ Portrait, 5 x 7 縦向き、5 x 7
+ PostScript (72 points/inch) PostScript (72 ポイント/インチ)
+ Postcard はがき
+ Poster ポスター
+ Pro (Dark) プロ(ダーク)
+ Pro (Medium Gray) プロ(中間グレー)
+ Protect Texture テクスチャを保護
+ Purple 紫
+ Quick Mask クイックマスク
+ Quick Selection Tool クイック選択ツール
+ Radial 円形
+ Rasterize Layer レイヤーをラスタライズ
+ Ratio 縦横比
+ Recent 最近
+ Rectangle Tool 長方形ツール
+ Rectangular Marquee Tool 長方形選択ツール
+ Reds レッド系
+ Reflected 反射形
+ Sample: foreground colour サンプル: 描画色
+ Sampled Colors サンプルしたカラー
+ Satin サテン
+ Save Pixel Aspect Ratio ピクセル縦横比を保存
+ Scattering 散布
+ Scratch Sizes スクラッチサイズ
+ Select Data Points データポイントを選択
+ Selection 選択範囲
+ SemiBold セミボールド
+ Shadows up to: シャドウの終了:
+ Shape Dynamics シェイプの変化
+ Sharpen Tool シャープツール
+ Show Extras Options エクストラの表示オプション
+ Slice Select Tool スライス選択ツール
+ Slice Tool スライスツール
+ Smart Filters スマートフィルター
+ Smudge Tool 指先ツール
+ Soft ソフト
+ Soften ぼかし
+ Source ソース
+ Source: set ソース: 設定済み
+ Sponge Tool スポンジツール
+ Spot Healing Brush Tool スポット修復ブラシツール
+ Spread スプレッド
+ Square, 12 x 12 正方形、12 x 12
+ Square, 5 x 5 正方形、5 x 5
+ Std Dev: 標準偏差:
+ Studio (Dark) スタジオ(ダーク)
+ Studio (Light) スタジオ(ライト)
+ Stylus Wheel スタイラスホイール
+ Subtract 減算
+ Tabloid タブロイド
+ Text Replacement テキストの置き換え
+ Thin シン
+ Traditional (72.27 points/inch) 従来方式 (72.27 ポイント/インチ)
+ Transfer 伝達
+ Triangle Tool 三角形ツール
+ Unsaved changes 未保存の変更
+ Uses the foreground and background colours. 描画色と背景色を使用します。
+ Web Web
+ Web Large Web (大)
+ Web Minimum Web (最小)
+ Web Most Common Web (標準)
+ WebP (lossless) WebP (可逆)
+ Wet Edges ウェットエッジ
+ Yellows イエロー系
+ Zoom Tool ズームツール
+ {name} Properties {name} のプロパティ
+
+# Templates with placeholders
+ Revert “{name}” to the last saved version? Your changes will be lost. 「{name}」を最後に保存した状態に戻しますか? 変更は失われます。
+ Do you want to save the changes you made to “{name}” before quitting? 終了する前に、「{name}」への変更を保存しますか?
+ Do you want to save the changes you made to “{name}” before closing? 閉じる前に、「{name}」への変更を保存しますか?
+ Doc: {flat}/{layered} ドキュメント: {flat}/{layered}
+ Scratch: {size} スクラッチ: {size}
+ Untagged {mode} タグなし {mode}
+ {w} px x {h} px ({ppi} ppi) {w} px × {h} px ({ppi} ppi)
+ Resolution: {dpi} pixels/inch 解像度: {dpi} ピクセル/インチ
+ Doc: {w} × {h} px ドキュメント: {w} × {h} px
+ Frame {current} / {total} フレーム {current} / {total}
+ Count: {n} カウント: {n}
+ BLANK DOCUMENT PRESETS ({n}) 空白ドキュメントのプリセット ({n})
+ Constraints ({n}) 制約 ({n})
+ Align {what} {what}で整列
+@plural {n} Layer|{n} Layers {n} レイヤー
+@plural Group · {n} layer|Group · {n} layers グループ · {n} レイヤー
+
+# Preferences (labels are generated from the setting names)
+ Additional plugins folder 追加のプラグインフォルダー
+ Adobe Adobe
+ Adobe rgb Adobe RGB
+ Allow agent control エージェントによる操作を許可
+ Allow scripts to connect スクリプトからの接続を許可
+ Always 常に
+ Always create smart objects when placing 配置時に常にスマートオブジェクトを作成
+ Animated zoom アニメーションズーム
+ Apply auto tone 自動トーン補正を適用
+ Ask 確認する
+ Ask before saving layered tiff レイヤー付き TIFF の保存前に確認
+ Auto collapse icon panels アイコンパネルを自動で折りたたむ
+ Auto show hidden panels 隠れたパネルを自動で表示
+ Auto show home screen ホーム画面を自動で表示
+ Autosave 自動保存
+ Autosave minutes 自動保存の間隔(分)
+ Beep when done 完了時にビープ音を鳴らす
+ Bicubic automatic バイキュービック(自動)
+ Bicubic sharper バイキュービック(シャープ)
+ Bicubic smoother バイキュービック(滑らか)
+ Bit depth ビット深度
+ Brush preview color ブラシプレビューの色
+ Cache levels キャッシュレベル
+ Cache tile size キャッシュタイルのサイズ
+ Camera Raw Defaults Camera Raw の既定値
+ Canvas border カンバスの境界
+ Canvas color カンバスの色
+ Canvas custom color カンバスのカスタム色
+ Color picker カラーピッカー
+ Color space カラースペース
+ Column width 列の幅
+ Concise 簡潔
+ Control port 制御ポート
+ Convert to srgb sRGB に変換
+ Cursors カーソル
+ Custom dark カスタム(ダーク)
+ Custom light カスタム(ライト)
+ Dark ダーク
+ Dark gray ダークグレー
+ Dashed lines 破線
+ Destination 保存先
+ Detailed 詳細
+ Disks ディスク
+ Display p3 Display P3
+ Double click layer mask launches select and mask レイヤーマスクのダブルクリックで「選択とマスク」を起動
+ Drop shadow ドロップシャドウ
+ Dynamic color sliders カラースライダーを動的に変化
+ East asian 東アジア
+ Effect cache mb 効果キャッシュ (MB)
+ Enable flick panning フリックによるパンを有効にする
+ Enable floating document window docking 浮動ドキュメントウィンドウのドッキングを有効にする
+ Enable narrow options bar 幅の狭いオプションバーを有効にする
+ Enabled 有効
+ Enhanced Controls 拡張コントロール
+ Export clipboard クリップボードを書き出す
+ Extra large 特大
+ File Handling ファイル管理
+ File path ファイルのパス
+ Fill new type layers with placeholder 新規文字レイヤーにプレースホルダーを入れる
+ Font preview フォントのプレビュー
+ Full size tip 実寸の先端
+ Gamut warning color 色域外警告の色
+ Gamut warning opacity 色域外警告の不透明度
+ Generator enabled 自動生成を有効にする
+ Gif GIF
+ Glossy 光沢
+ Grid color グリッドの色
+ Grid colors グリッドの色
+ Grid size グリッドのサイズ
+ Grid style グリッドのスタイル
+ Grid unit グリッドの単位
+ Gridline every グリッド線の間隔
+ Guide color ガイドの色
+ Guide style ガイドのスタイル
+ Guides, Grid & Slices ガイド・グリッド・スライス
+ Gutter 余白
+ History Log ヒストリーログ
+ History states ヒストリーの数
+ Ignore exif profile tag EXIF のプロファイルタグを無視
+ Image interpolation 画像の補間方法
+ Image previews 画像のプレビュー
+ Integrations 連携
+ Interface インターフェイス
+ Jpeg quality JPEG 品質
+ Jpg JPG
+ Language 言語
+ Large tabs 大きなタブ
+ Legacy compositing 従来の合成方式
+ Light gray ライトグレー
+ Line 線
+ Lines 線
+ Lowercase extension 拡張子を小文字にする
+ Maximize psd compatibility PSD の互換性を最大にする
+ Medium gray 中間グレー
+ Memory usage mb メモリ使用量 (MB)
+ Missing glyph protection 字形欠落の保護
+ Modern モダン
+ Nearest neighbor ニアレストネイバー
+ Never しない
+ Normal tip 通常の先端
+ Open as smart object スマートオブジェクトとして開く
+ Open documents as tabs ドキュメントをタブで開く
+ Overscroll オーバースクロール
+ Performance パフォーマンス
+ Png PNG
+ Point size ポイントサイズ
+ Precise 精密
+ Preserve details ディテールを保持
+ Print resolution 印刷解像度
+ Pro プロ
+ Pro medium プロ(中間)
+ Pro photo ProPhoto
+ Quick export format クイック書き出しの形式
+ Quick export location クイック書き出しの保存先
+ Recent file count 最近使ったファイルの数
+ Recent files 最近使ったファイル
+ Recent fonts 最近使ったフォント
+ Recover on launch 起動時に復元
+ Remember workspace changes ワークスペースの変更を記憶
+ Resize image during place 配置時に画像をリサイズ
+ Rotate view with trackpad トラックパッドでビューを回転
+ Same folder 同じフォルダー
+ Save in background バックグラウンドで保存
+ Scratch Disks スクラッチディスク
+ Screen スクリーン
+ Screen resolution 画面解像度
+ Scrubby slider acceleration スクラブスライダーの加速
+ Sessions only セッションのみ
+ Sharpen for シャープの対象
+ Show channels in color チャンネルをカラーで表示
+ Show crosshair in brush tip ブラシ先端に十字線を表示
+ Show extension panels 拡張パネルを表示
+ Show font names in english フォント名を英語で表示
+ Show menu colors メニューの色を表示
+ Show only crosshair while painting 描画中は十字線のみ表示
+ Show slice numbers スライス番号を表示
+ Show tooltips ツールチップを表示
+ Show transformation values 変形値を表示
+ Slice color スライスの色
+ Smart guide color スマートガイドの色
+ Smart quotes スマート引用符
+ Snap vector tools and transforms to pixel grid ベクトルツールと変形をピクセルグリッドにスナップ
+ Srgb sRGB
+ Standard 標準
+ Studio スタジオ
+ Studio light スタジオ(ライト)
+ Subdivisions 分割数
+ System システム
+ Text engine テキストエンジン
+ Text file テキストファイル
+ Tiny 極小
+ Touch gestures タッチジェスチャ
+ Transparency & Gamut 透明部分・色域
+ Type units 文字の単位
+ UI font size UI のフォントサイズ
+ UI scale UI の拡大率
+ Units & Rulers 単位・定規
+ Use additional plugins folder 追加のプラグインフォルダーを使う
+ Use esc to commit Esc キーで確定
+ Use gpu GPU を使用
+ Use legacy free transform 従来の自由変形を使用
+ Use shift key for tool switch Shift キーでツールを切り替え
+ Vary round brush hardness on hud HUD で丸ブラシの硬さを変更
+ Webp WebP
+ World ready 多言語対応
+ Zoom clicked point to center クリックした位置を中央にズーム
+ Zoom resizes windows ズームでウィンドウをリサイズ
+ Zoom with scroll wheel スクロールホイールでズーム
+ Zoom with trackpad pinch トラックパッドのピンチでズーム
+ Pass Through 通過
+ Dissolve ディザ合成
+ Darker Color カラー比較(暗)
+ Linear Dodge (Add) 覆い焼き(リニア)- 加算
+ Lighter Color カラー比較(明)
+ Soft Light ソフトライト
+ Hard Light ハードライト
+ Vivid Light ビビッドライト
+ Linear Light リニアライト
+ Pin Light ピンライト
+ Exclusion 除外
+ Divide 除算
+ Luminosity 輝度
+@plural {n} sample|{n} samples サンプル {n} 個
+ {added}, {removed} subtracted {added}、除外 {removed} 個
+
+# Added with the rebase onto the dock / brush picker work
+ Adjustment Preview 色調補正のプレビュー
+ Airbrush: keeps depositing paint while the pointer rests. エアブラシ: ポインターを止めている間も塗料を乗せ続けます。
+ Angle: 角度:
+ Blend If 条件付き合成
+ Close Tab Group タブグループを閉じる
+ Collapse 折りたたむ
+ Collapse All Groups すべてのグループを折りたたむ
+ Collapse Panel Group パネルグループを折りたたむ
+ Collapse group ({key}-click: all groups) グループを折りたたむ({key}+クリック: すべてのグループ)
+ Create new brush from the current settings 現在の設定から新規ブラシを作成
+ Create new brush from these settings この設定から新規ブラシを作成
+ Delete brush ブラシを削除
+ Drag the arrow to set the angle, the dots to set the roundness 矢印をドラッグして角度、点をドラッグして真円率を設定
+ Expand 展開
+ Expand Panel Group パネルグループを展開
+ Expand group ({key}-click: all groups) グループを展開({key}+クリック: すべてのグループ)
+ Fade steps フェードのステップ数
+ Hide the layer's effects ({key}-click: all layers) レイヤーの効果を隠す({key}+クリック: すべてのレイヤー)
+ Import Brushes… (.abr) ブラシを読み込み…(.abr)
+ Move Group Down グループを下へ移動
+ Move Group Up グループを上へ移動
+ Reset the brush to the defaults ブラシを既定に戻す
+ Restore original size 元のサイズに戻す
+ Roundness: 真円率:
+ Search Brushes ブラシを検索
+ Show the layer's effects ({key}-click: all layers) レイヤーの効果を表示({key}+クリック: すべてのレイヤー)
+ Brush picker ブラシピッカー
+ Erase 消去
+ Right click with painting tools 描画ツールで右クリック
+
+# Strings added to the UI after this catalog was first written (rebase onto main, 2026-10).
+ System Info… システム情報…
+ System Info システム情報
+ More panels その他のパネル
+ These settings aren't available in PhotoCraft yet. これらの設定は PhotoCraft ではまだ使用できません。
+ Graphics グラフィックス
+ Reset GPU Backend GPU バックエンドをリセット
+ Applies at next launch. 次回の起動時に適用されます。
+ Click to sample the foreground colour · {key}-click for background クリックで描画色を取得 · {key}+クリックで背景色を取得
+ {key}-click to set the source {key}+クリックでソースを設定
+ {key} to subtract {key} で削除
+ Clone source {n} ({key}-click with Clone Stamp to set) コピーソース {n}({key}+クリックでコピースタンプのソースを設定)
+ Source: not set ({key}-click with Clone Stamp) ソース: 未設定({key}+クリックでコピースタンプ)
+ Pixel Layer ピクセルレイヤー
+ Type Layer 文字レイヤー
+ Shape Layer シェイプレイヤー
+ Group Layer グループレイヤー
+ Fill Layer 塗りつぶしレイヤー
+ Smart Object Layer スマートオブジェクトレイヤー
+ Create Warped Text ワープテキストを作成
+ Rasterize Smart Object スマートオブジェクトをラスタライズ
+ Rasterize Fill Content 塗りの内容をラスタライズ
+ Unlock: picking a preset replaces these settings ロック解除: プリセットを選ぶとこの設定は置き換わります
+ Lock: keep these settings when picking another preset ロック: 別のプリセットを選んでもこの設定を保持します
+ Diameter: 直径:
+ Hardness: 硬さ:
+ No brush presets ブラシプリセットがありません
+ Toggle the Brush Settings panel (F5) ブラシ設定パネルの表示を切り替え(F5)
+ Create new brush preset from the current settings 現在の設定から新規ブラシプリセットを作成
+ Brush Settings… (F5): every option of this brush ブラシ設定…(F5): このブラシのすべてのオプション
+ Rename Brush… ブラシの名前を変更…
+ Delete Brush ブラシを削除
+ Group name グループ名
+ Brush name ブラシ名
+ Grid view グリッド表示
+ List view リスト表示
+ Off: the speed of the pointer sets the spacing オフ: ポインターの速度で間隔が決まります
+ Tilt Scale 傾きの比率
+ Brush Projection ブラシの投影
+ Apply the pen's tilt and rotation to the tip shape ペンの傾きと回転を先端のシェイプに適用します
+ Mixer Brush 混合ブラシ
+ Wet ウェット
+ Mix 混合
+ Wetness Jitter ウェットのジッター
+ Mix Jitter 混合のジッター
+ Show the layer mask as an overlay レイヤーマスクをオーバーレイで表示
+ Toggle visibility 表示/非表示を切り替え
+ Unlink the mask from the layer マスクとレイヤーのリンクを解除
+ Link the mask to the layer マスクをレイヤーにリンク
+ Gradient グラデーション
+ Gradient Options グラデーションオプション
+ Align with layer レイヤーに揃える
+ Reset Alignment 位置をリセット
+ Centre the gradient (offset 0, 0) グラデーションを中央に配置(オフセット 0, 0)
+ The current gradient (pick one in Window › Gradients) 現在のグラデーション(ウィンドウ › グラデーション で選択)
+ Select a type layer to edit its character and paragraph settings. 文字レイヤーを選択すると、文字と段落の設定を編集できます。
+ Text color 文字色
+ Type Options 文字オプション
+ Anti-aliasing method アンチエイリアスの種類
+ Horizontal type 横書き
+ Vertical type 縦書き
+ Fill path with foreground color パスを描画色で塗りつぶす
+ Stroke path with brush ブラシでパスの境界線を描く
+ Load path as a selection パスを選択範囲として読み込む
+ Make work path from selection 選択範囲から作業用パスを作成
+ Add vector mask ベクトルマスクを追加
+ Create new path 新規パスを作成
+ Delete path パスを削除
+ Delete vector mask ベクトルマスクを削除
+ CPU (no GPU acceleration) CPU(GPU アクセラレーションなし)
+ DirectX 12 DirectX 12
+ GPU backend GPU バックエンド
+ Metal Metal
+ OpenGL OpenGL
+ Use tablet pressure タブレットの筆圧を使用
+ Vulkan Vulkan
diff --git a/crates/ui-egui/src/i18n/mod.rs b/crates/ui-egui/src/i18n/mod.rs
new file mode 100644
index 000000000..82b3633df
--- /dev/null
+++ b/crates/ui-egui/src/i18n/mod.rs
@@ -0,0 +1,433 @@
+//! UI localisation. Strings in code stay English and are the default lookup keys; a per-language
+//! catalog (`*.tsv`, see `ja.tsv` for the format) maps them to display text at render time. Command
+//! ids, menu paths used for logic, the control channel, the CLI and MCP never see translated text,
+//! so agents and scripts are unaffected. A string without a translation is shown in English.
+//!
+//! # Adding a language
+//! 1. Add `xx.tsv` next to `ja.tsv` (copy its header; translate from the *meaning* of the English
+//! text, clean-room, see `ja.tsv`).
+//! 2. Add one row to [`LANGUAGES`] (code, native name, catalog, plural rule).
+//!
+//! That is all: the Preferences dropdown, the system-locale match and the catalog tests (parse,
+//! placeholders, plural forms) pick it up from the registry.
+//!
+//! # Looking strings up
+//! - [`tr`]: a plain string. [`tr_ctx`]: when one English word needs different translations.
+//! - [`tr_id`]: a command-id keyed string with the English label as fallback (menu items), so a
+//! translation survives rewording of the English text and can differ per command.
+//! - [`trn`]: plural-aware (`{n}` is filled in). [`fmt`]: fill `{name}` placeholders after [`tr`];
+//! translators may reorder placeholders freely.
+
+mod catalog;
+
+use std::sync::OnceLock;
+use std::sync::atomic::{AtomicUsize, Ordering};
+
+use catalog::Catalog;
+
+/// One supported UI language.
+pub struct LangInfo {
+ /// BCP 47 code, lowercase (`ja`, `zh-hans`, `pt-br`). Also the `interface.language` value.
+ pub code: &'static str,
+ /// The language's name in itself, shown in the Preferences dropdown.
+ pub name: &'static str,
+ /// Catalog file contents (empty for the built-in English).
+ pub source: &'static str,
+ /// Plural form index for a count (English: 0 = one, 1 = other; Japanese: always 0).
+ pub plural: fn(u64) -> usize,
+ /// Must the catalog cover every menu string? (checked by the tests)
+ pub complete_menus: bool,
+ catalog: OnceLock<Catalog>,
+}
+
+fn plural_one_other(n: u64) -> usize {
+ usize::from(n != 1)
+}
+
+fn plural_none(_: u64) -> usize {
+ 0
+}
+
+/// The registry. English first: it is the fallback and the source language.
+pub static LANGUAGES: [LangInfo; 2] = [
+ LangInfo { code: "en", name: "English", source: "", plural: plural_one_other, complete_menus: false, catalog: OnceLock::new() },
+ LangInfo { code: "ja", name: "日本語", source: include_str!("ja.tsv"), plural: plural_none, complete_menus: true, catalog: OnceLock::new() },
+];
+
+impl LangInfo {
+ fn catalog(&self) -> &Catalog {
+ self.catalog.get_or_init(|| Catalog::parse(self.source))
+ }
+}
+
+/// A language the UI can be shown in (a handle into [`LANGUAGES`]).
+#[derive(Clone, Copy)]
+pub struct Lang(&'static LangInfo);
+
+impl std::fmt::Debug for Lang {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "Lang({})", self.0.code)
+ }
+}
+
+impl PartialEq for Lang {
+ fn eq(&self, other: &Self) -> bool {
+ self.0.code == other.0.code
+ }
+}
+
+impl Eq for Lang {}
+
+impl Lang {
+ pub const EN: Lang = Lang(&LANGUAGES[0]);
+
+ pub fn code(self) -> &'static str {
+ self.0.code
+ }
+
+ /// A language by its exact code.
+ pub fn from_code(code: &str) -> Option<Lang> {
+ LANGUAGES.iter().find(|l| l.code.eq_ignore_ascii_case(code)).map(Lang)
+ }
+
+ /// Resolve the `interface.language` preference: a language code, or `auto` (and anything
+ /// unknown, e.g. a code from a newer version) to follow the system locale.
+ pub fn from_pref(pref: &str) -> Lang {
+ Lang::from_code(pref).unwrap_or_else(system_lang)
+ }
+
+ /// Every registered language.
+ pub fn all() -> impl Iterator<Item = Lang> {
+ LANGUAGES.iter().map(Lang)
+ }
+
+ pub fn name(self) -> &'static str {
+ self.0.name
+ }
+
+ fn catalog(self) -> &'static Catalog {
+ self.0.catalog()
+ }
+}
+
+/// Candidate language codes for a locale tag, most specific first: `zh_TW.UTF-8` →
+/// `zh-tw`, `zh-hant`, `zh`.
+fn candidates(tag: &str) -> Vec<String> {
+ let base = tag.split(['.', '@']).next().unwrap_or("").replace('_', "-").to_ascii_lowercase();
+ let parts: Vec<&str> = base.split('-').filter(|p| !p.is_empty()).collect();
+ let Some(&primary) = parts.first() else { return Vec::new() };
+ let mut out = Vec::new();
+ for n in (1..=parts.len()).rev() {
+ out.push(parts[..n].join("-"));
+ }
+ if primary == "zh" && !parts.iter().any(|p| matches!(*p, "hans" | "hant")) {
+ // Chinese by region when no script is given.
+ let script = if parts.iter().any(|p| matches!(*p, "tw" | "hk" | "mo")) { "zh-hant" } else { "zh-hans" };
+ out.insert(out.len() - 1, script.to_string());
+ }
+ out
+}
+
+/// The registered language for a locale tag such as `ja_JP.UTF-8`, `ja-JP`, `zh-TW`; `None` if
+/// the language isn't supported. `C`/`POSIX` mean English.
+pub fn lang_from_tag(tag: &str) -> Option<Lang> {
+ let cands = candidates(tag);
+ if matches!(cands.first().map(String::as_str), Some("c" | "posix")) {
+ return Some(Lang::EN);
+ }
+ cands.iter().find_map(|c| Lang::from_code(c))
+}
+
+/// The system language (cached). English when it can't be determined.
+pub fn system_lang() -> Lang {
+ // Tests drive the UI by its English labels whatever the developer's locale is.
+ if cfg!(test) {
+ return Lang::EN;
+ }
+ static SYSTEM: OnceLock<Lang> = OnceLock::new();
+ *SYSTEM.get_or_init(detect_system_lang)
+}
+
+#[cfg(not(target_arch = "wasm32"))]
+fn detect_system_lang() -> Lang {
+ for var in ["LC_ALL", "LC_MESSAGES", "LANG"] {
+ if let Some(l) = std::env::var(var).ok().filter(|v| !v.is_empty()).and_then(|v| lang_from_tag(&v)) {
+ return l;
+ }
+ }
+ // Apps started from the Finder don't inherit LANG: use the macOS preferred-languages list.
+ // The absolute path keeps a `defaults` earlier on PATH from running; any failure means English.
+ #[cfg(target_os = "macos")]
+ if let Ok(out) = std::process::Command::new("/usr/bin/defaults").args(["read", "-g", "AppleLanguages"]).output()
+ && out.status.success()
+ && let Some(l) = first_supported(&String::from_utf8_lossy(&out.stdout))
+ {
+ return l;
+ }
+ Lang::EN
+}
+
+/// The first supported language in a `defaults read` list like `(\n "ja-JP",\n "en-US"\n)`.
+#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
+fn first_supported(list: &str) -> Option<Lang> {
+ list.split(['(', ')', ',', '"', '\n']).map(str::trim).filter(|s| !s.is_empty()).find_map(lang_from_tag)
+}
+
+#[cfg(target_arch = "wasm32")]
+fn detect_system_lang() -> Lang {
+ Lang::EN
+}
+
+/// Index into [`LANGUAGES`] of the language the UI is drawn in this frame.
+static CURRENT: AtomicUsize = AtomicUsize::new(0);
+
+/// Set the UI language for drawing (the shell calls this once per frame from the preference), so
+/// widgets can translate without every call site carrying a language around.
+pub fn set_current(lang: Lang) {
+ let i = LANGUAGES.iter().position(|l| l.code == lang.code()).unwrap_or(0);
+ CURRENT.store(i, Ordering::Relaxed);
+}
+
+/// The language the UI is drawn in.
+pub fn current() -> Lang {
+ Lang(LANGUAGES.get(CURRENT.load(Ordering::Relaxed)).unwrap_or(&LANGUAGES[0]))
+}
+
+/// Does `lang` have a catalog entry for this plain string? (English never does: it is the source.)
+pub fn has(lang: Lang, s: &str) -> bool {
+ lang.catalog().plain(s).is_some()
+}
+
+/// Translate an English UI string into the current language ([`tr`] with [`current`]).
+pub fn t(s: &str) -> &str {
+ tr(current(), s)
+}
+
+/// Translate an English UI string; unknown strings come back unchanged.
+pub fn tr(lang: Lang, s: &str) -> &str {
+ lang.catalog().plain(s).unwrap_or(s)
+}
+
+/// Like [`tr`], for an English string that needs a disambiguating `context`.
+pub fn tr_ctx<'a>(lang: Lang, context: &str, s: &'a str) -> &'a str {
+ lang.catalog().contextual(context, s).unwrap_or_else(|| tr(lang, s))
+}
+
+/// A string keyed by its command id, falling back to the translation of the English `label`.
+pub fn tr_id<'a>(lang: Lang, id: &str, label: &'a str) -> &'a str {
+ lang.catalog().id(id).unwrap_or_else(|| tr(lang, label))
+}
+
+/// Fill `{name}` placeholders. Unknown placeholders are left as written.
+pub fn fmt(template: &str, args: &[(&str, &str)]) -> String {
+ let mut out = template.to_string();
+ for (k, v) in args {
+ out = out.replace(&format!("{{{k}}}"), v);
+ }
+ out
+}
+
+/// A plural-aware message: `one`/`other` are the English forms (with `{n}` where the count goes).
+pub fn trn(lang: Lang, n: u64, one: &str, other: &str) -> String {
+ let idx = (lang.0.plural)(n);
+ let text = lang.catalog().plural(one, other, idx).unwrap_or(if n == 1 { one } else { other });
+ fmt(text, &[("n", &n.to_string())])
+}
+
+#[cfg(test)]
+mod tests {
+ use super::catalog::{parse_entries, placeholders};
+ use super::*;
+
+ const JA: fn() -> Lang = || Lang::from_code("ja").expect("ja registered");
+
+ #[test]
+ fn tags_map_to_languages() {
+ assert_eq!(lang_from_tag("ja_JP.UTF-8"), Some(JA()));
+ assert_eq!(lang_from_tag("ja-JP"), Some(JA()));
+ assert_eq!(lang_from_tag("en_US.UTF-8"), Some(Lang::EN));
+ assert_eq!(lang_from_tag("C"), Some(Lang::EN));
+ assert_eq!(lang_from_tag("POSIX"), Some(Lang::EN));
+ assert_eq!(lang_from_tag("fr_FR"), None);
+ assert_eq!(lang_from_tag(""), None);
+ assert_eq!(lang_from_tag("_"), None);
+ }
+
+ #[test]
+ fn candidates_walk_from_specific_to_general() {
+ assert_eq!(candidates("pt_BR.UTF-8"), ["pt-br", "pt"]);
+ assert_eq!(candidates("zh_TW"), ["zh-tw", "zh-hant", "zh"]);
+ assert_eq!(candidates("zh-CN"), ["zh-cn", "zh-hans", "zh"]);
+ assert_eq!(candidates("zh-Hant-HK"), ["zh-hant-hk", "zh-hant", "zh"]);
+ }
+
+ #[test]
+ fn macos_language_list_is_parsed() {
+ assert_eq!(first_supported("(\n \"ja-JP\",\n \"en-US\"\n)\n"), Some(JA()));
+ assert_eq!(first_supported("(\n \"fr-FR\",\n \"en-US\"\n)\n"), Some(Lang::EN));
+ assert_eq!(first_supported("("), None);
+ }
+
+ #[test]
+ fn preferences_resolve_with_fallback() {
+ assert_eq!(Lang::from_pref("ja"), JA());
+ assert_eq!(Lang::from_pref("JA"), JA());
+ assert_eq!(Lang::from_pref("en"), Lang::EN);
+ // `auto` and unknown codes follow the system (English under test).
+ assert_eq!(Lang::from_pref("auto"), Lang::EN);
+ assert_eq!(Lang::from_pref("xx-unknown"), Lang::EN);
+ }
+
+ #[test]
+ fn lookups_fall_back_to_english() {
+ assert_eq!(tr(JA(), "no such label"), "no such label");
+ assert_eq!(tr(Lang::EN, "Layer"), "Layer");
+ assert_eq!(tr(JA(), "Layer"), "レイヤー");
+ assert_eq!(tr_id(JA(), "no.such.id", "Layer"), "レイヤー");
+ assert_eq!(tr_ctx(JA(), "no such context", "Layer"), "レイヤー");
+ }
+
+ #[test]
+ fn catalog_kinds_are_parsed_and_looked_up() {
+ let c = Catalog::parse("# c\n\tHello\tこんにちは\n@id\tfile.save\t保存する\nmenu\tWindows\tウィンドウ群\n@plural\t{n} file|{n} files\t{n} 個\n\n");
+ assert_eq!(c.plain("Hello"), Some("こんにちは"));
+ assert_eq!(c.id("file.save"), Some("保存する"));
+ assert_eq!(c.contextual("menu", "Windows"), Some("ウィンドウ群"));
+ assert_eq!(c.contextual("other", "Windows"), None);
+ assert_eq!(c.plural("{n} file", "{n} files", 0), Some("{n} 個"));
+ assert_eq!(c.plural("{n} file", "{n} files", 5), Some("{n} 個"), "an index past the forms clamps");
+ }
+
+ #[test]
+ fn malformed_lines_are_reported_not_fatal() {
+ let (entries, errors) = parse_entries("\tok\tはい\nno tabs here\n\tonly\n\ta\tb\tc\textra\n\t\tempty source\n");
+ assert_eq!(entries.len(), 1);
+ assert_eq!(errors.len(), 4, "{errors:?}");
+ assert_eq!(parse_entries("\ta\\tb\tx\\ny\\\\z\n").0[0], (String::new(), "a\tb".into(), "x\ny\\z".into()));
+ }
+
+ #[test]
+ fn plurals_and_placeholders() {
+ assert_eq!(trn(Lang::EN, 1, "{n} item", "{n} items"), "1 item");
+ assert_eq!(trn(Lang::EN, 0, "{n} item", "{n} items"), "0 items");
+ assert_eq!(trn(Lang::EN, 7, "{n} item", "{n} items"), "7 items");
+ assert_eq!(trn(JA(), 1, "{n} item", "{n} items"), "1 件");
+ assert_eq!(trn(JA(), 7, "{n} item", "{n} items"), "7 件");
+ assert_eq!(fmt("{b} before {a}", &[("a", "x"), ("b", "y"), ("c", "z")]), "y before x");
+ assert_eq!(fmt("{missing}", &[]), "{missing}");
+ assert_eq!(placeholders("a {x} b {y} {"), ["x", "y"]);
+ }
+
+ /// Every bundled catalog is well-formed and consistent with its sources.
+ #[test]
+ fn bundled_catalogs_are_consistent() {
+ for l in &LANGUAGES {
+ assert!(l.code == l.code.to_ascii_lowercase() && !l.name.is_empty(), "{}", l.code);
+ let (entries, errors) = parse_entries(l.source);
+ assert!(errors.is_empty(), "{}: {errors:?}", l.code);
+ let mut seen = std::collections::HashSet::new();
+ for (ctx, src, tr) in &entries {
+ assert!(seen.insert((ctx.clone(), src.clone())), "{}: duplicate {ctx:?} {src:?}", l.code);
+ if ctx == "@plural" {
+ let one_other: Vec<&str> = src.split('|').collect();
+ assert_eq!(one_other.len(), 2, "{}: plural source must be `one|other`: {src:?}", l.code);
+ for form in tr.split('|') {
+ let mut want = placeholders(one_other[1]);
+ let mut got = placeholders(form);
+ want.sort_unstable();
+ got.sort_unstable();
+ assert_eq!(want, got, "{}: placeholders differ in {src:?}", l.code);
+ }
+ continue;
+ }
+ let mut want = placeholders(src);
+ let mut got = placeholders(tr);
+ want.sort_unstable();
+ got.sort_unstable();
+ assert_eq!(want, got, "{}: placeholders differ in {src:?}", l.code);
+ if ctx.is_empty() {
+ assert_eq!(src.ends_with('…'), tr.ends_with('…'), "{}: ellipsis mismatch: {src:?}", l.code);
+ }
+ if ctx == "@id" {
+ assert!(crate::menus::is_live(src) || crate::menu_catalog::CATALOG.iter().any(|m| m.3 == src), "{}: unknown command id {src:?}", l.code);
+ }
+ }
+ }
+ }
+
+ /// Languages that claim complete menus have an entry for every label and path segment.
+ #[test]
+ fn complete_languages_translate_every_menu_string() {
+ let mut strings = std::collections::BTreeSet::new();
+ for &(path, label, _, _) in crate::menu_catalog::CATALOG {
+ strings.extend(path.iter().copied());
+ strings.insert(label);
+ }
+ for &(_, label, path, _) in crate::menus::UI_COMMANDS {
+ strings.extend(path.iter().copied());
+ strings.insert(label);
+ }
+ for c in photocraft_engine::command_specs().iter().filter(|c| !c.menu.is_empty()) {
+ strings.extend(c.menu.iter().copied());
+ strings.insert(c.label);
+ }
+ strings.remove("---");
+ for l in LANGUAGES.iter().filter(|l| l.complete_menus) {
+ let cat = l.catalog();
+ let missing: Vec<_> = strings.iter().filter(|s| cat.plain(s).is_none()).collect();
+ assert!(missing.is_empty(), "{}: untranslated menu strings: {missing:#?}", l.code);
+ }
+ }
+
+ /// Every `tl!("literal")` in the shell has an entry in each language that claims complete menus
+ /// (so a new label can't ship untranslated by accident). Literals that are deliberately shown as
+ /// they are (names, units) are listed in `KEEP_AS_IS`.
+ #[test]
+ fn every_tl_literal_is_translated() {
+ const KEEP_AS_IS: &[&str] = &[];
+ let dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("src");
+ let mut literals = std::collections::BTreeSet::new();
+ let mut stack = vec![dir];
+ while let Some(d) = stack.pop() {
+ for entry in std::fs::read_dir(&d).into_iter().flatten().flatten() {
+ let path = entry.path();
+ if path.is_dir() {
+ stack.push(path);
+ } else if path.extension().is_some_and(|e| e == "rs") && !path.ends_with("lib.rs") {
+ let text = std::fs::read_to_string(&path).unwrap_or_default();
+ // Test modules aside, scan every `tl!("…")`.
+ let code = text.split("#[cfg(test)]").next().unwrap_or("");
+ let mut rest = code;
+ while let Some(at) = rest.find("tl!(\"") {
+ rest = &rest[at + 5..];
+ let mut end = 0;
+ let bytes = rest.as_bytes();
+ while end < bytes.len() && !(bytes[end] == b'"' && (end == 0 || bytes[end - 1] != b'\\')) {
+ end += 1;
+ }
+ let lit = rest.get(..end).unwrap_or("").replace("\\\"", "\"");
+ if rest.get(end + 1..end + 2) == Some(")") {
+ literals.insert(lit);
+ }
+ }
+ }
+ }
+ }
+ assert!(literals.len() > 300, "scan found only {} literals", literals.len());
+ for l in LANGUAGES.iter().filter(|l| l.complete_menus) {
+ let cat = l.catalog();
+ let missing: Vec<_> = literals.iter().filter(|s| !KEEP_AS_IS.contains(&s.as_str()) && cat.plain(s).is_none()).collect();
+ assert!(missing.is_empty(), "{}: untranslated tl! strings: {missing:#?}", l.code);
+ }
+ }
+
+ /// Blend mode names come from the colour crate; each must be translated.
+ #[test]
+ fn blend_mode_names_are_translated() {
+ for l in LANGUAGES.iter().filter(|l| l.complete_menus) {
+ for m in std::iter::once(photocraft_color::BlendMode::PassThrough).chain(photocraft_color::BlendMode::LAYER_MODES) {
+ assert!(l.catalog().plain(m.label()).is_some(), "{}: blend mode {:?}", l.code, m.label());
+ }
+ }
+ }
+}
diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs
index ca5df7b10..d8076a10e 100644
--- a/crates/ui-egui/src/icons.rs
+++ b/crates/ui-egui/src/icons.rs
@@ -107,7 +107,7 @@ pub fn button(ui: &mut egui::Ui, name: &str, box_size: f32, selected: bool, tool
t.icon
};
paint(ui, rect, name, (box_size * 0.52).round(), tint);
- if tooltip.is_empty() { resp } else { resp.on_hover_text(tooltip) }
+ if tooltip.is_empty() { resp } else { resp.on_hover_text(tl!(tooltip)) }
}
/// Rail toggle: "on" gets a quiet filled background and full-strength icon (no accent).
@@ -122,7 +122,7 @@ pub fn rail_button(ui: &mut egui::Ui, name: &str, box_size: f32, on: bool, toolt
}
let tint = if on || resp.hovered() { t.text } else { t.text_faint };
paint(ui, rect, name, (box_size * 0.52).round(), tint);
- resp.on_hover_text(tooltip)
+ resp.on_hover_text(tl!(tooltip))
}
#[cfg(test)]
diff --git a/crates/ui-egui/src/layer_menu_ui.rs b/crates/ui-egui/src/layer_menu_ui.rs
index 82d7a19b5..140b3bebd 100644
--- a/crates/ui-egui/src/layer_menu_ui.rs
+++ b/crates/ui-egui/src/layer_menu_ui.rs
@@ -21,21 +21,21 @@ pub fn add_mask_command(has_selection: bool, alt: bool) -> &'static str {
/// The context menu entries for a layer (Photoshop 2026 order, trimmed to the layer kind).
pub fn entries(l: &Layer, multi: bool, has_selection: bool) -> Vec<Entry> {
- let mut v: Vec<Entry> = vec![Some(("Blending Options…", "layer.layerStyle.blendingOptions"))];
+ let mut v: Vec<Entry> = vec![Some((tl!("Blending Options…"), "layer.layerStyle.blendingOptions"))];
v.push(None);
- v.push(Some((if multi { "Duplicate Layers…" } else { "Duplicate Layer…" }, "layer.duplicate")));
- v.push(Some((if multi { "Delete Layers" } else { "Delete Layer" }, "layer.delete")));
+ v.push(Some((if multi { tl!("Duplicate Layers…") } else { tl!("Duplicate Layer…") }, "layer.duplicate")));
+ v.push(Some((if multi { tl!("Delete Layers") } else { tl!("Delete Layer") }, "layer.delete")));
if !multi {
- v.push(Some(("Group from Layers…", "layer.groupLayers")));
+ v.push(Some((tl!("Group from Layers…"), "layer.groupLayers")));
}
v.push(None);
- v.push(Some(("Quick Export As PNG", "layer.quickExportAsPng")));
- v.push(Some(("Export As…", "layer.exportAs")));
+ v.push(Some((tl!("Quick Export As PNG"), "layer.quickExportAsPng")));
+ v.push(Some((tl!("Export As…"), "layer.exportAs")));
v.push(None);
- v.push(Some(("Artboard from Layers…", "layer.new.artboardFromLayers")));
- v.push(Some(("Frame from Layers…", "layer.new.frameFromLayers")));
+ v.push(Some((tl!("Artboard from Layers…"), "layer.new.artboardFromLayers")));
+ v.push(Some((tl!("Frame from Layers…"), "layer.new.frameFromLayers")));
v.push(None);
- v.push(Some(("Convert to Smart Object", "layer.smartObjects.convertToSmartObject")));
+ v.push(Some((tl!("Convert to Smart Object"), "layer.smartObjects.convertToSmartObject")));
match &l.content {
LayerContent::Text(_) => v.push(Some(("Rasterize Type", "layer.rasterize.type"))),
LayerContent::Shape(_) => v.push(Some(("Rasterize Layer", "layer.rasterize.shape"))),
@@ -45,31 +45,31 @@ pub fn entries(l: &Layer, multi: bool, has_selection: bool) -> Vec<Entry> {
}
v.push(None);
if l.mask.is_some() {
- v.push(Some(("Disable Layer Mask", "layer.layerMask.enabled")));
- v.push(Some(("Apply Layer Mask", "layer.layerMask.apply")));
- v.push(Some(("Delete Layer Mask", "layer.layerMask.delete")));
+ v.push(Some((tl!("Disable Layer Mask"), "layer.layerMask.enabled")));
+ v.push(Some((tl!("Apply Layer Mask"), "layer.layerMask.apply")));
+ v.push(Some((tl!("Delete Layer Mask"), "layer.layerMask.delete")));
} else {
- v.push(Some(("Add Layer Mask", add_mask_command(has_selection, false))));
+ v.push(Some((tl!("Add Layer Mask"), add_mask_command(has_selection, false))));
}
v.push(Some((
- if l.clipped { "Release Clipping Mask" } else { "Create Clipping Mask" },
+ if l.clipped { tl!("Release Clipping Mask") } else { tl!("Create Clipping Mask") },
if l.clipped { "layer.releaseClippingMask" } else { "layer.createClippingMask" },
)));
v.push(None);
- v.push(Some(("Link Layers", "layer.linkLayers")));
- v.push(Some(("Select Linked Layers", "layer.selectLinkedLayers")));
+ v.push(Some((tl!("Link Layers"), "layer.linkLayers")));
+ v.push(Some((tl!("Select Linked Layers"), "layer.selectLinkedLayers")));
v.push(None);
- v.push(Some(("Copy Layer Style", "layer.layerStyle.copyLayerStyle")));
- v.push(Some(("Paste Layer Style", "layer.layerStyle.pasteLayerStyle")));
- v.push(Some(("Clear Layer Style", "layer.layerStyle.clear")));
+ v.push(Some((tl!("Copy Layer Style"), "layer.layerStyle.copyLayerStyle")));
+ v.push(Some((tl!("Paste Layer Style"), "layer.layerStyle.pasteLayerStyle")));
+ v.push(Some((tl!("Clear Layer Style"), "layer.layerStyle.clear")));
v.push(None);
if multi {
- v.push(Some(("Merge Layers", "layer.mergeLayers")));
+ v.push(Some((tl!("Merge Layers"), "layer.mergeLayers")));
} else {
- v.push(Some(("Merge Down", "layer.mergeDown")));
+ v.push(Some((tl!("Merge Down"), "layer.mergeDown")));
}
- v.push(Some(("Merge Visible", "layer.mergeVisible")));
- v.push(Some(("Flatten Image", "layer.flattenImage")));
+ v.push(Some((tl!("Merge Visible"), "layer.mergeVisible")));
+ v.push(Some((tl!("Flatten Image"), "layer.flattenImage")));
v
}
@@ -98,7 +98,7 @@ pub fn show(app: &crate::PhotocraftApp, ui: &mut egui::Ui, l: &Layer, on_set: bo
// selected first when clicked, so its items stay available.
let is_active = app.session.active().is_some_and(|s| s.active_layer == Some(l.id));
let enabled = if on_set || is_active { crate::menus::is_enabled(app, id) } else { true };
- if ui.add_enabled(enabled, egui::Button::new(label)).clicked() {
+ if ui.add_enabled(enabled, egui::Button::new(tl!(&label))).clicked() {
if !on_set {
actions.push(("layer.select".into(), json!({"layer": l.id.0})));
}
@@ -109,7 +109,7 @@ pub fn show(app: &crate::PhotocraftApp, ui: &mut egui::Ui, l: &Layer, on_set: bo
}
}
ui.separator();
- if ui.button("Rename Layer…").clicked() {
+ if ui.button(tl!("Rename Layer…")).clicked() {
rename = true;
ui.close();
}
diff --git a/crates/ui-egui/src/layer_props_ui.rs b/crates/ui-egui/src/layer_props_ui.rs
index 8422cb705..b9ae55e83 100644
--- a/crates/ui-egui/src/layer_props_ui.rs
+++ b/crates/ui-egui/src/layer_props_ui.rs
@@ -37,7 +37,7 @@ pub fn transform_params(layer: u64, b: [i32; 4], w: Option<f32>, h: Option<f32>,
fn field(ui: &mut egui::Ui, id: &str, label: &str, current: f32, width: f32) -> Option<f32> {
let t = Tokens::get(ui.ctx());
let (r, _) = ui.allocate_exact_size(vec2(LABEL_W, 22.0), Sense::hover());
- ui.painter().text(pos2(r.right() - 2.0, r.center().y), egui::Align2::RIGHT_CENTER, label, egui::FontId::proportional(12.0), t.text_dim);
+ ui.painter().text(pos2(r.right() - 2.0, r.center().y), egui::Align2::RIGHT_CENTER, tl!(label), egui::FontId::proportional(12.0), t.text_dim);
let key = egui::Id::new(("layer-props-field", id));
let mut v = ui.data(|d| d.get_temp::<f32>(key)).unwrap_or(current);
let resp = widgets::value_field(ui, &mut v, -300_000.0..=300_000.0, "px", width);
@@ -99,7 +99,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
let mut run: Vec<(String, Value)> = Vec::new();
if let Some(s) = layer.surface() {
let b = app.cached_bounds(layer.id.0, s);
- if section(ui, "transform", "Transform") {
+ if section(ui, "transform", tl!("Transform")) {
let link_key = egui::Id::new("layer-props-link");
let linked = ui.data(|d| d.get_temp::<bool>(link_key)).unwrap_or(true);
let bb = [b.x0, b.y0, b.x1, b.y1];
@@ -110,7 +110,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
if let Some(v) = field(ui, "w", "W", b.width() as f32, w) {
run.extend(transform_params(layer.id.0, bb, Some(v), None, linked).map(|p| ("edit.transform".to_string(), p)));
}
- if crate::icons::button(ui, if linked { "link" } else { "unlink" }, LINK_W, linked, "Link width and height").clicked() {
+ if crate::icons::button(ui, if linked { "link" } else { "unlink" }, LINK_W, linked, tl!("Link width and height")).clicked() {
ui.data_mut(|d| d.insert_temp(link_key, !linked));
}
if let Some(v) = field(ui, "h", "H", b.height() as f32, w) {
@@ -135,7 +135,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
if matches!(layer.content, LayerContent::Fill(photocraft_doc::Fill::Gradient { .. })) {
crate::gradient_ui::properties(app, ui, layer);
}
- if section(ui, "align", "Align and Distribute") {
+ if section(ui, "align", tl!("Align and Distribute")) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
for (i, kind) in ["leftEdges", "horizontalCenters", "rightEdges", "topEdges", "verticalCenters", "bottomEdges"].into_iter().enumerate() {
@@ -150,7 +150,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
ui.painter().rect_filled(r, t.radius_sm, t.hover);
}
align_glyph(ui, r, kind, if on { t.icon } else { t.text_faint });
- if resp.on_hover_text(format!("Align {label}")).clicked() {
+ if resp.on_hover_text(crate::i18n::fmt(tl!("Align {what}"), &[("what", tl!(&label))])).clicked() {
run.push((id, json!({})));
}
}
diff --git a/crates/ui-egui/src/layer_row_ui.rs b/crates/ui-egui/src/layer_row_ui.rs
index cdd9462ae..d30f366e6 100644
--- a/crates/ui-egui/src/layer_row_ui.rs
+++ b/crates/ui-egui/src/layer_row_ui.rs
@@ -119,7 +119,7 @@ pub fn indicators(
let has_fx = !l.effects.items.is_empty();
let show_blend = l.blend != BlendMode::Normal && l.blend != BlendMode::PassThrough;
let fx_galley = has_fx.then(|| painter.layout_no_wrap("fx".into(), fx_font, t.text_dim));
- let blend_galley = show_blend.then(|| painter.layout_no_wrap(l.blend.label().into(), blend_font, t.text_faint));
+ let blend_galley = show_blend.then(|| painter.layout_no_wrap(tl!(l.blend.label()).into(), blend_font, t.text_faint));
let mut items = Vec::new();
if locked {
items.push((Indicator::Lock, ICON_W));
@@ -159,12 +159,13 @@ pub fn indicators(
let all = ui.input(|i| i.modifiers.alt);
actions.push(("layer.setEffectsExpanded".into(), json!({"layer": l.id.0, "expanded": !fx_open, "all": all})));
}
- let (verb, name) = (if fx_open { "Collapse" } else { "Expand" }, l.name.clone());
- let resp = resp.on_hover_text(format!(
- "{} the layer's effects ({}-click: all layers)",
- if fx_open { "Hide" } else { "Show" },
- crate::shortcuts::pretty("Alt")
- ));
+ let (verb, name) = (if fx_open { tl!("Collapse") } else { tl!("Expand") }, l.name.clone());
+ let tip = if fx_open {
+ tl!("Hide the layer's effects ({key}-click: all layers)")
+ } else {
+ tl!("Show the layer's effects ({key}-click: all layers)")
+ };
+ let resp = resp.on_hover_text(crate::i18n::fmt(tip, &[("key", &crate::shortcuts::pretty("Alt"))]));
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, format!("{verb} effects {name}")));
}
}
@@ -195,7 +196,7 @@ pub fn label(painter: &Painter, x: f32, cy: f32, right: f32, text: &str, font: F
/// The Layers panel's own items at the top of its panel menu (Photoshop's flyout).
pub fn panel_menu(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui) {
let can = app.session.is_enabled("layer.setExpanded");
- if ui.add_enabled(can, egui::Button::new("Collapse All Groups")).clicked() {
+ if ui.add_enabled(can, egui::Button::new(tl!("Collapse All Groups"))).clicked() {
if let Err(e) = app.run("layer.setExpanded", json!({"all": true, "expanded": false})) {
app.ui.status = e;
app.ui.status_error = true;
diff --git a/crates/ui-egui/src/layer_style.rs b/crates/ui-egui/src/layer_style.rs
index cd1c61cd2..1974c9d4c 100644
--- a/crates/ui-egui/src/layer_style.rs
+++ b/crates/ui-egui/src/layer_style.rs
@@ -352,10 +352,11 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
// Left: effect list.
ui.vertical(|ui| {
ui.set_width(190.0);
- ui.label(RichText::new("Styles").color(t.text_faint));
+ ui.label(RichText::new(tl!("Styles")).color(t.text_faint));
// Blending Options page (layer blend mode, opacity and fill opacity).
- let bo =
- ui.add(egui::Label::new(RichText::new("Blending Options").color(if selected == BLENDING { t.text } else { t.text_dim })).sense(Sense::click()));
+ let bo = ui.add(
+ egui::Label::new(RichText::new(tl!("Blending Options")).color(if selected == BLENDING { t.text } else { t.text_dim })).sense(Sense::click()),
+ );
if bo.clicked() {
f.insert("selected".into(), json!(BLENDING));
}
@@ -382,7 +383,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.painter().text(
rect.left_center() + vec2(28.0, 0.0),
egui::Align2::LEFT_CENTER,
- label,
+ tl!(label),
egui::FontId::proportional(12.5),
if on || is_sel { t.text } else { t.text_dim },
);
@@ -401,7 +402,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.vertical(|ui| {
ui.set_width(330.0);
let label = KINDS.iter().find(|k| k.0 == selected).map(|k| k.1).unwrap_or(if selected == BLENDING { "Blending Options" } else { "" });
- ui.label(RichText::new(label).font(crate::theme::semibold(14.0)).color(t.text));
+ ui.label(RichText::new(tl!(&label)).font(crate::theme::semibold(14.0)).color(t.text));
ui.add_space(6.0);
let pkey = format!("p:{selected}");
let mut p = f.get(&pkey).cloned().unwrap_or_else(|| defaults(&selected));
@@ -415,7 +416,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
P::Color => {
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let hexs = p.get(key).and_then(Value::as_str).unwrap_or("#000000").to_string();
let mut c = parse_hex(&hexs);
if ui.color_edit_button_srgba(&mut c).changed() {
@@ -425,7 +426,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
P::Blend => {
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let mut cur = p.get(key).and_then(Value::as_str).unwrap_or("Normal").to_string();
let opts: Vec<(String, &str)> =
photocraft_color::BlendMode::LAYER_MODES.iter().map(|m| (m.label().to_string(), m.label())).collect();
@@ -436,7 +437,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
P::Choice(options) => {
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let mut cur = p.get(key).and_then(Value::as_str).unwrap_or(options[0].0).to_string();
let opts: Vec<(String, &str)> = options.iter().map(|(v, l)| (v.to_string(), *l)).collect();
if widgets::dropdown(ui, &format!("fx-{selected}-{key}"), &mut cur, &opts, 150.0) {
@@ -451,7 +452,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
.map(|a| a.iter().filter_map(|e| Some((e.get(0)?.as_str()?.to_string(), e.get(1)?.as_str()?.to_string()))).collect())
.unwrap_or_default();
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let mut cur = p
.get(key)
.and_then(Value::as_str)
diff --git a/crates/ui-egui/src/layer_tree_ui.rs b/crates/ui-egui/src/layer_tree_ui.rs
index 024b4949f..e85021797 100644
--- a/crates/ui-egui/src/layer_tree_ui.rs
+++ b/crates/ui-egui/src/layer_tree_ui.rs
@@ -61,8 +61,9 @@ pub fn disclosure(ui: &mut egui::Ui, row: Rect, x: &mut f32, l: &Layer, actions:
let all = ui.input(|i| i.modifiers.alt);
actions.push(("layer.setExpanded".into(), json!({"layer": l.id.0, "expanded": !g.expanded, "all": all})));
}
- let (verb, name) = (if g.expanded { "Collapse" } else { "Expand" }, l.name.clone());
- let resp = resp.on_hover_text(format!("{} group ({}-click: all groups)", if g.expanded { "Collapse" } else { "Expand" }, crate::shortcuts::pretty("Alt")));
+ let (verb, name) = (if g.expanded { tl!("Collapse") } else { tl!("Expand") }, l.name.clone());
+ let tip = if g.expanded { tl!("Collapse group ({key}-click: all groups)") } else { tl!("Expand group ({key}-click: all groups)") };
+ let resp = resp.on_hover_text(crate::i18n::fmt(tip, &[("key", &crate::shortcuts::pretty("Alt"))]));
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, format!("{verb} group {name}")));
clicked
}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index bddadde63..52e50eb52 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -7,6 +7,13 @@
#![forbid(unsafe_code)]
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
+/// Translate a string literal into the current UI language: `tl!("Image Size…")`.
+macro_rules! tl {
+ ($s:expr) => {
+ $crate::i18n::t($s)
+ };
+}
+
pub mod actions;
pub mod adjust_dialog;
pub mod adjust_editors;
@@ -47,6 +54,7 @@ pub mod gpu_canvas;
pub mod gpu_status;
pub mod gradient_ui;
pub mod hold_keys;
+pub mod i18n;
mod icon_data;
pub mod icons;
pub mod layer_menu_ui;
@@ -751,6 +759,7 @@ impl PhotocraftApp {
impl eframe::App for PhotocraftApp {
fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
+ i18n::set_current(i18n::Lang::from_pref(&self.session.prefs().interface.language));
if !self.styled {
Self::setup_context(ctx, self.ui.theme);
self.styled = true;
diff --git a/crates/ui-egui/src/liquify_ui.rs b/crates/ui-egui/src/liquify_ui.rs
index 1a791e343..73f6598d6 100644
--- a/crates/ui-egui/src/liquify_ui.rs
+++ b/crates/ui-egui/src/liquify_ui.rs
@@ -294,7 +294,7 @@ pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result<Value, String> {
app.distort.liquify = None;
return Ok(json!({"cancelled": true}));
}
- let d = app.distort.liquify.as_mut().ok_or("Liquify is not open")?;
+ let d = app.distort.liquify.as_mut().ok_or(tl!("Liquify is not open"))?;
if let Some(t) = ui.get("tool") {
d.opts.tool = serde_json::from_value(t.clone()).map_err(|e| format!("bad tool: {e}"))?;
}
@@ -470,7 +470,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut strip = ui.new_child(egui::UiBuilder::new().max_rect(left.shrink2(vec2(6.0, 8.0))));
strip.spacing_mut().item_spacing.y = 4.0;
for tool in LiquifyTool::ALL {
- let tip = format!("{} ({})", tool.label(), shortcut(tool));
+ let tip = format!("{} ({})", tl!(tool.label()), shortcut(tool));
if crate::icons::button(&mut strip, tool_icon(tool), 34.0, d.opts.tool == tool, &tip).clicked() {
d.opts.tool = tool;
}
@@ -485,47 +485,47 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut props = ui.new_child(egui::UiBuilder::new().max_rect(right.shrink2(vec2(14.0, 12.0))));
egui::ScrollArea::vertical().id_salt("liquify-props").show(&mut props, |ui| {
ui.spacing_mut().item_spacing.y = 6.0;
- widgets::section_label(ui, "Brush Tool Options");
- widgets::slider_row(ui, "Size", &mut d.opts.size, 1.0..=3000.0, "", None);
- widgets::slider_row(ui, "Density", &mut d.opts.density, 0.0..=100.0, "", None);
- widgets::slider_row(ui, "Pressure", &mut d.opts.pressure, 0.0..=100.0, "", None);
- widgets::slider_row(ui, "Rate", &mut d.opts.rate, 0.0..=100.0, "", None);
+ widgets::section_label(ui, tl!("Brush Tool Options"));
+ widgets::slider_row(ui, tl!("Size"), &mut d.opts.size, 1.0..=3000.0, "", None);
+ widgets::slider_row(ui, tl!("Density"), &mut d.opts.density, 0.0..=100.0, "", None);
+ widgets::slider_row(ui, tl!("Pressure"), &mut d.opts.pressure, 0.0..=100.0, "", None);
+ widgets::slider_row(ui, tl!("Rate"), &mut d.opts.rate, 0.0..=100.0, "", None);
widgets::hairline(ui);
- widgets::section_label(ui, "Brush Reconstruct Options");
- widgets::slider_row(ui, "Amount", &mut d.opts.reconstruct_amount, 0.0..=100.0, "%", None);
+ widgets::section_label(ui, tl!("Brush Reconstruct Options"));
+ widgets::slider_row(ui, tl!("Amount"), &mut d.opts.reconstruct_amount, 0.0..=100.0, "%", None);
ui.horizontal(|ui| {
- if widgets::secondary_button(ui, "Reconstruct", 110.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Reconstruct"), 110.0).clicked() {
let a = f64::from(d.opts.reconstruct_amount);
d.global(LiquifyTool::ReconstructAll, Some(a));
}
- if widgets::secondary_button(ui, "Restore All", 110.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Restore All"), 110.0).clicked() {
d.restore_all();
}
});
widgets::hairline(ui);
- widgets::section_label(ui, "Mask Options");
+ widgets::section_label(ui, tl!("Mask Options"));
ui.horizontal(|ui| {
- if widgets::secondary_button(ui, "None", 70.0).clicked() {
+ if widgets::secondary_button(ui, tl!("None"), 70.0).clicked() {
d.global(LiquifyTool::ThawAll, None);
}
- if widgets::secondary_button(ui, "Mask All", 80.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Mask All"), 80.0).clicked() {
d.global(LiquifyTool::FreezeAll, None);
}
- if widgets::secondary_button(ui, "Invert All", 80.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Invert All"), 80.0).clicked() {
d.global(LiquifyTool::InvertFreeze, None);
}
});
widgets::hairline(ui);
- widgets::section_label(ui, "View Options");
- widgets::checkbox(ui, &mut d.opts.show_mesh, "Show Mesh");
+ widgets::section_label(ui, tl!("View Options"));
+ widgets::checkbox(ui, &mut d.opts.show_mesh, tl!("Show Mesh"));
ui.horizontal(|ui| {
- ui.label("Mesh Size");
- widgets::dropdown(ui, "liquify-mesh-size", &mut d.opts.mesh_size, &[(0, "Small"), (1, "Medium"), (2, "Large")], 110.0);
+ ui.label(tl!("Mesh Size"));
+ widgets::dropdown(ui, "liquify-mesh-size", &mut d.opts.mesh_size, &[(0, tl!("Small")), (1, tl!("Medium")), (2, tl!("Large"))], 110.0);
});
- widgets::checkbox(ui, &mut d.opts.show_mask, "Show Mask");
- widgets::checkbox(ui, &mut d.opts.show_backdrop, "Show Backdrop");
+ widgets::checkbox(ui, &mut d.opts.show_mask, tl!("Show Mask"));
+ widgets::checkbox(ui, &mut d.opts.show_backdrop, tl!("Show Backdrop"));
if d.opts.show_backdrop {
- widgets::slider_row(ui, "Opacity", &mut d.opts.backdrop_opacity, 0.0..=100.0, "", None);
+ widgets::slider_row(ui, tl!("Opacity"), &mut d.opts.backdrop_opacity, 0.0..=100.0, "", None);
}
widgets::hairline(ui);
ui.label(
@@ -537,10 +537,10 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
// Footer buttons.
let foot = ERect::from_min_size(pos2(right.left() + 14.0, right.bottom() - 48.0), vec2(RIGHT_W - 28.0, 32.0));
let mut fb = ui.new_child(egui::UiBuilder::new().max_rect(foot).layout(egui::Layout::right_to_left(egui::Align::Center)));
- if widgets::primary_button(&mut fb, "OK", 84.0).clicked() {
+ if widgets::primary_button(&mut fb, tl!("OK"), 84.0).clicked() {
action = Some("ok");
}
- if widgets::secondary_button(&mut fb, "Cancel", 84.0).clicked() {
+ if widgets::secondary_button(&mut fb, tl!("Cancel"), 84.0).clicked() {
action = Some("cancel");
}
// Preview.
diff --git a/crates/ui-egui/src/mask_thumbs_ui.rs b/crates/ui-egui/src/mask_thumbs_ui.rs
index e97bf05a7..6755ba5a5 100644
--- a/crates/ui-egui/src/mask_thumbs_ui.rs
+++ b/crates/ui-egui/src/mask_thumbs_ui.rs
@@ -118,7 +118,7 @@ pub fn paint(
paint_chain(painter, chain.center(), t.text_faint);
}
let (verb, what, name) = (if linked { "Unlink" } else { "Link" }, kind.label(), l.name.clone());
- let resp = resp.on_hover_text(if linked { "Unlink the mask from the layer" } else { "Link the mask to the layer" });
+ let resp = resp.on_hover_text(if linked { tl!("Unlink the mask from the layer") } else { tl!("Link the mask to the layer") });
resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, format!("{verb} {what} {name}")));
if resp.clicked() {
out.clicked = true;
diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs
index e03c61d87..c18f083f0 100644
--- a/crates/ui-egui/src/menus.rs
+++ b/crates/ui-egui/src/menus.rs
@@ -708,6 +708,7 @@ pub fn menu_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> f32 {
let items: std::cell::OnceCell<Vec<MenuItem>> = std::cell::OnceCell::new();
let app_ref: &PhotocraftApp = app;
let mut right = ui.cursor().left();
+ let lang = crate::i18n::current();
let mut clicked: Option<String> = None;
let t = crate::theme::Tokens::get(ui.ctx());
let mut nav = crate::menu_nav::Nav::load(ui.ctx());
@@ -723,12 +724,12 @@ pub fn menu_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) -> f32 {
nav.bar_bottom = Some(ui.max_rect().bottom());
let mut buttons = Vec::with_capacity(TOP_MENUS.len());
for top in TOP_MENUS {
- let r = ui.menu_button(egui::RichText::new(top).color(t.text_dim), |ui| {
+ let r = ui.menu_button(egui::RichText::new(crate::i18n::tr(lang, top)).color(t.text_dim), |ui| {
let items = items.get_or_init(|| menu_items(app_ref));
let mine: Vec<&MenuItem> = items.iter().filter(|i| i.path.first().map(String::as_str) == Some(top)).collect();
ui.set_min_width(220.0);
if mine.is_empty() {
- ui.weak("(coming soon)");
+ ui.weak(crate::i18n::tr(lang, "(coming soon)"));
}
render_level(ui, &mine, 1, &mut clicked, &mut nav);
});
@@ -783,6 +784,10 @@ fn render_level(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, clicked: &
fn render_level_rows(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, clicked: &mut Option<String>, nav: &mut crate::menu_nav::Nav) {
let t = crate::theme::Tokens::get(ui.ctx());
+ let lang = crate::i18n::current();
+ // Items never wrap: the menu widens to its longest label plus shortcut (translations can be
+ // longer than the English).
+ ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend);
if t.pro {
// Spectrum/macOS menus: blue highlight row with white text.
let v = &mut ui.style_mut().visuals;
@@ -805,7 +810,7 @@ fn render_level_rows(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, click
}
continue;
}
- let mut text = it.label.clone();
+ let mut text = crate::i18n::tr_id(lang, &it.id, &it.label).to_string();
if let Some(c) = it.checked {
text = format!("{} {}", if c { "✔" } else { " " }, text);
}
@@ -836,7 +841,9 @@ fn render_level_rows(ui: &mut egui::Ui, items: &[&MenuItem], depth: usize, click
let any_enabled = child.iter().any(|c| c.enabled && c.label != "---");
let enabled = any_enabled || !child.is_empty();
ui.add_enabled_ui(enabled, |ui| {
- nav.row(ui, depth - 1, enabled, None, |ui, nav| (ui.menu_button(name, |ui| render_level(ui, &child, depth + 1, clicked, nav)).response, ()));
+ nav.row(ui, depth - 1, enabled, None, |ui, nav| {
+ (ui.menu_button(crate::i18n::tr(lang, name), |ui| render_level(ui, &child, depth + 1, clicked, nav)).response, ())
+ });
});
last_was_sep = false;
}
diff --git a/crates/ui-egui/src/new_doc_ui.rs b/crates/ui-egui/src/new_doc_ui.rs
index 8dc5af950..a2cf04978 100644
--- a/crates/ui-egui/src/new_doc_ui.rs
+++ b/crates/ui-egui/src/new_doc_ui.rs
@@ -142,7 +142,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.spacing_mut().item_spacing.x = 18.0;
for (name, _) in CATEGORIES {
let on = cat == *name;
- let r = ui.add(egui::Label::new(RichText::new(*name).size(13.0).color(if on { t.text } else { t.text_dim })).sense(Sense::click()));
+ let r = ui.add(egui::Label::new(RichText::new(tl!(name)).size(13.0).color(if on { t.text } else { t.text_dim })).sense(Sense::click()));
if on {
ui.painter().line_segment([r.rect.left_bottom() + vec2(0.0, 3.0), r.rect.right_bottom() + vec2(0.0, 3.0)], Stroke::new(2.0, t.text));
}
@@ -160,7 +160,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
// Left: preset grid.
ui.vertical(|ui| {
ui.set_width(520.0);
- ui.label(RichText::new(format!("BLANK DOCUMENT PRESETS ({})", presets.len())).size(11.0).color(t.text_faint));
+ ui.label(RichText::new(crate::i18n::fmt(tl!("BLANK DOCUMENT PRESETS ({n})"), &[("n", &presets.len().to_string())])).size(11.0).color(t.text_faint));
ui.add_space(6.0);
let card = vec2(164.0, 112.0);
for row in presets.chunks(3) {
@@ -184,7 +184,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.painter().rect_stroke(r, t.radius, Stroke::new(1.5, t.accent), StrokeKind::Inside);
}
page_icon(ui, Rect::from_center_size(pos2(r.center().x, r.top() + 34.0), vec2(40.0, 40.0)), p.1, p.2, &t);
- ui.painter().text(pos2(r.center().x, r.top() + 72.0), Align2::CENTER_CENTER, p.0, egui::FontId::proportional(12.0), t.text);
+ ui.painter().text(pos2(r.center().x, r.top() + 72.0), Align2::CENTER_CENTER, tl!(p.0), egui::FontId::proportional(12.0), t.text);
let unit = if p.3 >= 300.0 { "in" } else { "px" };
let size = if unit == "in" {
format!(
@@ -209,16 +209,16 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
// Right: Preset Details.
ui.vertical(|ui| {
ui.set_width(260.0);
- ui.label(RichText::new("PRESET DETAILS").size(11.0).color(t.text_faint));
+ ui.label(RichText::new(tl!("PRESET DETAILS")).size(11.0).color(t.text_faint));
ui.add_space(4.0);
- let mut name = get_s(f, "name", "Untitled-1");
+ let mut name = get_s(f, "name", tl!("Untitled-1"));
if ui.add(egui::TextEdit::singleline(&mut name).desired_width(250.0).font(egui::FontId::proportional(15.0))).changed() {
f.insert("name".into(), json!(name));
}
ui.add_space(8.0);
let ppi = get_f(f, "resolution", 72.0);
let mut unit = get_s(f, "__unit", "px");
- small_label(ui, "Width");
+ small_label(ui, tl!("Width"));
ui.horizontal(|ui| {
let mut w = to_unit(get_f(f, "width", 1920.0), &unit, ppi);
if widgets::value_field(ui, &mut w, 0.01..=300_000.0, "", 110.0).changed() {
@@ -230,7 +230,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
f.insert("__unit".into(), json!(unit));
}
});
- small_label(ui, "Height");
+ small_label(ui, tl!("Height"));
ui.horizontal(|ui| {
let mut h = to_unit(get_f(f, "height", 1080.0), &unit, ppi);
if widgets::value_field(ui, &mut h, 0.01..=300_000.0, "", 110.0).changed() {
@@ -238,7 +238,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
f.remove("__preset");
}
ui.add_space(6.0);
- small_label(ui, "Orientation");
+ small_label(ui, tl!("Orientation"));
let (w, h) = (get_f(f, "width", 1920.0), get_f(f, "height", 1080.0));
for (icon, portrait) in [("rectangle-vertical", true), ("rectangle-horizontal", false)] {
if icons::button(ui, icon, 24.0, (h > w) == portrait, if portrait { "Portrait" } else { "Landscape" }).clicked() && (h > w) != portrait {
@@ -248,7 +248,7 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
});
ui.add_space(4.0);
- small_label(ui, "Resolution");
+ small_label(ui, tl!("Resolution"));
ui.horizontal(|ui| {
let per_cm = get_s(f, "__resUnit", "in") == "cm";
let mut r = if per_cm { ppi / 2.54 } else { ppi };
@@ -256,12 +256,13 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
f.insert("resolution".into(), json!(if per_cm { r * 2.54 } else { r }));
}
let mut ru = get_s(f, "__resUnit", "in");
- if widgets::dropdown(ui, "nd-resunit", &mut ru, &[("in".to_string(), "Pixels/Inch"), ("cm".to_string(), "Pixels/Centimeter")], 120.0) {
+ if widgets::dropdown(ui, "nd-resunit", &mut ru, &[("in".to_string(), tl!("Pixels/Inch")), ("cm".to_string(), tl!("Pixels/Centimeter"))], 120.0)
+ {
f.insert("__resUnit".into(), json!(ru));
}
});
ui.add_space(4.0);
- small_label(ui, "Color Mode");
+ small_label(ui, tl!("Color Mode"));
ui.horizontal(|ui| {
let mut mode = get_s(f, "mode", "rgb");
if widgets::dropdown(
@@ -269,10 +270,10 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
"nd-mode",
&mut mode,
&[
- ("gray".to_string(), "Grayscale"),
- ("rgb".to_string(), "RGB Color"),
- ("cmyk".to_string(), "CMYK Color"),
- ("lab".to_string(), "Lab Color"),
+ ("gray".to_string(), tl!("Grayscale")),
+ ("rgb".to_string(), tl!("RGB Color")),
+ ("cmyk".to_string(), tl!("CMYK Color")),
+ ("lab".to_string(), tl!("Lab Color")),
],
110.0,
) {
@@ -284,13 +285,13 @@ pub fn body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
});
ui.add_space(4.0);
- small_label(ui, "Background Contents");
+ small_label(ui, tl!("Background Contents"));
let mut bg = get_s(f, "background", "white");
let opts = [
- ("white".to_string(), "White"),
- ("black".to_string(), "Black"),
- ("backgroundColor".to_string(), "Background Color"),
- ("transparent".to_string(), "Transparent"),
+ ("white".to_string(), tl!("White")),
+ ("black".to_string(), tl!("Black")),
+ ("backgroundColor".to_string(), tl!("Background Color")),
+ ("transparent".to_string(), tl!("Transparent")),
];
if widgets::dropdown(ui, "nd-bg", &mut bg, &opts, 240.0) {
f.insert("background".into(), json!(bg));
diff --git a/crates/ui-egui/src/notices.rs b/crates/ui-egui/src/notices.rs
index 2cc607d8a..fad5068cf 100644
--- a/crates/ui-egui/src/notices.rs
+++ b/crates/ui-egui/src/notices.rs
@@ -78,7 +78,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let title = egui::RichText::new(&n.title).strong().color(if n.error { t.warning } else { t.text });
ui.add(egui::Label::new(title).wrap());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| {
- if ui.add(egui::Button::new(egui::RichText::new("×").color(t.text_dim)).frame(false)).on_hover_text("Dismiss").clicked() {
+ if ui.add(egui::Button::new(egui::RichText::new("×").color(t.text_dim)).frame(false)).on_hover_text(tl!("Dismiss")).clicked() {
dismiss = Some(n.id);
}
});
diff --git a/crates/ui-egui/src/palette.rs b/crates/ui-egui/src/palette.rs
index 8b5b0521e..06571fad9 100644
--- a/crates/ui-egui/src/palette.rs
+++ b/crates/ui-egui/src/palette.rs
@@ -71,7 +71,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let (r, _) = ui.allocate_exact_size(vec2(22.0, 22.0), Sense::hover());
icons::paint(ui, r, "search", 16.0, t.text_dim);
let te = egui::TextEdit::singleline(&mut q)
- .hint_text("Search commands, tools and panels…")
+ .hint_text(tl!("Search commands, tools and panels…"))
.frame(egui::Frame::NONE)
.font(egui::FontId::proportional(15.0))
.desired_width(width - 40.0);
@@ -81,23 +81,27 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.add_space(6.0);
crate::widgets::hairline(ui);
ui.add_space(6.0);
+ let lang = crate::i18n::Lang::from_pref(&app.session.prefs().interface.language);
let mut hits: Vec<(i32, String, String, Option<String>, bool)> = crate::menus::menu_items(app)
.into_iter()
.filter_map(|m| {
- let path = m.path.join(" › ");
- let s = fuzzy_score(&q, &format!("{} {}", m.label, path))?;
+ let path_en = m.path.join(" › ");
+ let path = m.path.iter().map(|p| crate::i18n::tr(lang, p)).collect::<Vec<_>>().join(" › ");
+ let label = crate::i18n::tr_id(lang, &m.id, &m.label);
+ // Match what is shown and the English name (commands are documented in English).
+ let s = fuzzy_score(&q, &format!("{label} {path} {} {path_en}", m.label))?;
Some((
s,
m.id,
- m.label.trim_end_matches('…').to_string(),
+ label.trim_end_matches('…').to_string(),
Some(path + &m.shortcut.map(|s| format!(" {}", crate::shortcuts::pretty(&s))).unwrap_or_default()),
m.enabled,
))
})
.collect();
for tool in crate::state::Tool::ALL {
- if let Some(s) = fuzzy_score(&q, tool.label()) {
- hits.push((s + 2, format!("tool:{tool:?}"), tool.label().into(), Some(format!("Tool {}", tool.key())), true));
+ if let Some(s) = fuzzy_score(&q, &format!("{} {}", tl!(tool.label()), tool.label())) {
+ hits.push((s + 2, format!("tool:{tool:?}"), tl!(tool.label()).into(), Some(format!("Tool {}", tool.key())), true));
}
}
hits.sort_by(|a, b| b.0.cmp(&a.0).then(a.2.cmp(&b.2)));
@@ -120,7 +124,7 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
sel = sel.min(hits.len().saturating_sub(1));
if hits.is_empty() {
- ui.label(RichText::new("No matching commands").color(t.text_faint));
+ ui.label(RichText::new(tl!("No matching commands")).color(t.text_faint));
}
for (i, (_, id, label, detail, enabled)) in hits.iter().enumerate() {
let (rect, resp) = ui.allocate_exact_size(vec2(width, 32.0), Sense::click());
@@ -143,7 +147,11 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
app.ui.palette_open = false;
}
ui.add_space(4.0);
- ui.label(RichText::new(format!("↑↓ navigate {} run esc close", crate::shortcuts::pretty("Enter"))).small().color(t.text_faint));
+ ui.label(
+ RichText::new(crate::i18n::fmt(tl!("↑↓ navigate {key} run esc close"), &[("key", &crate::shortcuts::pretty("Enter"))]))
+ .small()
+ .color(t.text_faint),
+ );
ui.data_mut(|d| {
d.insert_temp(qid, q);
d.insert_temp(sel_id, sel);
diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs
index 8df71d500..af6b0f718 100644
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@ -103,7 +103,7 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
slot_index += 1;
let tool = slot_tool(ui, app.ui.tool, slot, key);
let sel = slot.contains(&app.ui.tool);
- let tip = if tool.key() == '\0' { tool.label().to_string() } else { format!("{} ({})", tool.label(), tool.key()) };
+ let tip = if tool.key() == '\0' { tl!(tool.label()).to_string() } else { format!("{} ({})", tl!(tool.label()), tool.key()) };
let resp = icons::button(ui, icons::tool_icon(tool), bx, sel, &tip);
if slot.len() > 1 {
let r = resp.rect;
@@ -189,7 +189,7 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
let ctx = ui.ctx().clone();
- if t.pro && icons::button(ui, "ellipsis", bx, false, "Edit Toolbar…").clicked() {
+ if t.pro && icons::button(ui, "ellipsis", bx, false, tl!("Edit Toolbar…")).clicked() {
let _ = crate::menus::invoke(app, &ctx, "edit.toolbar", json!({}));
}
ui.add_space(if t.pro { 8.0 } else { 14.0 });
@@ -197,12 +197,18 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if t.pro {
ui.add_space(8.0);
let quick_mask = app.session.active().is_some_and(|s| s.doc.quick_mask.is_some());
- if icons::button(ui, "square-dashed", bx, quick_mask, if quick_mask { "Edit in Standard Mode (Q)" } else { "Edit in Quick Mask Mode (Q)" })
- .clicked()
+ if icons::button(
+ ui,
+ "square-dashed",
+ bx,
+ quick_mask,
+ if quick_mask { tl!("Edit in Standard Mode (Q)") } else { tl!("Edit in Quick Mask Mode (Q)") },
+ )
+ .clicked()
{
let _ = crate::menus::invoke(app, &ctx, "select.editInQuickMaskMode", json!({}));
}
- let sm = icons::button(ui, "app-window", bx, false, "Change Screen Mode (F)");
+ let sm = icons::button(ui, "app-window", bx, false, tl!("Change Screen Mode (F)"));
if sm.clicked() {
let _ = crate::menus::invoke(app, &ctx, "view.screenMode.cycle", json!({}));
}
@@ -210,9 +216,9 @@ pub fn toolbar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
egui::Popup::context_menu(&sm).show(|ui| {
ui.set_min_width(220.0);
for (id, label) in [
- ("view.screenMode.standard", "Standard Screen Mode"),
- ("view.screenMode.fullScreenWithMenuBar", "Full Screen Mode With Menu Bar"),
- ("view.screenMode.fullScreen", "Full Screen Mode"),
+ ("view.screenMode.standard", tl!("Standard Screen Mode")),
+ ("view.screenMode.fullScreenWithMenuBar", tl!("Full Screen Mode With Menu Bar")),
+ ("view.screenMode.fullScreen", tl!("Full Screen Mode")),
] {
let on = crate::view_cmds::checked(app, id).unwrap_or(false);
if ui.add(egui::Button::selectable(on, label)).clicked() {
@@ -257,17 +263,17 @@ fn color_chips(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Photoshop: clicking a chip opens the Color Picker for that colour.
let bg_resp = ui.interact(bg, ui.id().with("bgchip"), Sense::click());
let fg_resp = ui.interact(fg, ui.id().with("fgchip"), Sense::click());
- if fg_resp.on_hover_text("Set foreground color").clicked() {
+ if fg_resp.on_hover_text(tl!("Set foreground color")).clicked() {
crate::color_picker_ui::open(app, "foreground");
- } else if bg_resp.on_hover_text("Set background color").clicked() {
+ } else if bg_resp.on_hover_text(tl!("Set background color")).clicked() {
crate::color_picker_ui::open(app, "background");
}
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
- if icons::button(ui, "arrow-left-right", 18.0, false, "Swap colours (X)").clicked() {
+ if icons::button(ui, "arrow-left-right", 18.0, false, tl!("Swap colours (X)")).clicked() {
let _ = app.run("tools.swapColors", json!({}));
}
- if icons::button(ui, "contrast", 18.0, false, "Default colours (D)").clicked() {
+ if icons::button(ui, "contrast", 18.0, false, tl!("Default colours (D)")).clicked() {
let _ = app.run("tools.defaultColors", json!({}));
}
});
@@ -302,10 +308,12 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.x = 6.0;
let mut ws = app.ui.workspace.clone();
let opts = [
- ("Essentials".to_string(), "Essentials"),
- ("Photography".to_string(), "Photography"),
- ("Painting".to_string(), "Painting"),
- ("Graphic and Web".to_string(), "Graphic and Web"),
+ // Keys stay English (`apply_workspace` matches them); the dropdown
+ // shows the labels in the UI language.
+ ("Essentials".to_string(), tl!("Essentials")),
+ ("Photography".to_string(), tl!("Photography")),
+ ("Painting".to_string(), tl!("Painting")),
+ ("Graphic and Web".to_string(), tl!("Graphic and Web")),
];
if widgets::dropdown(ui, "workspace", &mut ws, &opts, 130.0) {
app.ui.workspace = ws;
@@ -316,14 +324,14 @@ pub fn title_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
app.ui.palette_open = !app.ui.palette_open;
}
let theme_icon = if t.dark() { "sun" } else { "moon" };
- if icons::button(ui, theme_icon, 28.0, false, "Switch theme").clicked() {
+ if icons::button(ui, theme_icon, 28.0, false, tl!("Switch theme")).clicked() {
let next = app.ui.theme.next();
app.set_theme(ui.ctx(), next);
}
// Always one click away: the community Discord.
let discord = egui::Button::image_and_text(
icons::image("message-square", 14.0, t.text_dim),
- egui::RichText::new("Discord").color(t.text_dim).size(12.0),
+ egui::RichText::new(tl!("Discord")).color(t.text_dim).size(12.0),
)
.frame(false);
if ui.add(discord).on_hover_text(format!("Join the ArtCraft Discord ({})", crate::links::DISCORD)).clicked() {
@@ -442,70 +450,73 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
picked = brush_preset_chip(ui, b, &app.session.tools.presets);
crate::brush_picker::settings_toggle(app, ui);
widgets::vline(ui, 22.0);
- opt_label(ui, "Mode");
+ opt_label(ui, tl!("Mode"));
let mut mode = b.mode;
let opts: Vec<(BlendMode, &str)> = BlendMode::LAYER_MODES.iter().map(|m| (*m, m.label())).collect();
if widgets::dropdown(ui, "brush-mode", &mut mode, &opts, 96.0) {
b.mode = mode;
}
- opt_label(ui, "Opacity");
+ opt_label(ui, tl!("Opacity"));
let mut o = b.opacity * 100.0;
if widgets::value_field(ui, &mut o, 0.0..=100.0, "%", 62.0).changed() {
b.opacity = o / 100.0;
}
- if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, "Always use pressure for opacity").clicked() {
+ if icons::button(ui, "circle-dot", 24.0, b.pressure_opacity, tl!("Always use pressure for opacity")).clicked() {
b.pressure_opacity = !b.pressure_opacity;
}
- opt_label(ui, "Flow");
+ opt_label(ui, tl!("Flow"));
let mut f = b.flow * 100.0;
if widgets::value_field(ui, &mut f, 1.0..=100.0, "%", 62.0).changed() {
b.flow = f / 100.0;
}
- let _ = icons::button(ui, "sparkles", 24.0, false, "Enable airbrush-style build-up effects");
- opt_label(ui, "Smoothing");
+ let _ = icons::button(ui, "sparkles", 24.0, false, tl!("Enable airbrush-style build-up effects"));
+ opt_label(ui, tl!("Smoothing"));
smoothing_field(ui, b, 58.0);
- let _ = icons::button(ui, "settings", 24.0, false, "Set additional smoothing options");
+ let _ = icons::button(ui, "settings", 24.0, false, tl!("Set additional smoothing options"));
widgets::vline(ui, 22.0);
- if icons::button(ui, "circle-dot", 24.0, b.pressure_size, "Always use pressure for size").clicked() {
+ if icons::button(ui, "circle-dot", 24.0, b.pressure_size, tl!("Always use pressure for size")).clicked() {
b.pressure_size = !b.pressure_size;
}
- let _ = icons::button(ui, "arrow-left-right", 24.0, false, "Set painting symmetry options");
+ let _ = icons::button(ui, "arrow-left-right", 24.0, false, tl!("Set painting symmetry options"));
}
Tool::Brush | Tool::Eraser => {
picked = brush_preset_chip(ui, b, &app.session.tools.presets);
crate::brush_picker::settings_toggle(app, ui);
widgets::vline(ui, 22.0);
- opt_label(ui, "Size");
+ opt_label(ui, tl!("Size"));
widgets::value_field(ui, &mut b.size, 1.0..=2500.0, "px", 76.0);
widgets::vline(ui, 22.0);
- opt_label(ui, "Hardness");
+ opt_label(ui, tl!("Hardness"));
let mut h = b.hardness * 100.0;
if widgets::value_field(ui, &mut h, 0.0..=100.0, "%", 66.0).changed() {
b.hardness = h / 100.0;
}
- opt_label(ui, "Opacity");
+ opt_label(ui, tl!("Opacity"));
let mut o = b.opacity * 100.0;
if widgets::value_field(ui, &mut o, 0.0..=100.0, "%", 66.0).changed() {
b.opacity = o / 100.0;
}
- opt_label(ui, "Flow");
+ opt_label(ui, tl!("Flow"));
let mut f = b.flow * 100.0;
if widgets::value_field(ui, &mut f, 1.0..=100.0, "%", 66.0).changed() {
b.flow = f / 100.0;
}
- opt_label(ui, "Smoothing");
+ opt_label(ui, tl!("Smoothing"));
smoothing_field(ui, b, 66.0);
widgets::vline(ui, 22.0);
- widgets::toggle(ui, &mut b.pressure_size, "Pressure for Size");
- widgets::toggle(ui, &mut b.pressure_opacity, "Pressure for Opacity");
+ widgets::toggle(ui, &mut b.pressure_size, tl!("Pressure for Size"));
+ widgets::toggle(ui, &mut b.pressure_opacity, tl!("Pressure for Opacity"));
}
Tool::RectMarquee | Tool::EllipseMarquee if t.pro => {
ui.spacing_mut().item_spacing.x = 2.0;
for (i, (icon, tip)) in [
- ("square", "New selection".to_string()),
- ("plus", format!("Add to selection ({})", crate::shortcuts::pretty("Shift"))),
- ("minus", format!("Subtract from selection ({})", crate::shortcuts::pretty("Alt"))),
- ("squares-subtract", format!("Intersect with selection ({})", crate::shortcuts::pretty("Shift+Alt"))),
+ ("square", tl!("New selection").to_string()),
+ ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])),
+ ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])),
+ (
+ "squares-subtract",
+ crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))]),
+ ),
]
.iter()
.enumerate()
@@ -517,75 +528,85 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.x = 8.0;
widgets::vline(ui, 22.0);
let o = &mut app.ui.tool_options;
- opt_label(ui, "Feather");
+ opt_label(ui, tl!("Feather"));
widgets::value_field(ui, &mut o.feather, 0.0..=1000.0, "px", 62.0);
// Photoshop greys Anti-alias for the Rectangular Marquee (its edges are always hard).
ui.add_enabled_ui(app.ui.tool == Tool::EllipseMarquee, |ui| widgets::checkbox(ui, &mut o.anti_alias, "Anti-alias"));
widgets::vline(ui, 22.0);
- opt_label(ui, "Style");
- let styles = [("normal".to_string(), "Normal"), ("fixedRatio".to_string(), "Fixed Ratio"), ("fixedSize".to_string(), "Fixed Size")];
+ opt_label(ui, tl!("Style"));
+ let styles = [
+ ("normal".to_string(), tl!("Normal")),
+ ("fixedRatio".to_string(), tl!("Fixed Ratio")),
+ ("fixedSize".to_string(), tl!("Fixed Size")),
+ ];
if widgets::dropdown(ui, "marquee-style", &mut o.marquee_style, &styles, 96.0) {
(o.marquee_width, o.marquee_height) = if o.marquee_style == "fixedSize" { (64.0, 64.0) } else { (1.0, 1.0) };
}
let fixed = o.marquee_style != "normal";
let (unit, range) = if o.marquee_style == "fixedSize" { ("px", 1.0..=300_000.0) } else { ("", 0.001..=999.0) };
ui.add_enabled_ui(fixed, |ui| {
- opt_label(ui, "Width");
+ opt_label(ui, tl!("Width"));
widgets::value_field(ui, &mut o.marquee_width, range.clone(), unit, 62.0);
- if icons::button(ui, "arrow-left-right", 22.0, false, "Swaps height and width").clicked() {
+ if icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked() {
std::mem::swap(&mut o.marquee_width, &mut o.marquee_height);
}
- opt_label(ui, "Height");
+ opt_label(ui, tl!("Height"));
widgets::value_field(ui, &mut o.marquee_height, range, unit, 62.0);
});
widgets::vline(ui, 22.0);
- if widgets::secondary_button(ui, "Select and Mask…", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() {
let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({}));
}
}
Tool::Lasso | Tool::PolygonLasso if t.pro => {
selection_mode_buttons(app, ui);
widgets::vline(ui, 22.0);
- opt_label(ui, "Feather");
+ opt_label(ui, tl!("Feather"));
widgets::value_field(ui, &mut app.ui.tool_options.feather, 0.0..=1000.0, "px", 62.0);
- widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, "Anti-alias");
+ widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias"));
widgets::vline(ui, 22.0);
- if widgets::secondary_button(ui, "Select and Mask…", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() {
let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({}));
}
if app.ui.tool == Tool::PolygonLasso && !app.ui.polygon.is_empty() {
- hint(ui, &format!("Click the first point or press {} to close · Esc cancels", crate::shortcuts::pretty("Enter")));
+ hint(
+ ui,
+ &crate::i18n::fmt(
+ tl!("Click the first point or press {key} to close · Esc cancels"),
+ &[("key", &crate::shortcuts::pretty("Enter"))],
+ ),
+ );
}
}
Tool::MagicWand => {
selection_mode_buttons(app, ui);
widgets::vline(ui, 22.0);
- opt_label(ui, "Tolerance");
+ opt_label(ui, tl!("Tolerance"));
widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0);
- widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, "Anti-alias");
- widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, "Contiguous");
- widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, "Sample All Layers");
+ widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias"));
+ widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous"));
+ widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("Sample All Layers"));
widgets::vline(ui, 22.0);
- if widgets::secondary_button(ui, "Select Subject", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() {
let _ = app.run("select.subject", json!({}));
}
- if widgets::secondary_button(ui, "Select and Mask…", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Select and Mask…"), 0.0).clicked() {
let _ = crate::menus::invoke(app, ui.ctx(), "select.selectAndMask", json!({}));
}
}
Tool::PaintBucket if t.pro => {
- opt_label(ui, "Fill");
+ opt_label(ui, tl!("Fill"));
let mut src = u8::from(app.ui.tool_options.bucket_fill_pattern);
- if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, "Foreground"), (1, "Pattern")], 100.0) {
+ if widgets::dropdown(ui, "bucket-src", &mut src, &[(0u8, tl!("Foreground")), (1, tl!("Pattern"))], 100.0) {
app.ui.tool_options.bucket_fill_pattern = src == 1;
}
- opt_label(ui, "Opacity");
+ opt_label(ui, tl!("Opacity"));
widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0);
- opt_label(ui, "Tolerance");
+ opt_label(ui, tl!("Tolerance"));
widgets::value_field(ui, &mut app.ui.tool_options.tolerance, 0.0..=255.0, "", 58.0);
- widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, "Anti-alias");
- widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, "Contiguous");
- widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, "All Layers");
+ widgets::checkbox(ui, &mut app.ui.tool_options.anti_alias, tl!("Anti-alias"));
+ widgets::checkbox(ui, &mut app.ui.tool_options.contiguous, tl!("Contiguous"));
+ widgets::checkbox(ui, &mut app.ui.tool_options.sample_all_layers, tl!("All Layers"));
}
Tool::Gradient if t.pro => {
// Live "Gradient" (a Gradient Fill layer) or "Classic gradient" (pixels).
@@ -603,11 +624,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.x = 2.0;
let before = app.ui.tool_options.clone();
for (style, icon, tip) in [
- ("linear", "blend", "Linear Gradient"),
- ("radial", "circle", "Radial Gradient"),
- ("angle", "rotate-cw", "Angle Gradient"),
- ("reflected", "arrow-left-right", "Reflected Gradient"),
- ("diamond", "diamond", "Diamond Gradient"),
+ ("linear", "blend", tl!("Linear Gradient")),
+ ("radial", "circle", tl!("Radial Gradient")),
+ ("angle", "rotate-cw", tl!("Angle Gradient")),
+ ("reflected", "arrow-left-right", tl!("Reflected Gradient")),
+ ("diamond", "diamond", tl!("Diamond Gradient")),
] {
if icons::button(ui, icon, 24.0, app.ui.tool_options.gradient_style == style, tip).clicked() {
app.ui.tool_options.gradient_style = style.into();
@@ -615,10 +636,10 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
ui.spacing_mut().item_spacing.x = 8.0;
widgets::vline(ui, 22.0);
- opt_label(ui, "Opacity");
+ opt_label(ui, tl!("Opacity"));
widgets::value_field(ui, &mut app.ui.tool_options.fill_opacity, 1.0..=100.0, "%", 62.0);
- widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, "Reverse");
- widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, "Dither");
+ widgets::checkbox(ui, &mut app.ui.tool_options.gradient_reverse, tl!("Reverse"));
+ widgets::checkbox(ui, &mut app.ui.tool_options.gradient_dither, tl!("Dither"));
// Live mode: the options also change a selected gradient fill layer.
crate::gradient_ui::options_changed(app, &before);
}
@@ -629,7 +650,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Custom ratio fields (Photoshop shows the preset's numbers here).
let (mut rw, mut rh) = crate::chrome_ui::crop_ratio(&o.crop_ratio, 0.0, 0.0).map_or((0.0, 0.0), |(w, h)| (w as f32, h as f32));
let cw = widgets::value_field(ui, &mut rw, 0.0..=99_999.0, "", 54.0).changed();
- let swap = icons::button(ui, "arrow-left-right", 22.0, false, "Swaps height and width").clicked();
+ let swap = icons::button(ui, "arrow-left-right", 22.0, false, tl!("Swaps height and width")).clicked();
let ch = widgets::value_field(ui, &mut rh, 0.0..=99_999.0, "", 54.0).changed();
if swap {
std::mem::swap(&mut rw, &mut rh);
@@ -638,18 +659,24 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
o.crop_ratio = format!("{}:{}", widgets::fmt_num(rw as f64), widgets::fmt_num(rh as f64));
}
widgets::vline(ui, 22.0);
- if widgets::secondary_button(ui, "Clear", 0.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Clear"), 0.0).clicked() {
o.crop_ratio.clear();
}
- let _ = icons::button(ui, "grid-3x3", 24.0, true, "Overlay: Rule of Thirds");
- widgets::checkbox(ui, &mut o.crop_delete, "Delete Cropped Pixels");
+ let _ = icons::button(ui, "grid-3x3", 24.0, true, tl!("Overlay: Rule of Thirds"));
+ widgets::checkbox(ui, &mut o.crop_delete, tl!("Delete Cropped Pixels"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if icons::button(ui, "check", 26.0, false, &format!("Commit current crop operation ({})", crate::shortcuts::pretty("Enter")))
- .clicked()
+ if icons::button(
+ ui,
+ "check",
+ 26.0,
+ false,
+ &crate::i18n::fmt(tl!("Commit current crop operation ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]),
+ )
+ .clicked()
{
crate::canvas::commit_crop(app);
}
- if icons::button(ui, "ban", 26.0, false, "Cancel current crop operation (Esc)").clicked() {
+ if icons::button(ui, "ban", 26.0, false, tl!("Cancel current crop operation (Esc)")).clicked() {
app.ui.crop_rect = None;
}
});
@@ -657,16 +684,22 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
Tool::Type if t.pro => crate::type_tool::options_bar(app, ui),
Tool::Move if t.pro => {
let o = &mut app.ui.tool_options;
- widgets::checkbox(ui, &mut o.move_auto_select, "Auto-Select:");
- widgets::dropdown(ui, "move-target", &mut o.move_target, &[("layer".to_string(), "Layer"), ("group".to_string(), "Group")], 76.0);
+ widgets::checkbox(ui, &mut o.move_auto_select, tl!("Auto-Select:"));
+ widgets::dropdown(
+ ui,
+ "move-target",
+ &mut o.move_target,
+ &[("layer".to_string(), tl!("Layer")), ("group".to_string(), tl!("Group"))],
+ 76.0,
+ );
widgets::vline(ui, 22.0);
- widgets::checkbox(ui, &mut o.move_show_transform, "Show Transform Controls");
+ widgets::checkbox(ui, &mut o.move_show_transform, tl!("Show Transform Controls"));
widgets::vline(ui, 22.0);
ui.spacing_mut().item_spacing.x = 0.0;
for (icon, tip, cmd) in [
- ("panels-top-left", "Align left edges", "layer.align.leftEdges"),
- ("app-window", "Align horizontal centers", "layer.align.horizontalCenters"),
- ("panel-right", "Align right edges", "layer.align.rightEdges"),
+ ("panels-top-left", tl!("Align left edges"), "layer.align.leftEdges"),
+ ("app-window", tl!("Align horizontal centers"), "layer.align.horizontalCenters"),
+ ("panel-right", tl!("Align right edges"), "layer.align.rightEdges"),
] {
let on = app.session.is_enabled(cmd);
if ui.add_enabled_ui(on, |ui| icons::button(ui, icon, 24.0, false, tip)).inner.clicked() {
@@ -674,11 +707,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
ui.add_space(6.0);
- let more = icons::button(ui, "ellipsis", 24.0, false, "Align and distribute");
+ let more = icons::button(ui, "ellipsis", 24.0, false, tl!("Align and distribute"));
egui::Popup::menu(&more).show(|ui| {
ui.set_min_width(200.0);
let mut section = |ui: &mut egui::Ui, title: &str, prefix: &str| {
- ui.label(egui::RichText::new(title).small().color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(&title)).small().color(t.text_dim));
for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with(prefix)) {
if ui.add_enabled(app.session.is_enabled(c.id), egui::Button::new(c.label)).clicked() {
let _ = app.run(c.id, json!({}));
@@ -686,9 +719,9 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
};
- section(ui, "Align", "layer.align.");
+ section(ui, tl!("Align"), "layer.align.");
ui.separator();
- section(ui, "Distribute", "layer.distribute.");
+ section(ui, tl!("Distribute"), "layer.distribute.");
});
}
Tool::RectMarquee | Tool::EllipseMarquee => hint(
@@ -701,13 +734,23 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
),
),
Tool::Move => hint(ui, "Drag to move the active layer"),
- Tool::Eyedropper => {
- hint(ui, &format!("Click to sample the foreground colour · {}-click for background", crate::shortcuts::pretty("Alt")))
- }
+ Tool::Eyedropper => hint(
+ ui,
+ &crate::i18n::fmt(
+ tl!("Click to sample the foreground colour · {key}-click for background"),
+ &[("key", &crate::shortcuts::pretty("Alt"))],
+ ),
+ ),
Tool::Zoom => {
widgets::checkbox(ui, &mut app.ui.tool_options.zoom_scrubby, "Scrubby Zoom");
- hint(ui, &format!("Click to zoom in · {}-click to zoom out · drag right/left to zoom in/out", crate::shortcuts::pretty("Alt")));
- if widgets::secondary_button(ui, "Fit Screen", 0.0).clicked()
+ hint(
+ ui,
+ &crate::i18n::fmt(
+ tl!("Click to zoom in · {key}-click to zoom out · drag right/left to zoom in/out"),
+ &[("key", &crate::shortcuts::pretty("Alt"))],
+ ),
+ );
+ if widgets::secondary_button(ui, tl!("Fit Screen"), 0.0).clicked()
&& let Some(i) = app.session.active_index()
{
app.ui.views[i].fit_pending = true;
@@ -757,7 +800,7 @@ fn label(ui: &mut egui::Ui, s: &str) {
fn opt_label(ui: &mut egui::Ui, s: &str) {
let t = Tokens::get(ui.ctx());
let text = if t.pro && !s.ends_with(':') { format!("{s}:") } else { s.to_string() };
- ui.label(RichText::new(text).color(t.text_dim));
+ ui.label(RichText::new(tl!(&text)).color(t.text_dim));
}
fn hint(ui: &mut egui::Ui, s: &str) {
@@ -795,7 +838,7 @@ pub fn status_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
widgets::vline(ui, 16.0);
label(ui, &format!("{layers} layers"));
} else {
- label(ui, "No document");
+ label(ui, tl!("No document"));
}
if !app.ui.status.is_empty() {
widgets::vline(ui, 16.0);
@@ -805,7 +848,7 @@ pub fn status_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
if app.session.active().is_some()
&& !t.pro
- && widgets::secondary_button(ui, "Fit", 0.0).clicked()
+ && widgets::secondary_button(ui, tl!("Fit"), 0.0).clicked()
&& let Some(i) = app.session.active_index()
{
app.ui.views[i].fit_pending = true;
@@ -833,11 +876,11 @@ pub fn right_dock(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.y = 4.0;
use crate::dock::Group;
let entries: [(&str, &str, Group); 5] = [
- ("sliders-horizontal", "Properties", Group::Properties),
- ("navigation", "Navigator", Group::Navigator),
- ("palette", "Color & Swatches", Group::Color),
- ("layers", "Layers", Group::Layers),
- ("clock", "History", Group::History),
+ ("sliders-horizontal", tl!("Properties"), Group::Properties),
+ ("navigation", tl!("Navigator"), Group::Navigator),
+ ("palette", tl!("Color & Swatches"), Group::Color),
+ ("layers", tl!("Layers"), Group::Layers),
+ ("clock", tl!("History"), Group::History),
];
for (icon, name, g) in entries {
// Studio floats Properties outside the dock.
@@ -926,7 +969,7 @@ fn dock_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, group: crate::dock::Gro
fn info_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- empty(ui, "No document");
+ empty(ui, tl!("No document"));
return;
};
let (rev, size) = (st.revision, st.doc.size);
@@ -984,13 +1027,17 @@ fn info_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
row(&mut cols[1], "H:", sel.map_or_else(dash, |r| fy(r.height() as f64)));
});
widgets::hairline(ui);
- ui.label(RichText::new(format!("Doc: {} × {} px", size.width, size.height)).color(t.text_dim).size(11.5));
+ ui.label(
+ RichText::new(crate::i18n::fmt(tl!("Doc: {w} × {h} px"), &[("w", &size.width.to_string()), ("h", &size.height.to_string())]))
+ .color(t.text_dim)
+ .size(11.5),
+ );
}
fn navigator(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(idx) = app.session.active_index() else {
- empty(ui, "No document");
+ empty(ui, tl!("No document"));
return;
};
let ctx = ui.ctx().clone();
@@ -1023,7 +1070,7 @@ fn navigator(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.painter().rect_stroke(vr, 2.0, Stroke::new(1.5, Color32::from_rgb(255, 84, 84)), StrokeKind::Middle);
ui.add_space(4.0);
ui.horizontal(|ui| {
- label(ui, "Zoom");
+ label(ui, tl!("Zoom"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
for (lbl, z) in [("200%", 2.0), ("100%", 1.0)] {
if widgets::pill_tab(ui, lbl, (v.zoom - z).abs() < 1e-3).clicked() {
@@ -1031,7 +1078,7 @@ fn navigator(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
app.ui.views[idx].fit_pending = false;
}
}
- if widgets::pill_tab(ui, "Fit", false).clicked() {
+ if widgets::pill_tab(ui, tl!("Fit"), false).clicked() {
app.ui.views[idx].fit_pending = true;
}
});
@@ -1118,7 +1165,7 @@ fn swatches(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
ui.add_space(2.0);
- ui.label(RichText::new("Click sets foreground · right-click sets background").small().color(t.text_faint));
+ ui.label(RichText::new(tl!("Click sets foreground · right-click sets background")).small().color(t.text_faint));
}
fn color_picker(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
@@ -1128,12 +1175,12 @@ fn color_picker(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut s = hsva0.s * 100.0;
let mut v = hsva0.v * 100.0;
let hue = widgets::hue_stops();
- widgets::slider_row(ui, "Hue", &mut h, 0.0..=360.0, "°", Some(&hue));
+ widgets::slider_row(ui, tl!("Hue"), &mut h, 0.0..=360.0, "°", Some(&hue));
let sat_stops =
[egui::ecolor::Hsva::new(hsva0.h, 0.0, hsva0.v.max(0.2), 1.0), egui::ecolor::Hsva::new(hsva0.h, 1.0, hsva0.v.max(0.2), 1.0)].map(Color32::from);
- widgets::slider_row(ui, "Saturation", &mut s, 0.0..=100.0, "%", Some(&sat_stops));
+ widgets::slider_row(ui, tl!("Saturation"), &mut s, 0.0..=100.0, "%", Some(&sat_stops));
let val_stops = [Color32::BLACK, Color32::from(egui::ecolor::Hsva::new(hsva0.h, hsva0.s, 1.0, 1.0))];
- widgets::slider_row(ui, "Brightness", &mut v, 0.0..=100.0, "%", Some(&val_stops));
+ widgets::slider_row(ui, tl!("Brightness"), &mut v, 0.0..=100.0, "%", Some(&val_stops));
let hsva = egui::ecolor::Hsva::new(h / 360.0, s / 100.0, v / 100.0, 1.0);
if hsva != hsva0 {
app.session.tools.foreground = hsva_srgb(hsva);
@@ -1173,7 +1220,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// A new active layer opens its parent groups and is scrolled into view (#152).
let reveal = crate::layer_reveal::track(app, ui.ctx());
let Some(st) = app.session.active() else {
- empty(ui, "No document");
+ empty(ui, tl!("No document"));
return;
};
let doc = st.doc.clone();
@@ -1191,14 +1238,14 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.painter().rect_filled(r, t.radius_sm, t.field);
ui.painter().rect_stroke(r, t.radius_sm, Stroke::new(1.0, t.field_border), StrokeKind::Inside);
icons::paint(ui, Rect::from_center_size(r.left_center() + vec2(11.0, 0.0), vec2(14.0, 14.0)), "search", 11.0, t.text_faint);
- ui.painter().text(r.left_center() + vec2(22.0, 0.0), Align2::LEFT_CENTER, "Kind", egui::FontId::proportional(11.5), t.text_dim);
+ ui.painter().text(r.left_center() + vec2(22.0, 0.0), Align2::LEFT_CENTER, tl!("Kind"), egui::FontId::proportional(11.5), t.text_dim);
ui.add_space(4.0);
for (kind, icon, tip) in [
- ("pixel", "image", "Filter for pixel layers"),
- ("adjustment", "contrast", "Filter for adjustment layers"),
- ("type", "type", "Filter for type layers"),
- ("shape", "square", "Filter for shape layers"),
- ("smart", "app-window", "Filter for smart objects"),
+ ("pixel", "image", tl!("Filter for pixel layers")),
+ ("adjustment", "contrast", tl!("Filter for adjustment layers")),
+ ("type", "type", tl!("Filter for type layers")),
+ ("shape", "square", tl!("Filter for shape layers")),
+ ("smart", "app-window", tl!("Filter for smart objects")),
] {
let on = app.ui.layer_filter.iter().any(|k| k == kind);
if icons::button(ui, icon, 22.0, on, tip).clicked() {
@@ -1227,23 +1274,23 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if widgets::value_field(ui, &mut o, 0.0..=100.0, "%", 66.0).changed() {
actions.push(("layer.setProps".into(), json!({"layer": l.id.0, "opacity": o / 100.0})));
}
- label(ui, if t.pro { "Opacity:" } else { "Opacity" });
+ label(ui, if t.pro { tl!("Opacity:") } else { tl!("Opacity") });
});
});
});
// Docks zero the item spacing: keep the Opacity and Fill fields apart (#155).
ui.add_space((theme::ROW_GAP - ui.spacing().item_spacing.y).max(0.0));
ui.horizontal(|ui| {
- label(ui, if t.pro { "Lock:" } else { "Lock" });
+ label(ui, if t.pro { tl!("Lock:") } else { tl!("Lock") });
if t.pro {
ui.spacing_mut().item_spacing.x = 0.0;
let lk = l.locks;
for (key, icon, tip, on) in [
- ("transparency", "grid-3x3", "Lock transparent pixels", lk.transparency),
- ("pixels", "brush", "Lock image pixels", lk.pixels),
- ("position", "move", "Lock position", lk.position),
- ("artboard", "scan", "Prevent auto-nesting in and out of Artboards and Frames", lk.artboard),
- ("all", "lock", "Lock all", lk.all),
+ ("transparency", "grid-3x3", tl!("Lock transparent pixels"), lk.transparency),
+ ("pixels", "brush", tl!("Lock image pixels"), lk.pixels),
+ ("position", "move", tl!("Lock position"), lk.position),
+ ("artboard", "scan", tl!("Prevent auto-nesting in and out of Artboards and Frames"), lk.artboard),
+ ("all", "lock", tl!("Lock all"), lk.all),
] {
if icons::button(ui, icon, 20.0, on, tip).clicked() {
actions.push(("layer.setProps".into(), json!({"layer": l.id.0, "locks": { key: !on }})));
@@ -1252,7 +1299,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
if !t.pro {
let locked = l.locks.transparency || l.locks.position || l.locks.all;
- if icons::button(ui, if locked { "lock" } else { "lock-open" }, 22.0, locked, "Lock layer").clicked() {
+ if icons::button(ui, if locked { "lock" } else { "lock-open" }, 22.0, locked, tl!("Lock layer")).clicked() {
actions.push(simple_lock_toggle(bg, l));
}
}
@@ -1262,7 +1309,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if widgets::value_field(ui, &mut f, 0.0..=100.0, "%", 66.0).changed() {
actions.push(("layer.setProps".into(), json!({"layer": l.id.0, "fill": f / 100.0})));
}
- label(ui, if t.pro { "Fill:" } else { "Fill" });
+ label(ui, if t.pro { tl!("Fill:") } else { tl!("Fill") });
})
});
});
@@ -1324,16 +1371,16 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if icons::button(ui, "trash", 26.0, false, "Delete layer").clicked() {
+ if icons::button(ui, "trash", 26.0, false, tl!("Delete layer")).clicked() {
actions.push(("layer.delete".into(), json!({})));
}
if icons::button(ui, "square-plus", 26.0, false, &crate::shortcuts::tip_label(app, "Create a new layer", "layer.new.layer")).clicked() {
actions.push(("layer.new.layer".into(), json!({})));
}
- if icons::button(ui, "folder", 26.0, false, "Create a new group").clicked() {
+ if icons::button(ui, "folder", 26.0, false, tl!("Create a new group")).clicked() {
actions.push(("layer.new.group".into(), json!({})));
}
- let adj = icons::button(ui, "contrast", 26.0, false, "Create new fill or adjustment layer");
+ let adj = icons::button(ui, "contrast", 26.0, false, tl!("Create new fill or adjustment layer"));
egui::Popup::menu(&adj).show(|ui| {
ui.set_min_width(190.0);
for c in photocraft_engine::command_specs().iter().filter(|c| c.id.starts_with("layer.newAdjustmentLayer.")) {
@@ -1343,24 +1390,31 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
ui.separator();
- if ui.button("Solid Color…").clicked() {
+ if ui.button(tl!("Solid Color…")).clicked() {
actions.push(("layer.newFillLayer.solidColor".into(), json!({})));
ui.close();
}
- if ui.button("Gradient…").clicked() {
+ if ui.button(tl!("Gradient…")).clicked() {
actions.push(("layer.newFillLayer.gradient".into(), json!({})));
ui.close();
}
});
- if icons::button(ui, "square-dot", 26.0, false, &format!("Add a mask (from the selection; {} inverts)", crate::shortcuts::pretty("Alt"))).clicked()
+ if icons::button(
+ ui,
+ "square-dot",
+ 26.0,
+ false,
+ &crate::i18n::fmt(tl!("Add a mask (from the selection; {key} inverts)"), &[("key", &crate::shortcuts::pretty("Alt"))]),
+ )
+ .clicked()
{
let alt = ui.input(|i| i.modifiers.alt);
actions.push((crate::layer_menu_ui::add_mask_command(doc.selection.is_some(), alt).into(), json!({})));
}
- let fx = fx_button(ui, 26.0, "Add a layer style");
+ let fx = fx_button(ui, 26.0, tl!("Add a layer style"));
egui::Popup::menu(&fx).show(|ui| {
ui.set_min_width(180.0);
- if ui.button("Blending Options…").clicked() {
+ if ui.button(tl!("Blending Options…")).clicked() {
crate::layer_style::open(app, None);
ui.close();
}
@@ -1374,7 +1428,7 @@ fn layers(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
});
// Photoshop's footer starts with Link Layers (enabled with two or more layers selected).
let can_link = app.session.is_enabled("layer.linkLayers");
- if ui.add_enabled_ui(can_link, |ui| icons::button(ui, "link", 26.0, false, "Link layers")).inner.clicked() {
+ if ui.add_enabled_ui(can_link, |ui| icons::button(ui, "link", 26.0, false, tl!("Link layers"))).inner.clicked() {
actions.push(("layer.linkLayers".into(), json!({})));
}
});
@@ -1543,8 +1597,8 @@ fn layer_row(
});
if !is_pixel {
let sub = match &l.content {
- LayerContent::Adjustment(a) => a.label().to_string(),
- LayerContent::Group(g) => format!("Group · {} layers", g.children.len()),
+ LayerContent::Adjustment(a) => tl!(a.label()).to_string(),
+ LayerContent::Group(g) => crate::i18n::trn(crate::i18n::current(), g.children.len() as u64, "Group · {n} layer", "Group · {n} layers"),
other => other.kind_name().to_string(),
};
crate::layer_row_ui::label(&painter, x, rect.center().y + 8.0, name_right, &sub, egui::FontId::proportional(11.0), t.text_faint);
@@ -1674,7 +1728,7 @@ fn channels(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- empty(ui, "No document");
+ empty(ui, tl!("No document"));
return;
};
let doc = st.doc.clone();
@@ -1747,9 +1801,9 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- let _ = icons::button(ui, "trash", 24.0, false, "Delete current state");
- let _ = icons::button(ui, "scan", 24.0, false, "Create new snapshot");
- let _ = icons::button(ui, "file-plus", 24.0, false, "Create new document from current state");
+ let _ = icons::button(ui, "trash", 24.0, false, tl!("Delete current state"));
+ let _ = icons::button(ui, "scan", 24.0, false, tl!("Create new snapshot"));
+ let _ = icons::button(ui, "file-plus", 24.0, false, tl!("Create new document from current state"));
});
});
}
@@ -1798,9 +1852,9 @@ pub fn properties_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
frame.show(ui, |ui| {
ui.set_width(width - 28.0);
let title = ui.horizontal(|ui| {
- ui.label(RichText::new("Properties").font(theme::semibold(13.5)).color(t.text));
+ ui.label(RichText::new(tl!("Properties")).font(theme::semibold(13.5)).color(t.text));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if icons::button(ui, "minus", 22.0, false, "Hide Properties").clicked() {
+ if icons::button(ui, "minus", 22.0, false, tl!("Hide Properties")).clicked() {
app.ui.panels.properties = false;
}
});
@@ -1825,7 +1879,7 @@ pub fn properties_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.vertical(|ui| {
ui.label(RichText::new(&layer.name).font(theme::medium(13.0)).color(t.text));
let kind = match &layer.content {
- LayerContent::Adjustment(a) => format!("{} Properties", a.label()),
+ LayerContent::Adjustment(a) => crate::i18n::fmt(tl!("{name} Properties"), &[("name", tl!(a.label()))]),
other => format!("{} Layer", other.kind_name()),
};
ui.label(RichText::new(kind).small().color(t.text_faint));
@@ -1857,17 +1911,17 @@ fn adjustment_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: LayerId,
if let Some(l) = layer {
ui.horizontal(|ui| {
let mut vis = l.visible;
- if widgets::toggle(ui, &mut vis, "Adjustment visible").changed() {
+ if widgets::toggle(ui, &mut vis, tl!("Adjustment visible")).changed() {
let _ = app.run("layer.setProps", json!({"layer": id.0, "visible": vis}));
}
let mut clip = l.clipped;
- if widgets::toggle(ui, &mut clip, "Clip to layer below").changed() {
+ if widgets::toggle(ui, &mut clip, tl!("Clip to layer below")).changed() {
let _ = app.run("layer.setProps", json!({"layer": id.0, "clipped": clip}));
}
});
}
ui.add_space(6.0);
- if widgets::secondary_button(ui, "Reset to defaults", ui.available_width()).clicked() {
+ if widgets::secondary_button(ui, tl!("Reset to defaults"), ui.available_width()).clicked() {
let _ = app.run("layer.setAdjustment", json!({"layer": id.0}));
app.live_adjust = None;
}
@@ -1887,12 +1941,12 @@ fn layer_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
ui.add_space(6.0);
}
let mut o = layer.opacity * 100.0;
- let r = widgets::slider_row(ui, "Opacity", &mut o, 0.0..=100.0, "%", None);
+ let r = widgets::slider_row(ui, tl!("Opacity"), &mut o, 0.0..=100.0, "%", None);
if r.drag_stopped() || (r.changed() && !r.dragged()) {
let _ = app.run("layer.setProps", json!({"layer": layer.id.0, "opacity": o / 100.0}));
}
let mut f = layer.fill_opacity * 100.0;
- let r = widgets::slider_row(ui, "Fill", &mut f, 0.0..=100.0, "%", None);
+ let r = widgets::slider_row(ui, tl!("Fill"), &mut f, 0.0..=100.0, "%", None);
if r.drag_stopped() || (r.changed() && !r.dragged()) {
let _ = app.run("layer.setProps", json!({"layer": layer.id.0, "fill": f / 100.0}));
}
@@ -1902,7 +1956,7 @@ fn layer_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) {
fn properties_body(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- empty(ui, "No properties");
+ empty(ui, tl!("No properties"));
return;
};
// Photoshop shows the Document properties when nothing or the Background layer is selected.
@@ -1947,25 +2001,25 @@ fn properties_body(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
/// Photoshop's Adjustments panel: a grid of one-click adjustment layers.
fn adjustments_grid(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
- ui.label(RichText::new("Add an adjustment").color(t.text_dim));
+ ui.label(RichText::new(tl!("Add an adjustment")).color(t.text_dim));
ui.add_space(4.0);
let items: [(&str, &str, &str); 16] = [
- ("brightnessContrast", "sun", "Brightness/Contrast"),
- ("levels", "gauge", "Levels"),
- ("curves", "pen-tool", "Curves"),
- ("exposure", "scan", "Exposure"),
- ("vibrance", "sparkles", "Vibrance"),
- ("hueSaturation", "droplet", "Hue/Saturation"),
- ("colorBalance", "blend", "Color Balance"),
- ("blackWhite", "contrast", "Black & White"),
- ("photoFilter", "circle-dot", "Photo Filter"),
- ("channelMixer", "sliders-horizontal", "Channel Mixer"),
- ("invert", "squares-subtract", "Invert"),
- ("posterize", "layers", "Posterize"),
- ("threshold", "square", "Threshold"),
- ("gradientMap", "palette", "Gradient Map"),
- ("selectiveColor", "swatch-book", "Selective Color"),
- ("colorLookup", "grid-3x3", "Color Lookup"),
+ ("brightnessContrast", "sun", tl!("Brightness/Contrast")),
+ ("levels", "gauge", tl!("Levels")),
+ ("curves", "pen-tool", tl!("Curves")),
+ ("exposure", "scan", tl!("Exposure")),
+ ("vibrance", "sparkles", tl!("Vibrance")),
+ ("hueSaturation", "droplet", tl!("Hue/Saturation")),
+ ("colorBalance", "blend", tl!("Color Balance")),
+ ("blackWhite", "contrast", tl!("Black & White")),
+ ("photoFilter", "circle-dot", tl!("Photo Filter")),
+ ("channelMixer", "sliders-horizontal", tl!("Channel Mixer")),
+ ("invert", "squares-subtract", tl!("Invert")),
+ ("posterize", "layers", tl!("Posterize")),
+ ("threshold", "square", tl!("Threshold")),
+ ("gradientMap", "palette", tl!("Gradient Map")),
+ ("selectiveColor", "swatch-book", tl!("Selective Color")),
+ ("colorLookup", "grid-3x3", tl!("Color Lookup")),
];
let mut run = None;
ui.horizontal_wrapped(|ui| {
@@ -2125,8 +2179,8 @@ fn brush_preset_chip(
brush_tip(ui.painter(), c, 7.0, b.hardness, Color32::WHITE);
ui.painter().text(pos2(c.x, r.bottom() - 5.0), Align2::CENTER_CENTER, format!("{}", b.size.round() as i64), egui::FontId::proportional(9.5), t.text_dim);
icons::paint(ui, Rect::from_center_size(pos2(r.right() - 9.0, c.y), vec2(10.0, 10.0)), "chevron-down", 9.0, t.text_faint);
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "Brush Preset picker"));
- let resp = resp.on_hover_text("Brush Preset picker");
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, tl!("Brush Preset picker")));
+ let resp = resp.on_hover_text(tl!("Brush Preset picker"));
egui::Popup::from_toggle_button_response(&resp)
.close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside)
.show(|ui| crate::brush_picker::body(ui, b, presets))
@@ -2232,10 +2286,10 @@ fn effect_rows(app: &mut PhotocraftApp, ui: &mut egui::Ui, l: &Layer, depth: usi
fn selection_mode_buttons(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.spacing_mut().item_spacing.x = 2.0;
for (i, (icon, tip)) in [
- ("square", "New selection".to_string()),
- ("plus", format!("Add to selection ({})", crate::shortcuts::pretty("Shift"))),
- ("minus", format!("Subtract from selection ({})", crate::shortcuts::pretty("Alt"))),
- ("squares-subtract", format!("Intersect with selection ({})", crate::shortcuts::pretty("Shift+Alt"))),
+ ("square", tl!("New selection").to_string()),
+ ("plus", crate::i18n::fmt(tl!("Add to selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift"))])),
+ ("minus", crate::i18n::fmt(tl!("Subtract from selection ({key})"), &[("key", &crate::shortcuts::pretty("Alt"))])),
+ ("squares-subtract", crate::i18n::fmt(tl!("Intersect with selection ({key})"), &[("key", &crate::shortcuts::pretty("Shift+Alt"))])),
]
.iter()
.enumerate()
@@ -2260,7 +2314,7 @@ fn gradient_swatch(ui: &mut egui::Ui, a: [f32; 4], b: [f32; 4]) {
mesh.add_triangle(0, 2, 3);
ui.painter().add(mesh);
ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Outside);
- let _ = resp.on_hover_text("Click to edit the gradient");
+ let _ = resp.on_hover_text(tl!("Click to edit the gradient"));
}
#[cfg(test)]
diff --git a/crates/ui-egui/src/perspective_ui.rs b/crates/ui-egui/src/perspective_ui.rs
index 899edfe3a..996df6a0c 100644
--- a/crates/ui-egui/src/perspective_ui.rs
+++ b/crates/ui-egui/src/perspective_ui.rs
@@ -143,7 +143,7 @@ pub fn begin(app: &mut PhotocraftApp, ctx: &egui::Context, command: &str) -> Res
};
s.update_grid();
app.distort.perspective = Some(s);
- app.ui.status = "Perspective Warp: draw planes along the image's perspective, then switch to Warp".into();
+ app.ui.status = tl!("Perspective Warp: draw planes along the image's perspective, then switch to Warp").into();
Ok(())
}
@@ -174,7 +174,7 @@ pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result<Value, String> {
app.distort.perspective = None;
return Ok(json!({"cancelled": true}));
}
- let s = app.distort.perspective.as_mut().ok_or("Perspective Warp is not active")?;
+ let s = app.distort.perspective.as_mut().ok_or(tl!("Perspective Warp is not active"))?;
if let Some(m) = ui.get("mode").and_then(Value::as_str) {
set_mode(s, if m == "warp" { PerspMode::Warp } else { PerspMode::Layout });
}
@@ -302,26 +302,29 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
crate::widgets::vline(ui, 22.0);
if s.mode == PerspMode::Warp {
for (label, tip, m) in [
- ("Straighten", "Automatically straighten near-vertical line segments", Straighten::Vertical),
- ("Level", "Automatically level near-horizontal line segments", Straighten::Horizontal),
- ("Both", "Automatically straighten and level", Straighten::Auto),
+ (tl!("Straighten"), tl!("Automatically straighten near-vertical line segments"), Straighten::Vertical),
+ (tl!("Level"), tl!("Automatically level near-horizontal line segments"), Straighten::Horizontal),
+ (tl!("Both"), tl!("Automatically straighten and level"), Straighten::Auto),
] {
- if ui.button(label).on_hover_text(tip).clicked() {
+ if ui.button(tl!(&label)).on_hover_text(tip).clicked() {
straighten(&mut s.planes, m);
s.update_grid();
}
}
} else {
ui.label(format!("{} plane(s)", s.planes.len()));
- if ui.button("Remove Planes").clicked() {
+ if ui.button(tl!("Remove Planes")).clicked() {
s.planes.clear();
s.update_grid();
}
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::widgets::primary_button(ui, "✓", 32.0).on_hover_text(format!("Commit Perspective Warp ({})", crate::shortcuts::pretty("Enter"))).clicked() {
+ if crate::widgets::primary_button(ui, "✓", 32.0)
+ .on_hover_text(crate::i18n::fmt(tl!("Commit Perspective Warp ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]))
+ .clicked()
+ {
commit(app);
- } else if crate::widgets::secondary_button(ui, "⊘", 32.0).on_hover_text("Cancel (Esc)").clicked() {
+ } else if crate::widgets::secondary_button(ui, "⊘", 32.0).on_hover_text(tl!("Cancel (Esc)")).clicked() {
app.distort.perspective = None;
}
});
diff --git a/crates/ui-egui/src/plugin_ui.rs b/crates/ui-egui/src/plugin_ui.rs
index 38de85ac1..7b15312c8 100644
--- a/crates/ui-egui/src/plugin_ui.rs
+++ b/crates/ui-egui/src/plugin_ui.rs
@@ -13,7 +13,7 @@ const PREFIX: &str = "plugin.filter.";
pub fn insert_menu_items(app: &PhotocraftApp, items: &mut Vec<MenuItem>) {
let plugins = photocraft_plugins::registry::list();
let Some(at) = items.iter().position(|i| i.id == "plugin.install") else { return };
- let path: Vec<String> = vec!["Filter".into(), "Plug-ins".into()];
+ let path: Vec<String> = vec![tl!("Filter").into(), tl!("Plug-ins").into()];
let enabled = app.session.is_enabled("plugin.run");
let mut extra: Vec<MenuItem> = plugins
.iter()
diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs
index 7b1454f8c..23fd245f5 100644
--- a/crates/ui-egui/src/prefs_ui.rs
+++ b/crates/ui-egui/src/prefs_ui.rs
@@ -352,16 +352,16 @@ pub fn shortcut_items(app: &PhotocraftApp) -> Vec<(String, String, Vec<String>,
pub fn shortcut_text(key: egui::Key, m: egui::Modifiers) -> Option<String> {
let mut parts = Vec::new();
if m.command || m.mac_cmd {
- parts.push("Cmd".to_string());
+ parts.push(tl!("Cmd").to_string());
}
if m.ctrl && !m.command {
- parts.push("Ctrl".into());
+ parts.push(tl!("Ctrl").into());
}
if m.alt {
- parts.push("Alt".into());
+ parts.push(tl!("Alt").into());
}
if m.shift {
- parts.push("Shift".into());
+ parts.push(tl!("Shift").into());
}
let name = match key {
egui::Key::Equals => "=",
@@ -525,7 +525,7 @@ pub fn open_shortcuts(app: &mut PhotocraftApp, tab: u64) -> u64 {
"capture": false,
"message": "",
});
- open_kind(app, "shortcuts", "Keyboard Shortcuts and Menus", fields)
+ open_kind(app, "shortcuts", tl!("Keyboard Shortcuts and Menus"), fields)
}
/// Open the Embedded Profile Mismatch prompt for the active document.
@@ -547,7 +547,7 @@ pub fn open_mismatch(app: &mut PhotocraftApp, report: &Value) -> u64 {
open_kind(
app,
"mismatch",
- "Embedded Profile Mismatch",
+ tl!("Embedded Profile Mismatch"),
json!({"message": msg, "action": action, "applied": action, "missing": report.get("missing").is_some()}),
)
}
@@ -609,6 +609,8 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let t = Tokens::get(ui.ctx());
let mut section = f.get("section").and_then(Value::as_str).unwrap_or("general").to_string();
let mut values = f.get("values").cloned().unwrap_or(Value::Null);
+ // The dialog follows the language being edited, so a change shows before OK.
+ let lang = crate::i18n::Lang::from_pref(values.pointer("/interface/language").and_then(Value::as_str).unwrap_or("auto"));
ui.horizontal_top(|ui| {
// Section list.
ui.vertical(|ui| {
@@ -625,7 +627,7 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.painter().text(
rect.left_center() + vec2(8.0, 0.0),
egui::Align2::LEFT_CENTER,
- title,
+ tl!(title),
crate::theme::medium(12.5),
if sel {
t.text
@@ -644,23 +646,23 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
ui.vertical(|ui| {
ui.set_width(540.0);
let title = SECTIONS.iter().find(|(id, _)| *id == section).map_or("General", |(_, t)| *t);
- ui.label(RichText::new(title).font(crate::theme::semibold(14.0)).color(t.text));
+ ui.label(RichText::new(tl!(&title)).font(crate::theme::semibold(14.0)).color(t.text));
ui.add_space(6.0);
egui::ScrollArea::vertical().max_height(390.0).id_salt("prefs-scroll").show(ui, |ui| {
let order: Vec<String> =
f.get("__order").and_then(|o| o.get(&section)).and_then(|v| serde_json::from_value(v.clone()).ok()).unwrap_or_default();
if !has_visible_fields(&values, &section) {
ui.add_space(4.0);
- ui.label(RichText::new("These settings aren't available in PhotoCraft yet.").color(t.text_faint));
+ ui.label(RichText::new(tl!("These settings aren't available in PhotoCraft yet.")).color(t.text_faint));
} else if let Some(obj) = values.get_mut(&section).and_then(Value::as_object_mut) {
- section_fields(ui, &section, obj, &order);
+ section_fields(ui, &section, obj, &order, lang);
if section == "performance" {
gpu_status_rows(ui, f.get("__gpuInfo"), obj);
}
ui.add_space(8.0);
}
if has_visible_fields(&values, &section)
- && crate::widgets::secondary_button(ui, "Reset Section", 110.0).clicked()
+ && crate::widgets::secondary_button(ui, tl!("Reset Section"), 110.0).clicked()
&& let Some(def) = prefs::Preferences::default().get(&section)
{
values[&section] = def;
@@ -677,17 +679,17 @@ fn prefs_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
fn gpu_status_rows(ui: &mut egui::Ui, info: Option<&Value>, obj: &mut Map<String, Value>) {
let t = Tokens::get(ui.ctx());
ui.add_space(10.0);
- ui.label(RichText::new("Graphics").font(crate::theme::semibold(12.5)).color(t.text));
+ ui.label(RichText::new(tl!("Graphics")).font(crate::theme::semibold(12.5)).color(t.text));
for line in info.and_then(Value::as_array).into_iter().flatten().filter_map(Value::as_str) {
ui.label(RichText::new(line).color(t.text_dim));
}
let auto = obj.get("gpuBackend").and_then(Value::as_str) == Some("auto");
ui.add_space(4.0);
ui.horizontal(|ui| {
- if ui.add_enabled(!auto, egui::Button::new("Reset GPU Backend")).clicked() {
+ if ui.add_enabled(!auto, egui::Button::new(tl!("Reset GPU Backend"))).clicked() {
obj.insert("gpuBackend".into(), json!("auto"));
}
- ui.label(RichText::new("Applies at next launch.").color(t.text_faint));
+ ui.label(RichText::new(tl!("Applies at next launch.")).color(t.text_faint));
});
}
@@ -698,7 +700,7 @@ fn has_visible_fields(values: &Value, section: &str) -> bool {
/// Generic editor for a section's fields: checkboxes, dropdowns for choices, colour swatches,
/// number fields with the preference's range, text fields.
-fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>, order: &[String]) {
+fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>, order: &[String], lang: crate::i18n::Lang) {
let t = Tokens::get(ui.ctx());
let mut keys: Vec<String> = order.iter().filter(|k| obj.contains_key(*k)).cloned().collect();
keys.extend(obj.keys().filter(|k| !order.contains(k)).cloned());
@@ -711,7 +713,8 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
continue;
}
let v = obj.get(&k).cloned().unwrap_or(Value::Null);
- let label = humanize(&k);
+ let human = humanize(&k);
+ let label = tl!(&human).to_string();
match &v {
Value::Bool(b) => {
ui.label("");
@@ -719,8 +722,16 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
crate::widgets::checkbox(ui, &mut b, &label);
obj.insert(k, json!(b));
}
+ Value::String(s) if path == "interface.language" => {
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
+ let mut pairs: Vec<(String, &str)> = vec![("auto".into(), tl!("Auto"))];
+ pairs.extend(crate::i18n::Lang::all().map(|l| (l.code().to_string(), l.name())));
+ let mut cur = s.clone();
+ crate::widgets::dropdown(ui, &format!("pref-{path}"), &mut cur, &pairs, 220.0);
+ obj.insert(k, json!(cur));
+ }
Value::String(s) if prefs::choices(&path).is_some() => {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let opts = prefs::choices(&path).unwrap_or(&[]);
let labels: Vec<String> = opts.iter().map(|o| choice_label(o)).collect();
let pairs: Vec<(String, &str)> = opts.iter().map(|o| o.to_string()).zip(labels.iter().map(String::as_str)).collect();
@@ -729,7 +740,7 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
obj.insert(k, json!(cur));
}
Value::String(s) if prefs::is_color(&path) => {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let c = prefs::parse_hex(s).unwrap_or([128, 128, 128]);
let mut rgb = c;
ui.horizontal(|ui| {
@@ -740,13 +751,13 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
let _ = color_of(s);
}
Value::String(s) => {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let mut s = s.clone();
ui.add(egui::TextEdit::singleline(&mut s).desired_width(260.0));
obj.insert(k, json!(s));
}
Value::Number(n) => {
- ui.label(RichText::new(label).color(t.text_dim));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
let (lo, hi) = prefs::range(&path).unwrap_or((-1e9, 1e9));
if n.is_u64() || n.is_i64() {
let mut x = n.as_i64().unwrap_or(0);
@@ -759,7 +770,7 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
}
}
Value::Array(items) if k == "disks" => {
- ui.label(RichText::new("Scratch disks").color(t.text_dim));
+ ui.label(RichText::new(tl!("Scratch disks")).color(t.text_dim));
let mut items = items.clone();
ui.vertical(|ui| {
for d in &mut items {
@@ -771,16 +782,16 @@ fn section_fields(ui: &mut egui::Ui, section: &str, obj: &mut Map<String, Value>
*d = json!({"enabled": on, "path": path});
});
}
- if ui.small_button("Add disk").clicked() {
+ if ui.small_button(tl!("Add disk")).clicked() {
items.push(json!({"enabled": true, "path": ""}));
}
});
obj.insert(k, Value::Array(items));
}
Value::Array(items) => {
- ui.label(RichText::new(label).color(t.text_dim));
- ui.label(RichText::new(format!("{} item{}", items.len(), if items.len() == 1 { "" } else { "s" })).color(t.text_faint));
- if !items.is_empty() && ui.small_button("Clear").clicked() {
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim));
+ ui.label(RichText::new(crate::i18n::trn(lang, items.len() as u64, "{n} item", "{n} items")).color(t.text_faint));
+ if !items.is_empty() && ui.small_button(tl!("Clear")).clicked() {
obj.insert(k, json!([]));
}
}
@@ -797,7 +808,7 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
let t = Tokens::get(ui.ctx());
let mut tab = f.get("tab").and_then(Value::as_u64).unwrap_or(0);
ui.horizontal(|ui| {
- for (i, name) in ["Keyboard Shortcuts", "Menus", "Toolbar"].iter().enumerate() {
+ for (i, name) in [tl!("Keyboard Shortcuts"), tl!("Menus"), tl!("Toolbar")].iter().enumerate() {
if crate::widgets::pill_tab(ui, name, tab == i as u64).clicked() {
tab = i as u64;
f.insert("capture".into(), json!(false));
@@ -812,8 +823,8 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
}
let mut filter = f.get("filter").and_then(Value::as_str).unwrap_or("").to_string();
ui.horizontal(|ui| {
- ui.label(RichText::new("Search").color(t.text_dim));
- ui.add(egui::TextEdit::singleline(&mut filter).desired_width(260.0).hint_text("command or shortcut"));
+ ui.label(RichText::new(tl!("Search")).color(t.text_dim));
+ ui.add(egui::TextEdit::singleline(&mut filter).desired_width(260.0).hint_text(tl!("command or shortcut")));
});
f.insert("filter".into(), json!(filter));
let mut overrides: BTreeMap<String, String> = f.get("overrides").and_then(|v| serde_json::from_value(v.clone()).ok()).unwrap_or_default();
@@ -847,7 +858,7 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
} else if matches!(key, egui::Key::Backspace | egui::Key::Delete) && m.is_none() {
overrides.insert(selected.clone(), String::new());
capture = false;
- message = "Shortcut removed.".into();
+ message = tl!("Shortcut removed.").into();
} else if let Some(sc) = shortcut_text(key, m) {
let clash: Vec<String> = items
.iter()
@@ -877,7 +888,7 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
if tab == 0 && path.is_empty() && def.is_none() && cur.is_none() {
continue;
}
- let top = path.first().cloned().unwrap_or_else(|| "Other".into());
+ let top = path.first().cloned().unwrap_or_else(|| tl!("Other").into());
if top != last_top {
ui.label(RichText::new(&top).font(crate::theme::semibold(12.5)).color(t.text));
ui.label("");
@@ -891,19 +902,20 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
selected = id.clone();
}
if tab == 0 {
- let text = if sel && capture { "Press keys…".to_string() } else { cur.as_deref().map(crate::shortcuts::pretty).unwrap_or_default() };
+ let text = if sel && capture { tl!("Press keys…").to_string() } else { cur.as_deref().map(crate::shortcuts::pretty).unwrap_or_default() };
let changed = overrides.contains_key(id);
- let r = ui
- .add(egui::Button::new(RichText::new(text).size(12.0).color(if changed { t.accent_text } else { t.text })).min_size(vec2(120.0, 18.0)));
+ let r = ui.add(
+ egui::Button::new(RichText::new(tl!(&text)).size(12.0).color(if changed { t.accent_text } else { t.text })).min_size(vec2(120.0, 18.0)),
+ );
if r.clicked() {
selected = id.clone();
capture = true;
message.clear();
}
- ui.label(if changed { RichText::new("modified").color(t.text_faint).size(10.5) } else { RichText::new("") });
+ ui.label(if changed { RichText::new(tl!("modified")).color(t.text_faint).size(10.5) } else { RichText::new("") });
} else {
let mut visible = !hidden.contains(id);
- crate::widgets::checkbox(ui, &mut visible, "Visible");
+ crate::widgets::checkbox(ui, &mut visible, tl!("Visible"));
if visible {
hidden.retain(|h| h != id);
} else if !hidden.contains(id) {
@@ -927,20 +939,20 @@ fn shortcuts_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String
if tab == 0 {
ui.horizontal(|ui| {
let has_sel = !selected.is_empty();
- if ui.add_enabled(has_sel, egui::Button::new("Use Default")).clicked() {
+ if ui.add_enabled(has_sel, egui::Button::new(tl!("Use Default"))).clicked() {
overrides.remove(&selected);
- message = "Default restored.".into();
+ message = tl!("Default restored.").into();
}
- if ui.add_enabled(has_sel, egui::Button::new("Delete Shortcut")).clicked() {
+ if ui.add_enabled(has_sel, egui::Button::new(tl!("Delete Shortcut"))).clicked() {
overrides.insert(selected.clone(), String::new());
- message = "Shortcut removed.".into();
+ message = tl!("Shortcut removed.").into();
}
- if ui.button("Reset All to Defaults").clicked() {
+ if ui.button(tl!("Reset All to Defaults")).clicked() {
overrides.clear();
- message = "All shortcuts reset to Photoshop defaults.".into();
+ message = tl!("All shortcuts reset to Photoshop defaults.").into();
}
});
- } else if ui.button("Show All Menu Items").clicked() {
+ } else if ui.button(tl!("Show All Menu Items")).clicked() {
hidden.clear();
colors.clear();
}
@@ -974,7 +986,7 @@ fn toolbar_tab(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
});
});
- if ui.button("Restore Defaults").clicked() {
+ if ui.button(tl!("Restore Defaults")).clicked() {
hidden.clear();
}
f.insert("toolbarHidden".into(), json!(hidden));
@@ -984,8 +996,8 @@ fn presets_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String,
let t = Tokens::get(ui.ctx());
let mut kind = f.get("kind").and_then(Value::as_str).unwrap_or("brushes").to_string();
ui.horizontal(|ui| {
- ui.label(RichText::new("Preset Type").color(t.text_dim));
- let opts = [("brushes".to_string(), "Brushes"), ("customShapes".to_string(), "Custom Shapes"), ("patterns".to_string(), "Patterns")];
+ ui.label(RichText::new(tl!("Preset Type")).color(t.text_dim));
+ let opts = [("brushes".to_string(), tl!("Brushes")), ("customShapes".to_string(), tl!("Custom Shapes")), ("patterns".to_string(), tl!("Patterns"))];
crate::widgets::dropdown(ui, "preset-kind", &mut kind, &opts, 180.0);
});
let list = app
@@ -1004,20 +1016,20 @@ fn presets_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String,
}
}
if list.is_empty() {
- ui.label(RichText::new("No presets of this type.").color(t.text_faint));
+ ui.label(RichText::new(tl!("No presets of this type.")).color(t.text_faint));
}
});
let mut new_name = f.get("newName").and_then(Value::as_str).unwrap_or("").to_string();
ui.horizontal(|ui| {
ui.add(egui::TextEdit::singleline(&mut new_name).desired_width(200.0));
- if ui.add_enabled(selected < list.len() && !new_name.trim().is_empty(), egui::Button::new("Rename")).clicked() {
+ if ui.add_enabled(selected < list.len() && !new_name.trim().is_empty(), egui::Button::new(tl!("Rename"))).clicked() {
let _ = app.run("edit.presets.presetManager", json!({"action": "rename", "kind": kind, "index": selected, "newName": new_name}));
}
- if ui.add_enabled(selected < list.len(), egui::Button::new("Delete")).clicked() {
+ if ui.add_enabled(selected < list.len(), egui::Button::new(tl!("Delete"))).clicked() {
let _ = app.run("edit.presets.presetManager", json!({"action": "delete", "kind": kind, "index": selected}));
}
// Load Photoshop brushes (.abr) into the library.
- if kind == "brushes" && ui.button("Load…").on_hover_text("Import Photoshop brushes (.abr)").clicked() {
+ if kind == "brushes" && ui.button(tl!("Load…")).on_hover_text(tl!("Import Photoshop brushes (.abr)")).clicked() {
app.open_dialog_file();
}
});
@@ -1030,10 +1042,16 @@ fn presets_io_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let t = Tokens::get(ui.ctx());
let mut action = f.get("action").and_then(Value::as_str).unwrap_or("export").to_string();
ui.horizontal(|ui| {
- ui.label(RichText::new("Action").color(t.text_dim));
- crate::widgets::dropdown(ui, "presets-io", &mut action, &[("export".to_string(), "Export Presets"), ("import".to_string(), "Import Presets")], 180.0);
+ ui.label(RichText::new(tl!("Action")).color(t.text_dim));
+ crate::widgets::dropdown(
+ ui,
+ "presets-io",
+ &mut action,
+ &[("export".to_string(), tl!("Export Presets")), ("import".to_string(), tl!("Import Presets"))],
+ 180.0,
+ );
});
- for (k, label) in [("brushes", "Brushes"), ("customShapes", "Custom Shapes")] {
+ for (k, label) in [("brushes", tl!("Brushes")), ("customShapes", tl!("Custom Shapes"))] {
let mut on = f.get(k).and_then(Value::as_bool).unwrap_or(true);
crate::widgets::checkbox(ui, &mut on, label);
f.insert(k.into(), json!(on));
@@ -1048,12 +1066,12 @@ fn mismatch_body(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let mut action = f.get("action").and_then(Value::as_str).unwrap_or("preserve").to_string();
let missing = f.get("missing").and_then(Value::as_bool).unwrap_or(false);
let opts: &[(&str, &str)] = if missing {
- &[("preserve", "Leave as is (don't color manage)"), ("assignWorking", "Assign working space")]
+ &[("preserve", tl!("Leave as is (don't color manage)")), ("assignWorking", tl!("Assign working space"))]
} else {
&[
- ("preserve", "Use the embedded profile (instead of the working space)"),
- ("convert", "Convert document's colors to the working space"),
- ("discard", "Discard the embedded profile (don't color manage)"),
+ ("preserve", tl!("Use the embedded profile (instead of the working space)")),
+ ("convert", tl!("Convert document's colors to the working space")),
+ ("discard", tl!("Discard the embedded profile (don't color manage)")),
]
};
for (v, label) in opts {
@@ -1128,6 +1146,29 @@ mod tests {
use super::*;
use std::sync::{Arc, Mutex};
+ /// Every generated preference label, section title and choice label has a Japanese entry.
+ #[test]
+ fn preference_labels_are_translated() {
+ let ja = crate::i18n::Lang::from_code("ja").expect("ja");
+ let session = photocraft_engine::Session::new();
+ let v: Value = serde_json::from_str(&session.prefs_to_json()).expect("prefs json");
+ let mut missing = Vec::new();
+ for (sec, title) in SECTIONS {
+ if !crate::i18n::has(ja, title) {
+ missing.push(title.to_string());
+ }
+ let Some(obj) = v.get(sec).and_then(Value::as_object) else { continue };
+ for k in obj.keys() {
+ let mut labels = vec![humanize(k)];
+ labels.extend(prefs::choices(&format!("{sec}.{k}")).into_iter().flatten().map(|c| choice_label(c)));
+ missing.extend(labels.into_iter().filter(|l| !crate::i18n::has(ja, l)));
+ }
+ }
+ missing.sort();
+ missing.dedup();
+ assert!(missing.is_empty(), "untranslated preference labels: {missing:#?}");
+ }
+
fn app_with_store() -> (PhotocraftApp, Arc<Mutex<Option<String>>>) {
app_with_saved(None)
}
diff --git a/crates/ui-egui/src/preset_files_ui.rs b/crates/ui-egui/src/preset_files_ui.rs
index 889a34658..3811f9694 100644
--- a/crates/ui-egui/src/preset_files_ui.rs
+++ b/crates/ui-egui/src/preset_files_ui.rs
@@ -36,7 +36,7 @@ pub fn open(app: &mut PhotocraftApp, name: &str, bytes: &[u8]) -> Option<Result<
"grd" => ("gradient.presets.importGrd", "gradients"),
_ => return None,
};
- let stem = std::path::Path::new(name).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_else(|| "Imported".into());
+ let stem = std::path::Path::new(name).file_stem().map(|s| s.to_string_lossy().to_string()).unwrap_or_else(|| tl!("Imported").into());
let mut p = source(name, bytes);
p["group"] = json!(stem);
if what == "brushes" {
diff --git a/crates/ui-egui/src/preset_panels.rs b/crates/ui-egui/src/preset_panels.rs
index a78690f41..54ffe80e1 100644
--- a/crates/ui-egui/src/preset_panels.rs
+++ b/crates/ui-egui/src/preset_panels.rs
@@ -44,7 +44,7 @@ pub struct PresetUi {
impl PresetUi {
pub fn shape(&self) -> &str {
- if self.custom_shape.is_empty() { "Heart" } else { &self.custom_shape }
+ if self.custom_shape.is_empty() { tl!("Heart") } else { &self.custom_shape }
}
}
@@ -258,7 +258,7 @@ fn browser(
if let Some((p, key, mut text)) = st.renaming.clone().filter(|r| r.0 == panel) {
let mut done = None;
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Name:").color(t.text_dim).size(11.5));
+ ui.label(egui::RichText::new(tl!("Name:")).color(t.text_dim).size(11.5));
let r = ui.add(egui::TextEdit::singleline(&mut text).desired_width(ui.available_width() - 4.0));
if !r.has_focus() && !r.lost_focus() {
r.request_focus();
@@ -301,11 +301,11 @@ fn browser(
}
}
hresp.context_menu(|ui| {
- if ui.button("Rename Group…").clicked() {
+ if ui.button(tl!("Rename Group…")).clicked() {
st.renaming = Some((panel.to_string(), format!("group:{}", g.name), g.name.clone()));
ui.close();
}
- if ui.button("Delete Group").clicked() {
+ if ui.button(tl!("Delete Group")).clicked() {
ev.push(Ev::DeleteGroup(g.name.clone()));
ui.close();
}
@@ -373,15 +373,15 @@ fn browser(
dropped = Some((it.key.clone(), pp));
}
resp.context_menu(|ui| {
- if ui.button("Rename…").clicked() {
+ if ui.button(tl!("Rename…")).clicked() {
st.renaming = Some((panel.to_string(), it.key.clone(), it.name.clone()));
ui.close();
}
- if ui.button("Delete").clicked() {
+ if ui.button(tl!("Delete")).clicked() {
ev.push(Ev::Delete(it.key.clone()));
ui.close();
}
- ui.menu_button("Move to", |ui| {
+ ui.menu_button(tl!("Move to"), |ui| {
for gname in group_names.iter().filter(|n| **n != g.name) {
if ui.button(gname).clicked() {
ev.push(Ev::Move(it.key.clone(), gname.clone()));
@@ -405,12 +405,12 @@ fn browser(
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
let mut s = size;
- ui.add_sized(vec2(90.0, 18.0), egui::Slider::new(&mut s, MIN_THUMB..=96.0).show_value(false)).on_hover_text("Thumbnail size (smallest: list)");
+ ui.add_sized(vec2(90.0, 18.0), egui::Slider::new(&mut s, MIN_THUMB..=96.0).show_value(false)).on_hover_text(tl!("Thumbnail size (smallest: list)"));
if (s - size).abs() > 0.01 {
st.sizes.insert(panel.to_string(), s);
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 24.0, false, "Delete").clicked()
+ if crate::icons::button(ui, "trash", 24.0, false, tl!("Delete")).clicked()
&& let Some(k) = selected.clone()
{
ev.push(Ev::Delete(k));
@@ -418,7 +418,7 @@ fn browser(
if crate::icons::button(ui, "plus", 24.0, false, new_tip).clicked() {
ev.push(Ev::New);
}
- if crate::icons::button(ui, "folder-plus", 24.0, false, "Create new group").clicked() {
+ if crate::icons::button(ui, "folder-plus", 24.0, false, tl!("Create new group")).clicked() {
ev.push(Ev::NewGroup);
}
});
@@ -495,7 +495,7 @@ pub fn gradients_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let canvas = app.last_canvas_rect;
let mut st = std::mem::take(&mut app.ui.presets_ui);
let max_h = (ui.available_height() - 40.0).clamp(90.0, 260.0);
- let events = browser(ui, &mut st, "gradients", &groups, Place { canvas, max_h, new_tip: "Create new gradient" }, &mut |ui, r, gi, ii| {
+ let events = browser(ui, &mut st, "gradients", &groups, Place { canvas, max_h, new_tip: tl!("Create new gradient") }, &mut |ui, r, gi, ii| {
let stops = groups_src[gi].items[ii].resolve(fg, bg);
paint_gradient(ui, r, &stops);
});
@@ -543,10 +543,11 @@ pub fn patterns_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut st = std::mem::take(&mut app.ui.presets_ui);
let max_h = (ui.available_height() - 40.0).clamp(90.0, 280.0);
let ctx = ui.ctx().clone();
- let events = browser(ui, &mut st, "patterns", &groups, Place { canvas, max_h, new_tip: "Create new pattern from the selection" }, &mut |ui, r, gi, ii| {
- let tex = pattern_texture(&ctx, &pats[gi][ii]);
- ui.painter().image(tex.id(), r, Rect::from_min_max(Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE);
- });
+ let events =
+ browser(ui, &mut st, "patterns", &groups, Place { canvas, max_h, new_tip: tl!("Create new pattern from the selection") }, &mut |ui, r, gi, ii| {
+ let tex = pattern_texture(&ctx, &pats[gi][ii]);
+ ui.painter().image(tex.id(), r, Rect::from_min_max(Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE);
+ });
app.ui.presets_ui = st;
for e in events {
match &e {
@@ -595,9 +596,9 @@ fn float_window(
ui.set_width(width);
// Photoshop-style tab header with a close box.
ui.horizontal(|ui| {
- ui.label(egui::RichText::new(title).color(t.text).size(12.0).strong());
+ ui.label(egui::RichText::new(tl!(&title)).color(t.text).size(12.0).strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
close = true;
}
});
@@ -612,16 +613,16 @@ fn float_window(
/// Draws the open floating panels (Styles, Shapes, Tool Presets, Clone Source).
pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
let p = app.ui.presets_ui.clone();
- if p.styles && float_window(app, ctx, "styles", "Styles", 250.0, 0.0, styles_panel) {
+ if p.styles && float_window(app, ctx, "styles", tl!("Styles"), 250.0, 0.0, styles_panel) {
app.ui.presets_ui.styles = false;
}
- if p.shapes && float_window(app, ctx, "shapes", "Shapes", 250.0, 280.0, shapes_panel) {
+ if p.shapes && float_window(app, ctx, "shapes", tl!("Shapes"), 250.0, 280.0, shapes_panel) {
app.ui.presets_ui.shapes = false;
}
- if p.tool_presets && float_window(app, ctx, "toolPresets", "Tool Presets", 250.0, 560.0, tool_presets_panel) {
+ if p.tool_presets && float_window(app, ctx, "toolPresets", tl!("Tool Presets"), 250.0, 560.0, tool_presets_panel) {
app.ui.presets_ui.tool_presets = false;
}
- if p.clone_source && float_window(app, ctx, "cloneSource", "Clone Source", 270.0, 840.0, clone_source_panel) {
+ if p.clone_source && float_window(app, ctx, "cloneSource", tl!("Clone Source"), 270.0, 840.0, clone_source_panel) {
app.ui.presets_ui.clone_source = false;
}
}
@@ -642,11 +643,17 @@ pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
for g in &src {
texes.push(g.items.iter().map(|s| style_texture(app, &ctx, s)).collect());
}
- let events =
- browser(ui, &mut st, "styles", &groups, Place { canvas, max_h: 300.0, new_tip: "Create new style from the selected layer" }, &mut |ui, r, gi, ii| {
+ let events = browser(
+ ui,
+ &mut st,
+ "styles",
+ &groups,
+ Place { canvas, max_h: 300.0, new_tip: tl!("Create new style from the selected layer") },
+ &mut |ui, r, gi, ii| {
ui.painter().rect_filled(r, 2.0, t.field);
ui.painter().image(texes[gi][ii].id(), r, Rect::from_min_max(Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE);
- });
+ },
+ );
app.ui.presets_ui = st;
let shift = ui.input(|i| i.modifiers.shift);
for e in events {
@@ -680,11 +687,17 @@ pub fn shapes_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut st = std::mem::take(&mut app.ui.presets_ui);
let ctx = ui.ctx().clone();
let t = Tokens::get(&ctx);
- let events =
- browser(ui, &mut st, "shapes", &groups, Place { canvas, max_h: 300.0, new_tip: "Create new shape from the current path" }, &mut |ui, r, gi, ii| {
+ let events = browser(
+ ui,
+ &mut st,
+ "shapes",
+ &groups,
+ Place { canvas, max_h: 300.0, new_tip: tl!("Create new shape from the current path") },
+ &mut |ui, r, gi, ii| {
let tex = shape_texture(&ctx, &src[gi].items[ii]);
ui.painter().image(tex.id(), r.shrink(2.0), Rect::from_min_max(Pos2::ZERO, pos2(1.0, 1.0)), t.text);
- });
+ },
+ );
app.ui.presets_ui = st;
let fill = shape_fill(app);
for e in events {
@@ -724,7 +737,7 @@ fn shape_fill(app: &PhotocraftApp) -> Value {
/// Options-bar shape picker for the Custom Shape tool.
pub fn shape_picker(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
- ui.label(egui::RichText::new("Shape:").color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!("Shape:")).color(t.text_dim).size(12.0));
let groups = photocraft_engine::presets::shapes::all_groups(&app.session);
let cur = app.ui.presets_ui.shape().to_string();
let ctx = ui.ctx().clone();
@@ -824,7 +837,7 @@ pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Rename field.
if let Some((_, key, mut text)) = app.ui.presets_ui.renaming.clone().filter(|r| r.0 == "toolPresets") {
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Name:").color(t.text_dim).size(11.5));
+ ui.label(egui::RichText::new(tl!("Name:")).color(t.text_dim).size(11.5));
let r = ui.add(egui::TextEdit::singleline(&mut text).desired_width(ui.available_width() - 4.0));
if !r.has_focus() && !r.lost_focus() {
r.request_focus();
@@ -842,7 +855,7 @@ pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
egui::ScrollArea::vertical().id_salt("tool-presets").max_height(260.0).auto_shrink([false, true]).show(ui, |ui| {
ui.spacing_mut().item_spacing.y = 0.0;
if items.is_empty() {
- empty(ui, if only { "No presets for the current tool." } else { "No tool presets." });
+ empty(ui, if only { tl!("No presets for the current tool.") } else { tl!("No tool presets.") });
}
for (name, tool) in &items {
let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 24.0), Sense::click());
@@ -858,11 +871,11 @@ pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
pick = Some(name.clone());
}
resp.context_menu(|ui| {
- if ui.button("Rename Tool Preset…").clicked() {
+ if ui.button(tl!("Rename Tool Preset…")).clicked() {
app.ui.presets_ui.renaming = Some(("toolPresets".into(), name.clone(), name.clone()));
ui.close();
}
- if ui.button("Delete Tool Preset").clicked() {
+ if ui.button(tl!("Delete Tool Preset")).clicked() {
action = Some(("tool.presets.edit".into(), json!({"action": "delete", "preset": name})));
ui.close();
}
@@ -872,14 +885,14 @@ pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.add_space(4.0);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
- crate::widgets::checkbox(ui, &mut app.ui.presets_ui.current_tool_only, "Current Tool Only");
+ crate::widgets::checkbox(ui, &mut app.ui.presets_ui.current_tool_only, tl!("Current Tool Only"));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 24.0, false, "Delete tool preset").clicked()
+ if crate::icons::button(ui, "trash", 24.0, false, tl!("Delete tool preset")).clicked()
&& let Some(n) = selected.clone()
{
action = Some(("tool.presets.edit".into(), json!({"action": "delete", "preset": n})));
}
- if crate::icons::button(ui, "plus", 24.0, false, "Create new tool preset").clicked() {
+ if crate::icons::button(ui, "plus", 24.0, false, tl!("Create new tool preset")).clicked() {
let label = cur.label().to_string();
let opts = json!({"toolOptions": serde_json::to_value(&app.ui.tool_options).unwrap_or_default()});
action = Some(("tool.presets.new".into(), json!({"name": label, "tool": tool_id(cur), "options": opts})));
@@ -916,7 +929,10 @@ pub fn clone_source_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let set = cs.slots[i].source.is_some();
let tip = match cs.slots[i].source {
Some(s) => format!("Clone source {}: {:.0}, {:.0}", i + 1, s[0], s[1]),
- None => format!("Clone source {} ({}-click with Clone Stamp to set)", i + 1, crate::shortcuts::pretty("Alt")),
+ None => crate::i18n::fmt(
+ tl!("Clone source {n} ({key}-click with Clone Stamp to set)"),
+ &[("n", &(i + 1).to_string()), ("key", &crate::shortcuts::pretty("Alt"))],
+ ),
};
let r = crate::icons::button(ui, "stamp", 30.0, cs.active == i, &tip);
if set {
@@ -933,7 +949,7 @@ pub fn clone_source_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
match (slot.source, slot.layer.and_then(|l| app.session.active().and_then(|d| d.doc.layer(photocraft_doc::LayerId(l)).map(|x| x.name.clone())))) {
(Some(_), Some(l)) => format!("Source: {} : {l}", app.session.active().map(|d| d.doc.name.clone()).unwrap_or_default()),
(Some(_), None) => "Source: set".to_string(),
- _ => format!("Source: not set ({}-click with Clone Stamp)", crate::shortcuts::pretty("Alt")),
+ _ => crate::i18n::fmt(tl!("Source: not set ({key}-click with Clone Stamp)"), &[("key", &crate::shortcuts::pretty("Alt"))]),
};
ui.label(egui::RichText::new(src_line).color(t.text_dim).size(11.0));
ui.add_space(4.0);
@@ -968,15 +984,15 @@ pub fn clone_source_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
action = Some(json!({"rotation": rot}));
}
ui.horizontal(|ui| {
- if crate::icons::button(ui, "arrow-left-right", 22.0, slot.flip_h, "Flip Horizontal").clicked() {
+ if crate::icons::button(ui, "arrow-left-right", 22.0, slot.flip_h, tl!("Flip Horizontal")).clicked() {
action = Some(json!({"flipH": !slot.flip_h}));
}
- if crate::icons::button(ui, "rotate-cw", 22.0, false, "Reset Transform").clicked() {
+ if crate::icons::button(ui, "rotate-cw", 22.0, false, tl!("Reset Transform")).clicked() {
run(app, "cloneSource.resetTransform", json!({}));
}
});
ui.horizontal(|ui| {
- if crate::icons::button(ui, "scaling", 22.0, slot.flip_v, "Flip Vertical").clicked() {
+ if crate::icons::button(ui, "scaling", 22.0, slot.flip_v, tl!("Flip Vertical")).clicked() {
action = Some(json!({"flipV": !slot.flip_v}));
}
});
@@ -991,20 +1007,24 @@ pub fn clone_source_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Overlay options.
let mut o = cs.overlay.clone();
let before = o.clone();
- crate::widgets::checkbox(ui, &mut o.show, "Show Overlay");
+ crate::widgets::checkbox(ui, &mut o.show, tl!("Show Overlay"));
ui.horizontal(|ui| {
ui.add_space(18.0);
- ui.label(egui::RichText::new("Opacity:").color(t.text_dim).size(11.5));
+ ui.label(egui::RichText::new(tl!("Opacity:")).color(t.text_dim).size(11.5));
crate::widgets::value_field(ui, &mut o.opacity, 0.0..=100.0, "%", 56.0);
- let opts =
- [("normal".to_string(), "Normal"), ("darken".to_string(), "Darken"), ("lighten".to_string(), "Lighten"), ("difference".to_string(), "Difference")];
+ let opts = [
+ ("normal".to_string(), tl!("Normal")),
+ ("darken".to_string(), tl!("Darken")),
+ ("lighten".to_string(), tl!("Lighten")),
+ ("difference".to_string(), tl!("Difference")),
+ ];
crate::widgets::dropdown(ui, "clone-overlay-mode", &mut o.blend, &opts, 90.0);
});
ui.horizontal(|ui| {
ui.add_space(18.0);
- crate::widgets::checkbox(ui, &mut o.clipped, "Clipped");
- crate::widgets::checkbox(ui, &mut o.auto_hide, "Auto Hide");
- crate::widgets::checkbox(ui, &mut o.invert, "Invert");
+ crate::widgets::checkbox(ui, &mut o.clipped, tl!("Clipped"));
+ crate::widgets::checkbox(ui, &mut o.auto_hide, tl!("Auto Hide"));
+ crate::widgets::checkbox(ui, &mut o.invert, tl!("Invert"));
});
if o != before {
run(
diff --git a/crates/ui-egui/src/props_layout.rs b/crates/ui-egui/src/props_layout.rs
index 5aac32cff..82557b5e6 100644
--- a/crates/ui-egui/src/props_layout.rs
+++ b/crates/ui-egui/src/props_layout.rs
@@ -46,7 +46,7 @@ pub fn header(ui: &mut egui::Ui, layer: &Layer) {
let icon_r = Rect::from_center_size(pos2(r.left() + 10.0, r.center().y), vec2(20.0, 20.0));
crate::icons::paint(ui, icon_r, kind_icon(&layer.content), 15.0, t.icon);
let kind = kind_label(layer);
- let kind_g = ui.painter().layout_no_wrap(kind.clone(), egui::FontId::proportional(11.0), t.text_faint);
+ let kind_g = ui.painter().layout_no_wrap(tl!(&kind).to_owned(), egui::FontId::proportional(11.0), t.text_faint);
let kind_w = kind_g.size().x;
// The name takes what's left between the icon and the kind (elided when long).
let name_x = r.left() + 26.0;
@@ -81,7 +81,7 @@ pub fn section(ui: &mut egui::Ui, id: &str, title: &str) -> bool {
11.0,
t.text_dim,
);
- ui.painter().text(pos2(r.left() + 18.0, r.center().y), egui::Align2::LEFT_CENTER, title, theme::semibold(12.0), t.text);
+ ui.painter().text(pos2(r.left() + 18.0, r.center().y), egui::Align2::LEFT_CENTER, tl!(title), theme::semibold(12.0), t.text);
if resp.clicked() {
open = !open;
ui.data_mut(|d| d.insert_temp(key, open));
diff --git a/crates/ui-egui/src/puppet_ui.rs b/crates/ui-egui/src/puppet_ui.rs
index 91d73061d..24f743983 100644
--- a/crates/ui-egui/src/puppet_ui.rs
+++ b/crates/ui-egui/src/puppet_ui.rs
@@ -177,7 +177,7 @@ pub fn control(app: &mut PhotocraftApp, ui: &Value) -> Result<Value, String> {
app.distort.puppet = None;
return Ok(json!({"cancelled": true}));
}
- let s = app.distort.puppet.as_mut().ok_or("Puppet Warp is not active")?;
+ let s = app.distort.puppet.as_mut().ok_or(tl!("Puppet Warp is not active"))?;
let mut remesh = false;
if let Some(m) = ui.get("mode").and_then(Value::as_str) {
s.warp.mode = PuppetMode::parse(m).ok_or("mode: rigid|normal|distort")?;
@@ -293,48 +293,48 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut remesh = false;
let mut resolve = false;
let mut rebind = false;
- ui.label("Mode:");
+ ui.label(tl!("Mode:"));
let mode = s.warp.mode;
crate::widgets::dropdown(
ui,
"puppet-mode",
&mut s.warp.mode,
- &[(PuppetMode::Rigid, "Rigid"), (PuppetMode::Normal, "Normal"), (PuppetMode::Distort, "Distort")],
+ &[(PuppetMode::Rigid, tl!("Rigid")), (PuppetMode::Normal, tl!("Normal")), (PuppetMode::Distort, tl!("Distort"))],
90.0,
);
resolve |= mode != s.warp.mode;
- ui.label("Density:");
+ ui.label(tl!("Density:"));
let density = s.warp.density;
crate::widgets::dropdown(
ui,
"puppet-density",
&mut s.warp.density,
- &[(PuppetDensity::Fewer, "Fewer Points"), (PuppetDensity::Normal, "Normal"), (PuppetDensity::More, "More Points")],
+ &[(PuppetDensity::Fewer, tl!("Fewer Points")), (PuppetDensity::Normal, tl!("Normal")), (PuppetDensity::More, tl!("More Points"))],
110.0,
);
remesh |= density != s.warp.density;
- ui.label("Expansion:");
+ ui.label(tl!("Expansion:"));
let mut e = s.warp.expansion as f32;
if crate::widgets::value_field(ui, &mut e, -50.0..=100.0, "px", 56.0).changed() {
s.warp.expansion = f64::from(e);
remesh = true;
}
- crate::widgets::checkbox(ui, &mut s.show_mesh, "Show Mesh");
+ crate::widgets::checkbox(ui, &mut s.show_mesh, tl!("Show Mesh"));
crate::widgets::vline(ui, 22.0);
if let Some(i) = s.selected.filter(|i| *i < s.warp.pins.len()) {
- ui.label("Pin Depth:");
- if ui.small_button("+").on_hover_text("Bring the selected pin forward").clicked() {
+ ui.label(tl!("Pin Depth:"));
+ if ui.small_button("+").on_hover_text(tl!("Bring the selected pin forward")).clicked() {
s.warp.pins[i].depth += 1;
resolve = true;
}
- if ui.small_button("−").on_hover_text("Send the selected pin backward").clicked() {
+ if ui.small_button("−").on_hover_text(tl!("Send the selected pin backward")).clicked() {
s.warp.pins[i].depth -= 1;
resolve = true;
}
- ui.label("Rotate:");
+ ui.label(tl!("Rotate:"));
let mut fixed = s.warp.pins[i].rotate.is_some();
let was = fixed;
- crate::widgets::dropdown(ui, "puppet-rotate", &mut fixed, &[(false, "Auto"), (true, "Fixed")], 70.0);
+ crate::widgets::dropdown(ui, "puppet-rotate", &mut fixed, &[(false, tl!("Auto")), (true, tl!("Fixed"))], 70.0);
if fixed != was {
s.warp.pins[i].rotate = fixed.then_some(0.0);
rebind = true;
@@ -348,7 +348,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
crate::widgets::vline(ui, 22.0);
}
- if ui.button("Remove All Pins").clicked() {
+ if ui.button(tl!("Remove All Pins")).clicked() {
s.warp.pins.clear();
s.selected = None;
rebind = true;
@@ -361,9 +361,12 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
s.solve(true);
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::widgets::primary_button(ui, "✓", 32.0).on_hover_text(format!("Commit Puppet Warp ({})", crate::shortcuts::pretty("Enter"))).clicked() {
+ if crate::widgets::primary_button(ui, "✓", 32.0)
+ .on_hover_text(crate::i18n::fmt(tl!("Commit Puppet Warp ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]))
+ .clicked()
+ {
commit(app);
- } else if crate::widgets::secondary_button(ui, "⊘", 32.0).on_hover_text("Cancel (Esc)").clicked() {
+ } else if crate::widgets::secondary_button(ui, "⊘", 32.0).on_hover_text(tl!("Cancel (Esc)")).clicked() {
app.distort.puppet = None;
}
});
diff --git a/crates/ui-egui/src/retouch_ui.rs b/crates/ui-egui/src/retouch_ui.rs
index eae4cb13e..2fe2bfb76 100644
--- a/crates/ui-egui/src/retouch_ui.rs
+++ b/crates/ui-egui/src/retouch_ui.rs
@@ -26,7 +26,7 @@ pub fn finish_stroke(app: &mut PhotocraftApp, tool: Tool, points: &[[f64; 3]], m
(Some(off), _) => p["offset"] = json!(off),
(None, Some(src)) => p["source"] = json!(src),
(None, None) => {
- app.ui.status = "Option-click to define a source point to clone from".into();
+ app.ui.status = tl!("Option-click to define a source point to clone from").into();
app.ui.status_error = true;
return true;
}
@@ -119,7 +119,7 @@ pub fn draw_source_marker(app: &PhotocraftApp, painter: &egui::Painter, xf: &Vie
fn opt(ui: &mut egui::Ui, text: &str) {
let t = Tokens::get(ui.ctx());
- ui.label(egui::RichText::new(text).color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!(&text)).color(t.text_dim).size(12.0));
}
fn pct(ui: &mut egui::Ui, label: &str, v: &mut f32) {
@@ -135,64 +135,68 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
let o = &mut app.ui.tool_options;
match tool {
Tool::SpotHealing => {
- opt(ui, "Type:");
- for (k, l) in [("contentAware", "Content-Aware"), ("createTexture", "Create Texture"), ("proximityMatch", "Proximity Match")] {
+ opt(ui, tl!("Type:"));
+ for (k, l) in [("contentAware", tl!("Content-Aware")), ("createTexture", tl!("Create Texture")), ("proximityMatch", tl!("Proximity Match"))] {
let mut on = o.spot_type == k;
if crate::widgets::checkbox(ui, &mut on, l).clicked() {
o.spot_type = k.into();
}
}
crate::widgets::vline(ui, 22.0);
- crate::widgets::checkbox(ui, &mut o.sample_all_layers, "Sample All Layers");
+ crate::widgets::checkbox(ui, &mut o.sample_all_layers, tl!("Sample All Layers"));
}
Tool::Healing | Tool::CloneStamp => {
- crate::widgets::checkbox(ui, &mut o.clone_aligned, "Aligned");
- opt(ui, "Sample:");
- let opts = [("current".to_string(), "Current Layer"), ("currentAndBelow".to_string(), "Current & Below"), ("all".to_string(), "All Layers")];
+ crate::widgets::checkbox(ui, &mut o.clone_aligned, tl!("Aligned"));
+ opt(ui, tl!("Sample:"));
+ let opts = [
+ ("current".to_string(), tl!("Current Layer")),
+ ("currentAndBelow".to_string(), tl!("Current & Below")),
+ ("all".to_string(), tl!("All Layers")),
+ ];
crate::widgets::dropdown(ui, "clone-sample", &mut o.clone_sample, &opts, 130.0);
if app.ui.clone_source.is_none() {
crate::widgets::vline(ui, 22.0);
- opt(ui, &format!("{}-click to set the source", crate::shortcuts::pretty("Alt")));
+ opt(ui, &crate::i18n::fmt(tl!("{key}-click to set the source"), &[("key", &crate::shortcuts::pretty("Alt"))]));
}
}
Tool::Dodge | Tool::Burn => {
- opt(ui, "Range:");
- let opts = [("shadows".to_string(), "Shadows"), ("midtones".to_string(), "Midtones"), ("highlights".to_string(), "Highlights")];
+ opt(ui, tl!("Range:"));
+ let opts = [("shadows".to_string(), tl!("Shadows")), ("midtones".to_string(), tl!("Midtones")), ("highlights".to_string(), tl!("Highlights"))];
crate::widgets::dropdown(ui, "tone-range", &mut o.tone_range, &opts, 100.0);
- pct(ui, "Exposure:", &mut o.exposure);
- crate::widgets::checkbox(ui, &mut o.protect_tones, "Protect Tones");
+ pct(ui, tl!("Exposure:"), &mut o.exposure);
+ crate::widgets::checkbox(ui, &mut o.protect_tones, tl!("Protect Tones"));
}
Tool::Sponge => {
- opt(ui, "Mode:");
- let opts = [("desaturate".to_string(), "Desaturate"), ("saturate".to_string(), "Saturate")];
+ opt(ui, tl!("Mode:"));
+ let opts = [("desaturate".to_string(), tl!("Desaturate")), ("saturate".to_string(), tl!("Saturate"))];
crate::widgets::dropdown(ui, "sponge-mode", &mut o.sponge_mode, &opts, 110.0);
- crate::widgets::checkbox(ui, &mut o.vibrance, "Vibrance");
+ crate::widgets::checkbox(ui, &mut o.vibrance, tl!("Vibrance"));
}
Tool::Blur | Tool::Sharpen | Tool::Smudge => {
- pct(ui, "Strength:", &mut o.strength);
- crate::widgets::checkbox(ui, &mut o.sample_all_layers, "Sample All Layers");
+ pct(ui, tl!("Strength:"), &mut o.strength);
+ crate::widgets::checkbox(ui, &mut o.sample_all_layers, tl!("Sample All Layers"));
if tool == Tool::Sharpen {
- crate::widgets::checkbox(ui, &mut o.protect_detail, "Protect Detail");
+ crate::widgets::checkbox(ui, &mut o.protect_detail, tl!("Protect Detail"));
}
if tool == Tool::Smudge {
- crate::widgets::checkbox(ui, &mut o.finger_painting, "Finger Painting");
+ crate::widgets::checkbox(ui, &mut o.finger_painting, tl!("Finger Painting"));
}
}
Tool::HistoryBrush => opt(ui, "Paints from the document's opening state"),
Tool::QuickSelection => {
- crate::widgets::checkbox(ui, &mut o.sample_all_layers, "Sample All Layers");
- crate::widgets::checkbox(ui, &mut o.enhance_edge, "Enhance Edge");
- opt(ui, &format!("{} to subtract", crate::shortcuts::pretty("Alt")));
+ crate::widgets::checkbox(ui, &mut o.sample_all_layers, tl!("Sample All Layers"));
+ crate::widgets::checkbox(ui, &mut o.enhance_edge, tl!("Enhance Edge"));
+ opt(ui, &crate::i18n::fmt(tl!("{key} to subtract"), &[("key", &crate::shortcuts::pretty("Alt"))]));
crate::widgets::vline(ui, 22.0);
- if crate::widgets::secondary_button(ui, "Select Subject", 0.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() {
let _ = app.run("select.subject", json!({}));
}
}
Tool::ObjectSelection => {
- crate::widgets::checkbox(ui, &mut o.sample_all_layers, "Sample All Layers");
- opt(ui, "Drag a rectangle around the object");
+ crate::widgets::checkbox(ui, &mut o.sample_all_layers, tl!("Sample All Layers"));
+ opt(ui, tl!("Drag a rectangle around the object"));
crate::widgets::vline(ui, 22.0);
- if crate::widgets::secondary_button(ui, "Select Subject", 0.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Select Subject"), 0.0).clicked() {
let _ = app.run("select.subject", json!({}));
}
}
diff --git a/crates/ui-egui/src/shortcuts.rs b/crates/ui-egui/src/shortcuts.rs
index 2e2a8ee27..40c20f27a 100644
--- a/crates/ui-egui/src/shortcuts.rs
+++ b/crates/ui-egui/src/shortcuts.rs
@@ -58,15 +58,17 @@ pub fn shortcut_label(app: &PhotocraftApp, command: &str) -> Option<String> {
effective_shortcut(app, command, default_shortcut(command).as_deref()).map(|s| pretty(&s))
}
-/// `label` followed by the command's effective shortcut (`New document… Ctrl+N`); bare
-/// `label` when the binding was removed.
+/// `label` (English, shown in the UI language) followed by the command's effective shortcut
+/// (`New document… Ctrl+N`); bare `label` when the binding was removed.
pub fn command_label(app: &PhotocraftApp, label: &str, command: &str) -> String {
+ let label = tl!(label);
shortcut_label(app, command).map_or_else(|| label.to_string(), |sc| format!("{label} {sc}"))
}
-/// `label` with the command's effective shortcut in parentheses (`Rulers (Ctrl+R)`); bare
-/// `label` when the binding was removed.
+/// `label` (English, shown in the UI language) with the command's effective shortcut in
+/// parentheses (`Rulers (Ctrl+R)`); bare `label` when the binding was removed.
pub fn tip_label(app: &PhotocraftApp, label: &str, command: &str) -> String {
+ let label = tl!(label);
shortcut_label(app, command).map_or_else(|| label.to_string(), |sc| format!("{label} ({sc})"))
}
diff --git a/crates/ui-egui/src/sizing.rs b/crates/ui-egui/src/sizing.rs
index f5ddf329f..bb29d4183 100644
--- a/crates/ui-egui/src/sizing.rs
+++ b/crates/ui-egui/src/sizing.rs
@@ -129,7 +129,7 @@ fn label(ui: &mut egui::Ui, text: &str, width: f32) {
fn info_row(ui: &mut egui::Ui, k: &str, v: String) {
let t = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
- label(ui, k, 90.0);
+ label(ui, tl!(k), 90.0);
ui.label(egui::RichText::new(v).color(t.text).size(12.0));
});
}
@@ -166,18 +166,18 @@ fn image_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let resample = f.get("resample").and_then(Value::as_str).unwrap_or("bicubic").to_string();
let resampling = resample != "none";
let (w, h) = (num(f, "width").round(), num(f, "height").round());
- info_row(ui, "Image Size:", format!("{} (was {})", human_bytes(w * h * bpp), human_bytes(ow * oh * bpp)));
- info_row(ui, "Dimensions:", format!("{} px × {} px", w as i64, h as i64));
+ info_row(ui, tl!("Image Size:"), format!("{} (was {})", human_bytes(w * h * bpp), human_bytes(ow * oh * bpp)));
+ info_row(ui, tl!("Dimensions:"), format!("{} px × {} px", w as i64, h as i64));
ui.add_space(6.0);
let mut constrain = f.get("__constrain").and_then(Value::as_bool).unwrap_or(true);
let w_row = ui.horizontal(|ui| {
- label(ui, "Width:", 90.0);
+ label(ui, tl!("Width:"), 90.0);
let c = dim_field(ui, f, "width", "__origW", "is-w");
unit_dropdown(ui, f, "is-unit-w");
c
});
let h_row = ui.horizontal(|ui| {
- label(ui, "Height:", 90.0);
+ label(ui, tl!("Height:"), 90.0);
let c = dim_field(ui, f, "height", "__origH", "is-h");
unit_dropdown(ui, f, "is-unit-h");
c
@@ -199,7 +199,7 @@ fn image_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let chain = Rect::from_center_size(pos2(bracket.left() + 8.0, bracket.center().y), vec2(14.0, 14.0));
ui.painter().rect_filled(chain, 2.0, if link.hovered() { t.hover } else { Color32::TRANSPARENT });
crate::icons::paint(ui, chain, if constrain { "link" } else { "unlink" }, 11.0, col);
- if link.on_hover_text("Constrain proportions").clicked() {
+ if link.on_hover_text(tl!("Constrain proportions")).clicked() {
constrain = !constrain;
f.insert("__constrain".into(), json!(constrain));
}
@@ -211,7 +211,7 @@ fn image_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
}
ui.horizontal(|ui| {
- label(ui, "Resolution:", 90.0);
+ label(ui, tl!("Resolution:"), 90.0);
let mut r = f.get("resolution").and_then(Value::as_f64).unwrap_or(72.0) as f32;
if crate::widgets::value_field(ui, &mut r, 1.0..=30000.0, "", 90.0).changed() {
let r = r.max(1.0) as f64;
@@ -222,13 +222,13 @@ fn image_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
f.insert("resolution".into(), json!(r));
}
- ui.label(egui::RichText::new("Pixels/Inch").color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!("Pixels/Inch")).color(t.text_dim).size(12.0));
});
ui.add_space(4.0);
ui.horizontal(|ui| {
label(ui, "", 90.0);
let mut on = resampling;
- if crate::widgets::checkbox(ui, &mut on, "Resample").changed() {
+ if crate::widgets::checkbox(ui, &mut on, tl!("Resample")).changed() {
f.insert("resample".into(), json!(if on { "bicubic" } else { "none" }));
if !on {
f.insert("width".into(), json!(ow));
@@ -238,11 +238,11 @@ fn image_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
if resampling {
let mut cur = resample.clone();
let opts = [
- ("preserveDetails".to_string(), "Preserve Details"),
- ("bicubic".to_string(), "Bicubic (smooth gradients)"),
- ("lanczos".to_string(), "Lanczos (sharp)"),
- ("bilinear".to_string(), "Bilinear"),
- ("nearest".to_string(), "Nearest Neighbor (hard edges)"),
+ ("preserveDetails".to_string(), tl!("Preserve Details")),
+ ("bicubic".to_string(), tl!("Bicubic (smooth gradients)")),
+ ("lanczos".to_string(), tl!("Lanczos (sharp)")),
+ ("bilinear".to_string(), tl!("Bilinear")),
+ ("nearest".to_string(), tl!("Nearest Neighbor (hard edges)")),
];
if crate::widgets::dropdown(ui, "is-resample", &mut cur, &opts, 200.0) {
f.insert("resample".into(), json!(cur));
@@ -256,32 +256,32 @@ fn canvas_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
let (ow, oh) = (num(f, "__origW"), num(f, "__origH"));
let bpp = num(f, "__bytesPerPixel").max(1.0);
let relative = f.get("relative").and_then(Value::as_bool).unwrap_or(false);
- ui.label(egui::RichText::new("Current Size").font(crate::theme::semibold(12.0)).color(t.text));
- info_row(ui, "Size:", human_bytes(ow * oh * bpp));
- info_row(ui, "Width:", format!("{} px", ow as i64));
- info_row(ui, "Height:", format!("{} px", oh as i64));
+ ui.label(egui::RichText::new(tl!("Current Size")).font(crate::theme::semibold(12.0)).color(t.text));
+ info_row(ui, tl!("Size:"), human_bytes(ow * oh * bpp));
+ info_row(ui, tl!("Width:"), format!("{} px", ow as i64));
+ info_row(ui, tl!("Height:"), format!("{} px", oh as i64));
ui.add_space(6.0);
crate::widgets::hairline(ui);
ui.add_space(6.0);
let (nw, nh) = if relative { (ow + num(f, "width"), oh + num(f, "height")) } else { (num(f, "width"), num(f, "height")) };
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("New Size").font(crate::theme::semibold(12.0)).color(t.text));
+ ui.label(egui::RichText::new(tl!("New Size")).font(crate::theme::semibold(12.0)).color(t.text));
ui.label(egui::RichText::new(human_bytes(nw.max(0.0) * nh.max(0.0) * bpp)).color(t.text_dim).size(12.0));
});
ui.horizontal(|ui| {
- label(ui, "Width:", 90.0);
+ label(ui, tl!("Width:"), 90.0);
dim_field(ui, f, "width", "__origW", "cs-w");
unit_dropdown(ui, f, "cs-unit-w");
});
ui.horizontal(|ui| {
- label(ui, "Height:", 90.0);
+ label(ui, tl!("Height:"), 90.0);
dim_field(ui, f, "height", "__origH", "cs-h");
unit_dropdown(ui, f, "cs-unit-h");
});
ui.horizontal(|ui| {
label(ui, "", 90.0);
let mut rel = relative;
- if crate::widgets::checkbox(ui, &mut rel, "Relative").changed() {
+ if crate::widgets::checkbox(ui, &mut rel, tl!("Relative")).changed() {
// Convert between absolute and delta so the resulting canvas is unchanged.
let (w, h) = (num(f, "width"), num(f, "height"));
let (w, h) = if rel { (w - ow, h - oh) } else { (w + ow, h + oh) };
@@ -291,7 +291,7 @@ fn canvas_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
}
});
ui.horizontal(|ui| {
- label(ui, "Anchor:", 90.0);
+ label(ui, tl!("Anchor:"), 90.0);
let cur = f.get("anchor").and_then(Value::as_str).unwrap_or("center").to_string();
if let Some(a) = anchor_grid(ui, &cur, nw - ow, nh - oh) {
f.insert("anchor".into(), json!(a));
@@ -299,14 +299,14 @@ fn canvas_size(ui: &mut egui::Ui, f: &mut Map<String, Value>) {
});
ui.add_space(4.0);
ui.horizontal(|ui| {
- label(ui, "Canvas extension color:", 150.0);
+ label(ui, tl!("Canvas extension color:"), 150.0);
let mut cur = f.get("extensionColor").and_then(Value::as_str).unwrap_or("background").to_string();
let opts = [
- ("foreground".to_string(), "Foreground"),
- ("background".to_string(), "Background"),
- ("white".to_string(), "White"),
- ("black".to_string(), "Black"),
- ("transparent".to_string(), "Transparent"),
+ ("foreground".to_string(), tl!("Foreground")),
+ ("background".to_string(), tl!("Background")),
+ ("white".to_string(), tl!("White")),
+ ("black".to_string(), tl!("Black")),
+ ("transparent".to_string(), tl!("Transparent")),
];
if crate::widgets::dropdown(ui, "cs-ext", &mut cur, &opts, 140.0) {
f.insert("extensionColor".into(), json!(cur));
diff --git a/crates/ui-egui/src/slice_ui.rs b/crates/ui-egui/src/slice_ui.rs
index 6bcc1d6fa..1e75bbd71 100644
--- a/crates/ui-egui/src/slice_ui.rs
+++ b/crates/ui-egui/src/slice_ui.rs
@@ -249,36 +249,36 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
let locked = app.session.file_menu.slices_locked;
let t = crate::theme::Tokens::get(ui.ctx());
if tool == Tool::Slice {
- ui.label(egui::RichText::new("Style: Normal").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Style: Normal")).color(t.text_dim));
crate::widgets::vline(ui, 22.0);
- if ui.add_enabled_ui(has_doc && !locked, |ui| crate::widgets::secondary_button(ui, "Slices From Guides", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(has_doc && !locked, |ui| crate::widgets::secondary_button(ui, tl!("Slices From Guides"), 0.0)).inner.clicked() {
let _ = app.run("slice.fromGuides", json!({}));
}
} else {
let sel = app.ui.slices.selected.is_some();
let stored =
sel && app.session.active().is_some_and(|d| slices::resolve(&d.doc).iter().any(|r| Some(r.number) == app.ui.slices.selected && r.id.is_some()));
- if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, "Promote", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, tl!("Promote"), 0.0)).inner.clicked() {
let _ = selected_id(app, true).map(|id| app.run("slice.promote", json!({"slice": id})));
}
- if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, "Divide…", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, tl!("Divide…"), 0.0)).inner.clicked() {
let _ = open_divide(app);
}
- if ui.add_enabled_ui(stored && !locked, |ui| crate::widgets::secondary_button(ui, "Delete", 0.0)).inner.clicked()
+ if ui.add_enabled_ui(stored && !locked, |ui| crate::widgets::secondary_button(ui, tl!("Delete"), 0.0)).inner.clicked()
&& let Some(id) = selected_id(app, false)
&& app.run("slice.delete", json!({"slice": id})).is_ok()
{
app.ui.slices.selected = None;
}
crate::widgets::vline(ui, 22.0);
- crate::widgets::checkbox(ui, &mut app.ui.slices.hide_auto, "Hide Auto Slices");
+ crate::widgets::checkbox(ui, &mut app.ui.slices.hide_auto, tl!("Hide Auto Slices"));
crate::widgets::vline(ui, 22.0);
- if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, "Slice Options…", 0.0)).inner.clicked() {
+ if ui.add_enabled_ui(sel && !locked, |ui| crate::widgets::secondary_button(ui, tl!("Slice Options…"), 0.0)).inner.clicked() {
let _ = open_options(app);
}
}
if locked {
- ui.label(egui::RichText::new("Slices are locked (View › Lock Slices)").color(t.text_dim).size(11.0));
+ ui.label(egui::RichText::new(tl!("Slices are locked (View › Lock Slices)")).color(t.text_dim).size(11.0));
}
true
}
diff --git a/crates/ui-egui/src/tab_strip.rs b/crates/ui-egui/src/tab_strip.rs
index 8cadfca38..b1bce70e8 100644
--- a/crates/ui-egui/src/tab_strip.rs
+++ b/crates/ui-egui/src/tab_strip.rs
@@ -112,6 +112,9 @@ fn tabs_in(
mut paint_tab: impl FnMut(&Ui, Rect, usize, std::sync::Arc<egui::Galley>, &Response, bool),
) -> StripOut {
let t = Tokens::get(ui.ctx());
+ // Panel names are English keys; draw them in the UI language.
+ let names: Vec<&str> = tabs.iter().map(|n| tl!(n)).collect();
+ let tabs = names.as_slice();
let natural: Vec<f32> = tabs.iter().map(|n| ui.painter().layout_no_wrap((*n).to_owned(), font.clone(), t.text).size().x + pad).collect();
let f = fit(&natural, *selected, area.width(), min_w, CHEVRON_W);
let mut x = area.left();
@@ -139,8 +142,8 @@ fn tabs_in(
ui.painter().rect_filled(r.shrink2(vec2(1.0, 3.0)), t.radius_sm, t.hover.gamma_multiply(0.6));
}
crate::icons::paint(ui, r, "chevrons-right", 12.0, if resp.hovered() { t.text } else { t.text_dim });
- resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "More panels"));
- let resp = resp.on_hover_text("More panels");
+ resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, tl!("More panels")));
+ let resp = resp.on_hover_text(tl!("More panels"));
egui::Popup::menu(&resp).show(|ui| {
ui.set_min_width(140.0);
for &i in &f.overflow {
diff --git a/crates/ui-egui/src/timeline_ui.rs b/crates/ui-egui/src/timeline_ui.rs
index b21dfc3fc..22d8408ab 100644
--- a/crates/ui-egui/src/timeline_ui.rs
+++ b/crates/ui-egui/src/timeline_ui.rs
@@ -52,11 +52,11 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
let playing = app.ui.timeline.playing;
let t = Tokens::get(ctx);
- crate::analysis_ui::panel_window(app, ctx, "timeline", "Timeline", vec2(0.0, 520.0), 660.0, |ui| {
+ crate::analysis_ui::panel_window(app, ctx, "timeline", tl!("Timeline"), vec2(0.0, 520.0), 660.0, |ui| {
ui.horizontal(|ui| {
- ui.label(RichText::new("Timeline").strong().color(t.text));
+ ui.label(RichText::new(tl!("Timeline")).strong().color(t.text));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
close = true;
}
});
@@ -64,37 +64,44 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.separator();
if !have_doc {
- ui.weak("Open a document to use the timeline.");
+ ui.weak(tl!("Open a document to use the timeline."));
return;
}
match &tl {
None => {
ui.add_space(8.0);
ui.vertical_centered(|ui| {
- if crate::widgets::primary_button(ui, "Create Video Timeline", 200.0).clicked() {
+ if crate::widgets::primary_button(ui, tl!("Create Video Timeline"), 200.0).clicked() {
act = Some(("timeline.create", json!({ "duration": 30, "fps": 30.0 })));
}
ui.add_space(4.0);
- ui.weak("30 frames @ 30 fps");
+ ui.weak(tl!("30 frames @ 30 fps"));
});
}
Some(tl) => {
ui.horizontal(|ui| {
let play_icon = if playing { "pause" } else { "play" };
- if crate::icons::button(ui, play_icon, 22.0, playing, if playing { "Pause" } else { "Play" }).clicked() {
+ if crate::icons::button(ui, play_icon, 22.0, playing, if playing { tl!("Pause") } else { tl!("Play") }).clicked() {
toggle_play = true;
}
- if crate::icons::button(ui, "chevron-left", 22.0, false, "Previous frame").clicked() {
+ if crate::icons::button(ui, "chevron-left", 22.0, false, tl!("Previous frame")).clicked() {
act = Some(("timeline.previousFrame", json!({})));
}
- ui.label(RichText::new(format!("Frame {} / {}", tl.current + 1, tl.duration)).color(t.text).monospace());
- if crate::icons::button(ui, "chevron-right", 22.0, false, "Next frame").clicked() {
+ ui.label(
+ RichText::new(crate::i18n::fmt(
+ crate::i18n::t("Frame {current} / {total}"),
+ &[("current", &(tl.current + 1).to_string()), ("total", &tl.duration.to_string())],
+ ))
+ .color(t.text)
+ .monospace(),
+ );
+ if crate::icons::button(ui, "chevron-right", 22.0, false, tl!("Next frame")).clicked() {
act = Some(("timeline.nextFrame", json!({})));
}
ui.separator();
ui.label(RichText::new(format!("{:.2}s", tl.time())).color(t.text_dim).monospace());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 20.0, false, "Delete Timeline").clicked() {
+ if crate::icons::button(ui, "trash", 20.0, false, tl!("Delete Timeline")).clicked() {
act = Some(("timeline.delete", json!({})));
}
ui.label(RichText::new(format!("{:.0} fps", tl.fps)).color(t.text_dim));
diff --git a/crates/ui-egui/src/tone.rs b/crates/ui-egui/src/tone.rs
index 61f6f55ff..06a7951b9 100644
--- a/crates/ui-egui/src/tone.rs
+++ b/crates/ui-egui/src/tone.rs
@@ -207,7 +207,7 @@ fn channel_picker(ui: &mut egui::Ui, id: egui::Id, label: &str) -> usize {
let mut ch: usize = ui.data(|d| d.get_temp(id)).unwrap_or(0);
ui.horizontal(|ui| {
let t = Tokens::get(ui.ctx());
- ui.label(egui::RichText::new(label).color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim).size(12.0));
let opts: Vec<(usize, &str)> = CHANNELS.iter().enumerate().map(|(i, (_, l))| (i, *l)).collect();
crate::widgets::dropdown(ui, &format!("{id:?}-ch"), &mut ch, &opts, 110.0);
});
@@ -223,7 +223,7 @@ fn channel_picker(ui: &mut egui::Ui, id: egui::Id, label: &str) -> usize {
pub fn histogram_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- ui.label(egui::RichText::new("No document").color(t.text_faint));
+ ui.label(egui::RichText::new(tl!("No document")).color(t.text_faint));
return;
};
let (doc_id, rev) = (st.doc.id, st.revision);
@@ -275,11 +275,11 @@ pub fn histogram_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.add_space(4.0);
egui::Grid::new("hist-stats").num_columns(2).spacing(vec2(12.0, 2.0)).show(ui, |ui| {
for (k, v) in [
- ("Mean:", format!("{mean:.2}")),
- ("Std Dev:", format!("{:.2}", var.sqrt())),
- ("Median:", median.unwrap_or(0).to_string()),
- ("Pixels:", (size.width as u64 * size.height as u64).to_string()),
- ("Cache Level:", level.to_string()),
+ (tl!("Mean:"), format!("{mean:.2}")),
+ (tl!("Std Dev:"), format!("{:.2}", var.sqrt())),
+ (tl!("Median:"), median.unwrap_or(0).to_string()),
+ (tl!("Pixels:"), (size.width as u64 * size.height as u64).to_string()),
+ (tl!("Cache Level:"), level.to_string()),
] {
ui.label(egui::RichText::new(k).color(t.text_dim).size(11.5));
ui.label(egui::RichText::new(v).font(crate::theme::mono(11.5)).color(t.text));
diff --git a/crates/ui-egui/src/transform_tool.rs b/crates/ui-egui/src/transform_tool.rs
index a0c319243..f9f02d932 100644
--- a/crates/ui-egui/src/transform_tool.rs
+++ b/crates/ui-egui/src/transform_tool.rs
@@ -840,7 +840,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let rw = crate::widgets::value_field(ui, &mut w, -10000.0..=10000.0, "%", 66.0);
let link_id = egui::Id::new("transform-link");
let mut link: bool = ui.data(|d| d.get_temp(link_id)).unwrap_or(true);
- if crate::icons::button(ui, if link { "link" } else { "unlink" }, 22.0, link, "Maintain aspect ratio").clicked() {
+ if crate::icons::button(ui, if link { "link" } else { "unlink" }, 22.0, link, tl!("Maintain aspect ratio")).clicked() {
link = !link;
ui.data_mut(|d| d.insert_temp(link_id, link));
}
@@ -859,14 +859,14 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut a = angle as f32;
let (r, resp) = ui.allocate_exact_size(vec2(18.0, 22.0), egui::Sense::hover());
crate::icons::paint(ui, r, "rotate-cw", 13.0, tk.text_dim);
- resp.on_hover_text("Rotate");
+ resp.on_hover_text(tl!("Rotate"));
if crate::widgets::value_field(ui, &mut a, -180.0..=180.0, "°", 60.0).changed() {
rotate_about_pivot(app, (a as f64 - angle).to_radians());
}
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Interpolation:");
+ lbl(ui, tl!("Interpolation:"));
let mut interp = t.interpolation.clone();
- let opts = [("bicubic".to_string(), "Bicubic"), ("bilinear".to_string(), "Bilinear"), ("nearest".to_string(), "Nearest Neighbor")];
+ let opts = [("bicubic".to_string(), tl!("Bicubic")), ("bilinear".to_string(), tl!("Bilinear")), ("nearest".to_string(), tl!("Nearest Neighbor"))];
if crate::widgets::dropdown(ui, "transform-interp", &mut interp, &opts, 130.0)
&& let Some(s) = app.ui.transform.as_mut()
{
@@ -874,14 +874,16 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_space(8.0);
- if crate::icons::button(ui, "check", 24.0, false, &format!("Commit transform ({})", crate::shortcuts::pretty("Enter"))).clicked() {
+ if crate::icons::button(ui, "check", 24.0, false, &crate::i18n::fmt(tl!("Commit transform ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]))
+ .clicked()
+ {
commit(app);
}
- if crate::icons::button(ui, "ban", 24.0, false, "Cancel transform (Esc)").clicked() {
+ if crate::icons::button(ui, "ban", 24.0, false, tl!("Cancel transform (Esc)")).clicked() {
cancel(app);
}
crate::widgets::vline(ui, 22.0);
- if crate::icons::button(ui, "grid-3x3", 24.0, false, "Switch between free transform and warp modes").clicked() {
+ if crate::icons::button(ui, "grid-3x3", 24.0, false, tl!("Switch between free transform and warp modes")).clicked() {
enter_warp(app);
}
});
@@ -893,7 +895,7 @@ fn warp_options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {
let lbl = |ui: &mut egui::Ui, s: &str| {
ui.label(egui::RichText::new(s).color(tk.text_dim).size(12.0));
};
- lbl(ui, "Warp:");
+ lbl(ui, tl!("Warp:"));
let mut style = w.style;
let opts: Vec<(WarpStyle, &str)> = WarpStyle::all().map(|s| (s, s.label())).collect();
if crate::widgets::dropdown(ui, "warp-style", &mut style, &opts, 120.0)
@@ -908,12 +910,12 @@ fn warp_options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {
}
if w.style.is_preset() {
let mut vertical = w.vertical;
- if crate::widgets::checkbox(ui, &mut vertical, "Vertical").changed()
+ if crate::widgets::checkbox(ui, &mut vertical, tl!("Vertical")).changed()
&& let Some(Some(cur)) = app.ui.transform.as_mut().map(|t| t.warp.as_mut())
{
cur.vertical = vertical;
}
- let fields: [(&str, f64); 3] = [("Bend:", w.bend), ("H:", w.h_distort), ("V:", w.v_distort)];
+ let fields: [(&str, f64); 3] = [(tl!("Bend:"), w.bend), ("H:", w.h_distort), ("V:", w.v_distort)];
for (k, (name, v)) in fields.iter().enumerate() {
lbl(ui, name);
let mut f = *v as f32;
@@ -929,12 +931,12 @@ fn warp_options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {
}
} else {
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Split:");
+ lbl(ui, tl!("Split:"));
for (id, label) in [
("edit.transform.splitWarpCrosswise", "Crosswise"),
("edit.transform.splitWarpVertically", "Vertical"),
("edit.transform.splitWarpHorizontally", "Horizontal"),
- ("edit.transform.removeWarpSplit", "Remove"),
+ ("edit.transform.removeWarpSplit", tl!("Remove")),
] {
if crate::widgets::secondary_button(ui, label, 0.0).clicked()
&& let Err(e) = split(app, id, None)
@@ -945,14 +947,16 @@ fn warp_options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, w: &Warp) {
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_space(8.0);
- if crate::icons::button(ui, "check", 24.0, false, &format!("Commit warp ({})", crate::shortcuts::pretty("Enter"))).clicked() {
+ if crate::icons::button(ui, "check", 24.0, false, &crate::i18n::fmt(tl!("Commit warp ({key})"), &[("key", &crate::shortcuts::pretty("Enter"))]))
+ .clicked()
+ {
commit(app);
}
- if crate::icons::button(ui, "ban", 24.0, false, "Cancel warp (Esc)").clicked() {
+ if crate::icons::button(ui, "ban", 24.0, false, tl!("Cancel warp (Esc)")).clicked() {
cancel(app);
}
crate::widgets::vline(ui, 22.0);
- if crate::icons::button(ui, "grid-3x3", 24.0, true, "Switch between free transform and warp modes").clicked() {
+ if crate::icons::button(ui, "grid-3x3", 24.0, true, tl!("Switch between free transform and warp modes")).clicked() {
leave_warp(app);
}
});
diff --git a/crates/ui-egui/src/type_panels_ui.rs b/crates/ui-egui/src/type_panels_ui.rs
index ca020bd9a..47d626eef 100644
--- a/crates/ui-egui/src/type_panels_ui.rs
+++ b/crates/ui-egui/src/type_panels_ui.rs
@@ -144,7 +144,7 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
let canvas = app.last_canvas_rect;
if app.ui.type_panels.styles {
let mut close = false;
- egui::Window::new("Type Styles")
+ egui::Window::new(tl!("Type Styles"))
.id(egui::Id::new("type-styles-window"))
.title_bar(false)
.resizable(false)
@@ -154,7 +154,7 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui.set_width(290.0);
ui.horizontal(|ui| {
let mut tab = app.ui.type_panels.styles_tab;
- for (i, name) in ["Character Styles", "Paragraph Styles"].iter().enumerate() {
+ for (i, name) in [tl!("Character Styles"), tl!("Paragraph Styles")].iter().enumerate() {
if crate::widgets::pill_tab(ui, name, tab == i).clicked() {
tab = i;
}
@@ -164,7 +164,7 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
app.ui.type_panels.options = None;
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
close = true;
}
});
@@ -179,7 +179,7 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
if app.ui.type_panels.glyphs {
let mut close = false;
- egui::Window::new("Glyphs")
+ egui::Window::new(tl!("Glyphs"))
.id(egui::Id::new("glyphs-window"))
.title_bar(false)
.resizable(false)
@@ -188,9 +188,9 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
.show(ctx, |ui| {
ui.set_width(340.0);
ui.horizontal(|ui| {
- ui.label(RichText::new("Glyphs").color(t.text).size(12.0).strong());
+ ui.label(RichText::new(tl!("Glyphs")).color(t.text).size(12.0).strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 20.0, false, "Close").clicked() {
+ if crate::icons::button(ui, "x", 20.0, false, tl!("Close")).clicked() {
close = true;
}
});
@@ -213,7 +213,7 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool) {
let t = Tokens::get(ui.ctx());
if app.session.active().is_none() {
- ui.label(RichText::new("No document").color(t.text_faint).size(11.5));
+ ui.label(RichText::new(tl!("No document")).color(t.text_faint).size(11.5));
return;
}
let prefix = if paragraph { "type.paragraphStyle" } else { "type.characterStyle" };
@@ -255,7 +255,7 @@ pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool)
p["id"] = json!(id);
p["clearOverrides"] = json!(alt);
if !paragraph && p.get("range").and_then(Value::as_array).is_some_and(|r| r[0] == r[1]) {
- app.ui.status = "Select text to apply a character style".into();
+ app.ui.status = tl!("Select text to apply a character style").into();
app.ui.status_error = false;
} else {
action = Some((format!("{prefix}.apply"), p));
@@ -266,9 +266,12 @@ pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool)
}
}
resp.on_hover_text(if id == 0 && !paragraph {
- "No character style".to_string()
+ tl!("No character style").to_string()
} else {
- format!("Click to apply, {}-click to clear overrides, double-click for Style Options", crate::shortcuts::pretty("Alt"))
+ crate::i18n::fmt(
+ tl!("Click to apply, {key}-click to clear overrides, double-click for Style Options"),
+ &[("key", &crate::shortcuts::pretty("Alt"))],
+ )
});
}
});
@@ -278,33 +281,33 @@ pub fn styles_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool)
let sel = selected.filter(|i| *i != 0 || paragraph);
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
- if crate::icons::button(ui, "ban", 22.0, false, "Clear Override").clicked() && has_target && over {
+ if crate::icons::button(ui, "ban", 22.0, false, tl!("Clear Override")).clicked() && has_target && over {
action = Some((format!("{prefix}.clearOverride"), tgt.clone()));
}
- if crate::icons::button(ui, "check", 22.0, false, "Redefine style by current selection").clicked()
+ if crate::icons::button(ui, "check", 22.0, false, tl!("Redefine style by current selection")).clicked()
&& has_target
&& cur_id.is_some_and(|i| i != 0 || paragraph)
{
action = Some((format!("{prefix}.redefine"), tgt.clone()));
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "trash", 22.0, false, "Delete style").clicked()
+ if crate::icons::button(ui, "trash", 22.0, false, tl!("Delete style")).clicked()
&& let Some(id) = sel.filter(|i| *i != 0)
{
action = Some((format!("{prefix}.delete"), json!({ "id": id })));
app.ui.type_panels.options = None;
}
- if crate::icons::button(ui, "plus", 22.0, false, "Create new style (from the selected type)").clicked() {
+ if crate::icons::button(ui, "plus", 22.0, false, tl!("Create new style (from the selected type)")).clicked() {
let mut p = tgt.clone();
p["fromSelection"] = json!(has_target);
action = Some((format!("{prefix}.new"), p));
}
- if crate::icons::button(ui, "copy", 22.0, false, "Duplicate style").clicked()
+ if crate::icons::button(ui, "copy", 22.0, false, tl!("Duplicate style")).clicked()
&& let Some(id) = sel
{
action = Some((format!("{prefix}.duplicate"), json!({ "id": id })));
}
- if crate::icons::button(ui, "settings", 22.0, false, "Style Options…").clicked()
+ if crate::icons::button(ui, "settings", 22.0, false, tl!("Style Options…")).clicked()
&& let Some(id) = sel
{
app.ui.type_panels.options = Some((paragraph, id as u32));
@@ -344,9 +347,9 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s
let mut clear: Vec<&str> = Vec::new();
ui.add_space(4.0);
ui.horizontal(|ui| {
- ui.label(RichText::new("Style Options").color(t.text).size(11.5).strong());
+ ui.label(RichText::new(tl!("Style Options")).color(t.text).size(11.5).strong());
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
- if crate::icons::button(ui, "x", 18.0, false, "Close Style Options").clicked() {
+ if crate::icons::button(ui, "x", 18.0, false, tl!("Close Style Options")).clicked() {
app.ui.type_panels.options = None;
}
});
@@ -355,7 +358,7 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s
let key = egui::Id::new(("style-name", paragraph, id));
let mut name: String = ui.data(|d| d.get_temp(key)).unwrap_or_else(|| s["name"].as_str().unwrap_or("").to_string());
ui.horizontal(|ui| {
- ui.label(RichText::new("Name").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Name")).color(t.text_dim).size(11.5));
let r = ui.add_enabled(id != 0, egui::TextEdit::singleline(&mut name).desired_width(170.0));
if r.lost_focus() && name.trim() != s["name"].as_str().unwrap_or("") && !name.trim().is_empty() {
let _ = run(app, &format!("{prefix}.rename"), json!({ "id": id, "name": name.trim() }));
@@ -368,22 +371,22 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s
egui::Grid::new(("style-opts", paragraph, id)).num_columns(3).spacing([6.0, 3.0]).show(ui, |ui| {
// (label, model key, panel key, kind)
let rows: &[(&str, &str, &str, &str)] = &[
- ("Font", "font_family", "font", "font"),
- ("Size", "size_pt", "size", "pt"),
- ("Leading", "leading_pt", "leading", "leading"),
- ("Tracking", "tracking", "tracking", "num"),
- ("Baseline", "baseline_shift_pt", "baselineShift", "pt"),
- ("Color", "color", "color", "color"),
- ("Faux Bold", "faux_bold", "fauxBold", "bool"),
- ("Faux Italic", "faux_italic", "fauxItalic", "bool"),
- ("Underline", "underline", "underline", "bool"),
- ("Strikethrough", "strikethrough", "strikethrough", "bool"),
+ (tl!("Font"), "font_family", "font", "font"),
+ (tl!("Size"), "size_pt", "size", "pt"),
+ (tl!("Leading"), "leading_pt", "leading", "leading"),
+ (tl!("Tracking"), "tracking", "tracking", "num"),
+ (tl!("Baseline"), "baseline_shift_pt", "baselineShift", "pt"),
+ (tl!("Color"), "color", "color", "color"),
+ (tl!("Faux Bold"), "faux_bold", "fauxBold", "bool"),
+ (tl!("Faux Italic"), "faux_italic", "fauxItalic", "bool"),
+ (tl!("Underline"), "underline", "underline", "bool"),
+ (tl!("Strikethrough"), "strikethrough", "strikethrough", "bool"),
];
for &(label, key, panel, kind) in rows {
let mut on = defined(&char_attrs, key);
let was = on;
ui.checkbox(&mut on, "");
- ui.label(RichText::new(label).color(if on { t.text } else { t.text_faint }).size(11.5));
+ ui.label(RichText::new(tl!(&label)).color(if on { t.text } else { t.text_faint }).size(11.5));
let v = if on { char_attrs[key].clone() } else { resolved_c[key].clone() };
ui.add_enabled_ui(on, |ui| match kind {
"font" => {
@@ -398,7 +401,7 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s
let range = if kind == "num" { -1000.0..=10000.0 } else { -1296.0..=1296.0 };
let unit = if kind == "num" { "" } else { " pt" };
if auto {
- ui.label(RichText::new("Auto").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Auto")).color(t.text_dim).size(11.5));
} else if crate::widgets::value_field(ui, &mut x, range, unit, 70.0).changed() {
set = Some(json!({ key: x }));
}
@@ -430,24 +433,25 @@ fn options_editor(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bool, s
}
if paragraph {
let rows: &[(&str, &str, &str)] = &[
- ("Align", "align", "align"),
- ("Indent First", "first_line_indent_pt", "pt"),
- ("Indent Left", "start_indent_pt", "pt"),
- ("Indent Right", "end_indent_pt", "pt"),
- ("Space Before", "space_before_pt", "pt"),
- ("Space After", "space_after_pt", "pt"),
- ("Hyphenate", "hyphenate", "bool"),
+ (tl!("Align"), "align", "align"),
+ (tl!("Indent First"), "first_line_indent_pt", "pt"),
+ (tl!("Indent Left"), "start_indent_pt", "pt"),
+ (tl!("Indent Right"), "end_indent_pt", "pt"),
+ (tl!("Space Before"), "space_before_pt", "pt"),
+ (tl!("Space After"), "space_after_pt", "pt"),
+ (tl!("Hyphenate"), "hyphenate", "bool"),
];
for &(label, key, kind) in rows {
let mut on = defined(&para_attrs, key);
let was = on;
ui.checkbox(&mut on, "");
- ui.label(RichText::new(label).color(if on { t.text } else { t.text_faint }).size(11.5));
+ ui.label(RichText::new(tl!(&label)).color(if on { t.text } else { t.text_faint }).size(11.5));
let v = if on { para_attrs[key].clone() } else { resolved_p[key].clone() };
ui.add_enabled_ui(on, |ui| match kind {
"align" => {
let mut a = v.as_str().unwrap_or("Left").to_string();
- let opts = ["Left", "Center", "Right", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyAll"].map(|o| (o.to_string(), o));
+ let opts = [tl!("Left"), tl!("Center"), tl!("Right"), "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyAll"]
+ .map(|o| (o.to_string(), o));
let opts: Vec<(String, &str)> = opts.to_vec();
if crate::widgets::dropdown(ui, &format!("style-align-{id}"), &mut a, &opts, 110.0) {
set = Some(json!({ "align": a }));
@@ -496,7 +500,7 @@ fn family_picker(ui: &mut egui::Ui, salt: &str, current: &mut String) -> bool {
let shown = if current.is_empty() { photocraft_text::fonts::DEFAULT_FAMILY.to_string() } else { current.clone() };
egui::ComboBox::from_id_salt(salt).selected_text(shown.clone()).width(140.0).height(360.0).icon(crate::widgets::chevron_icon).show_ui(ui, |ui| {
let mut q: String = ui.data(|d| d.get_temp(search_id)).unwrap_or_default();
- let r = ui.add(egui::TextEdit::singleline(&mut q).hint_text("Search fonts").desired_width(180.0));
+ let r = ui.add(egui::TextEdit::singleline(&mut q).hint_text(tl!("Search fonts")).desired_width(180.0));
if !r.has_focus() && q.is_empty() {
r.request_focus();
}
@@ -519,7 +523,7 @@ fn family_picker(ui: &mut egui::Ui, salt: &str, current: &mut String) -> bool {
fn glyph_font(app: &PhotocraftApp) -> (String, String) {
let p = &app.ui.type_panels;
if !p.glyph_family.is_empty() {
- return (p.glyph_family.clone(), if p.glyph_style.is_empty() { "Regular".into() } else { p.glyph_style.clone() });
+ return (p.glyph_family.clone(), if p.glyph_style.is_empty() { tl!("Regular").into() } else { p.glyph_style.clone() });
}
let layer = app.ui.text_edit.as_ref().map(|e| photocraft_doc::LayerId(e.layer)).or_else(|| app.session.active().and_then(|s| s.active_layer));
if let Some(st) = app.session.active()
@@ -528,10 +532,11 @@ fn glyph_font(app: &PhotocraftApp) -> (String, String) {
&& let Some(r) = tl.char_runs().first()
{
let fam = if r.style.font_family.is_empty() { photocraft_text::fonts::DEFAULT_FAMILY.to_string() } else { r.style.font_family.clone() };
- let style = if r.style.font_style.is_empty() { if r.style.italic { "Italic".into() } else { "Regular".into() } } else { r.style.font_style.clone() };
+ let style =
+ if r.style.font_style.is_empty() { if r.style.italic { tl!("Italic").into() } else { tl!("Regular").into() } } else { r.style.font_style.clone() };
return (fam, style);
}
- (photocraft_text::fonts::DEFAULT_FAMILY.into(), "Regular".into())
+ (photocraft_text::fonts::DEFAULT_FAMILY.into(), tl!("Regular").into())
}
fn char_style_for(family: &str, style: &str) -> photocraft_doc::text::CharStyle {
@@ -598,7 +603,7 @@ pub fn glyphs_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut f = family.clone();
if family_picker(ui, "glyph-family", &mut f) {
app.ui.type_panels.glyph_family = f;
- app.ui.type_panels.glyph_style = "Regular".into();
+ app.ui.type_panels.glyph_style = tl!("Regular").into();
}
let styles = crate::type_tool::styles(&family);
let mut s = style.clone();
@@ -609,9 +614,9 @@ pub fn glyphs_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
});
// Show: category.
- let mut cat = if app.ui.type_panels.glyph_category.is_empty() { "Entire Font".to_string() } else { app.ui.type_panels.glyph_category.clone() };
+ let mut cat = if app.ui.type_panels.glyph_category.is_empty() { tl!("Entire Font").to_string() } else { app.ui.type_panels.glyph_category.clone() };
ui.horizontal(|ui| {
- ui.label(RichText::new("Show:").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Show:")).color(t.text_dim).size(11.5));
let opts: Vec<(String, &str)> = photocraft_text::glyphs::CATEGORIES.iter().map(|c| (c.to_string(), *c)).collect();
if crate::widgets::dropdown(ui, "glyph-category", &mut cat, &opts, 160.0) {
app.ui.type_panels.glyph_category = cat.clone();
@@ -625,7 +630,7 @@ pub fn glyphs_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
// Recently used.
let recent = app.ui.type_panels.glyph_recent.clone();
ui.add_space(2.0);
- ui.label(RichText::new("Recently Used").color(t.text_faint).size(10.5));
+ ui.label(RichText::new(tl!("Recently Used")).color(t.text_faint).size(10.5));
let (rr, _) = ui.allocate_exact_size(vec2(ui.available_width(), 26.0), Sense::hover());
ui.painter().rect_filled(rr, 2.0, t.field);
for (i, g) in recent.iter().enumerate() {
@@ -705,7 +710,7 @@ pub fn glyphs_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if let Some(g) = activated {
app.ui.type_panels.glyph_selected = Some(g.clone());
if !insert_glyph(app, &g) {
- app.ui.status = "Select a type layer or click into text to insert glyphs".into();
+ app.ui.status = tl!("Select a type layer or click into text to insert glyphs").into();
}
}
}
@@ -738,7 +743,7 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut act: Option<&str> = None;
let mut change_to = d.change_to.clone();
let mut all_layers = d.all_layers;
- egui::Window::new("Check Spelling")
+ egui::Window::new(tl!("Check Spelling"))
.id(egui::Id::new("check-spelling"))
.collapsible(false)
.resizable(false)
@@ -747,12 +752,12 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
.anchor(Align2::CENTER_CENTER, vec2(0.0, -40.0))
.show(ctx, |ui| {
ui.set_width(380.0);
- ui.label(RichText::new("Check Spelling").color(t.text).size(13.0).strong());
+ ui.label(RichText::new(tl!("Check Spelling")).color(t.text).size(13.0).strong());
ui.add_space(6.0);
ui.horizontal_top(|ui| {
ui.vertical(|ui| {
ui.set_width(250.0);
- ui.label(RichText::new("Not in Dictionary:").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Not in Dictionary:")).color(t.text_dim).size(11.5));
let word = item.as_ref().and_then(|i| i["word"].as_str()).unwrap_or("");
let shown = if item.is_some() {
word.to_string()
@@ -763,10 +768,10 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
};
ui.add_enabled(false, egui::TextEdit::singleline(&mut shown.clone()).desired_width(240.0));
ui.add_space(4.0);
- ui.label(RichText::new("Change To:").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Change To:")).color(t.text_dim).size(11.5));
ui.add_enabled(item.is_some(), egui::TextEdit::singleline(&mut change_to).desired_width(240.0));
ui.add_space(4.0);
- ui.label(RichText::new("Suggestions:").color(t.text_dim).size(11.5));
+ ui.label(RichText::new(tl!("Suggestions:")).color(t.text_dim).size(11.5));
egui::Frame::NONE.fill(t.field).corner_radius(CornerRadius::same(3)).inner_margin(egui::Margin::same(4)).show(ui, |ui| {
ui.set_min_size(vec2(240.0, 110.0));
egui::ScrollArea::vertical().id_salt("spell-sugg").max_height(110.0).show(ui, |ui| {
@@ -784,23 +789,28 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) {
});
});
ui.add_space(4.0);
- if crate::widgets::checkbox(ui, &mut all_layers, "Check All Layers").changed() {
+ if crate::widgets::checkbox(ui, &mut all_layers, tl!("Check All Layers")).changed() {
act = Some("relist");
}
- let msg = if item.is_none() { "Spell check complete." } else { "" };
+ let msg = if item.is_none() { tl!("Spell check complete.") } else { "" };
if !msg.is_empty() {
ui.label(RichText::new(msg).color(t.text).size(11.5));
}
});
ui.vertical(|ui| {
ui.spacing_mut().item_spacing.y = 4.0;
- if crate::widgets::primary_button(ui, "Done", 100.0).clicked() {
+ if crate::widgets::primary_button(ui, tl!("Done"), 100.0).clicked() {
act = Some("done");
}
ui.add_space(6.0);
ui.add_enabled_ui(item.is_some(), |ui| {
- for (label, a) in [("Ignore", "ignore"), ("Ignore All", "ignoreAll"), ("Change", "change"), ("Change All", "changeAll"), ("Add", "add")]
- {
+ for (label, a) in [
+ (tl!("Ignore"), "ignore"),
+ (tl!("Ignore All"), "ignoreAll"),
+ (tl!("Change"), "change"),
+ (tl!("Change All"), "changeAll"),
+ (tl!("Add"), "add"),
+ ] {
if crate::widgets::secondary_button(ui, label, 100.0).clicked() {
act = Some(a);
}
diff --git a/crates/ui-egui/src/type_tool.rs b/crates/ui-egui/src/type_tool.rs
index 872e2aca3..0eb15cf7e 100644
--- a/crates/ui-egui/src/type_tool.rs
+++ b/crates/ui-egui/src/type_tool.rs
@@ -610,7 +610,7 @@ pub fn styles(family: &str) -> Vec<String> {
v.sort();
v.dedup_by(|a, b| a.2 == b.2);
let v: Vec<String> = v.into_iter().map(|x| x.2).collect();
- if v.is_empty() { vec!["Regular".into()] } else { v }
+ if v.is_empty() { vec![tl!("Regular").into()] } else { v }
}
/// Searchable font-family combo box.
@@ -619,7 +619,7 @@ fn font_picker(ui: &mut egui::Ui, current: &mut String, width: f32) -> bool {
let search_id = ui.id().with("font-search");
egui::ComboBox::from_id_salt("type-font").selected_text(current.as_str()).width(width).height(460.0).icon(crate::widgets::chevron_icon).show_ui(ui, |ui| {
let mut q: String = ui.data(|d| d.get_temp(search_id)).unwrap_or_default();
- let r = ui.add(egui::TextEdit::singleline(&mut q).hint_text("Search fonts").desired_width(200.0));
+ let r = ui.add(egui::TextEdit::singleline(&mut q).hint_text(tl!("Search fonts")).desired_width(200.0));
if !r.has_focus() && q.is_empty() {
r.request_focus();
}
@@ -697,7 +697,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
Some((f, s, z, _)) => (f.clone(), if s.is_empty() { "Regular".into() } else { s.clone() }, *z),
None => (o.type_font.clone(), o.type_style.clone(), o.type_size),
};
- if crate::icons::button(ui, "text-cursor", 24.0, false, "Toggle text orientation").clicked()
+ if crate::icons::button(ui, "text-cursor", 24.0, false, tl!("Toggle text orientation")).clicked()
&& let Some((layer, _)) = target(app)
{
let to = if is_vertical(app, LayerId(layer)) { "horizontal" } else { "vertical" };
@@ -728,11 +728,11 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
let mut aa = o.type_aa.clone();
let aa_opts = [
- ("none".to_string(), "None"),
- ("sharp".to_string(), "Sharp"),
- ("crisp".to_string(), "Crisp"),
- ("strong".to_string(), "Strong"),
- ("smooth".to_string(), "Smooth"),
+ ("none".to_string(), tl!("None")),
+ ("sharp".to_string(), tl!("Sharp")),
+ ("crisp".to_string(), tl!("Crisp")),
+ ("strong".to_string(), tl!("Strong")),
+ ("smooth".to_string(), tl!("Smooth")),
];
if crate::widgets::dropdown(ui, "type-aa", &mut aa, &aa_opts, 80.0) {
app.ui.tool_options.type_aa = aa.clone();
@@ -747,7 +747,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
crate::widgets::vline(ui, 22.0);
ui.spacing_mut().item_spacing.x = 2.0;
for (align, icon, tip) in
- [("left", "align-left", "Left align text"), ("center", "align-center", "Center text"), ("right", "align-right", "Right align text")]
+ [("left", "align-left", tl!("Left align text")), ("center", "align-center", tl!("Center text")), ("right", "align-right", tl!("Right align text"))]
{
if crate::icons::button(ui, icon, 24.0, o.type_align == align, tip).clicked() {
app.ui.tool_options.type_align = align.into();
@@ -769,7 +769,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8;
ui.painter().rect_filled(rect, 2.0, Color32::from_rgb(q(c[0]), q(c[1]), q(c[2])));
ui.painter().rect_stroke(rect, 2.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Outside);
- let resp = resp.on_hover_text("Set the text color");
+ let resp = resp.on_hover_text(tl!("Set the text color"));
egui::Popup::from_toggle_button_response(&resp).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| {
let mut col = Color32::from_rgb(q(c[0]), q(c[1]), q(c[2]));
if egui::color_picker::color_picker_color32(ui, &mut col, egui::color_picker::Alpha::Opaque) {
@@ -779,10 +779,18 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if app.ui.text_edit.is_some() {
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_space(8.0);
- if crate::icons::button(ui, "check", 24.0, false, &format!("Commit any current edits ({})", crate::shortcuts::pretty("Cmd+Enter"))).clicked() {
+ if crate::icons::button(
+ ui,
+ "check",
+ 24.0,
+ false,
+ &crate::i18n::fmt(tl!("Commit any current edits ({key})"), &[("key", &crate::shortcuts::pretty("Cmd+Enter"))]),
+ )
+ .clicked()
+ {
commit(app);
}
- if crate::icons::button(ui, "ban", 24.0, false, "Cancel any current edits (Esc)").clicked() {
+ if crate::icons::button(ui, "ban", 24.0, false, tl!("Cancel any current edits (Esc)")).clicked() {
cancel(app);
}
});
@@ -955,7 +963,7 @@ fn toggle_cell(ui: &mut egui::Ui, w: f32, on: bool, tip: &str, paint: impl FnOnc
paint(ui, r, if on { t.text } else { t.text_dim });
let tip = tip.to_string();
resp.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Button, true, on, &tip));
- resp.on_hover_text(tip).clicked()
+ resp.on_hover_text(tl!(&tip)).clicked()
}
/// Width of each of `n` equal cells filling `avail` with 2 pt gaps.
@@ -976,7 +984,7 @@ pub fn character_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui, paragraph: bo
if styles_at(app).is_none() {
let t = crate::theme::Tokens::get(ui.ctx());
ui.add_space(8.0);
- ui.label(egui::RichText::new("Select a type layer to edit its character and paragraph settings.").color(t.text_dim));
+ ui.label(egui::RichText::new(tl!("Select a type layer to edit its character and paragraph settings.")).color(t.text_dim));
return;
}
type_sections(app, ui, !paragraph, paragraph);
@@ -997,7 +1005,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
});
ui.add_space(ROW_GAP);
};
- if character && section(ui, "character", "Character") {
+ if character && section(ui, "character", tl!("Character")) {
let full = ui.available_width();
let w = field_width(full, 2, LABEL_W);
let mut fam = c.font_family.clone();
@@ -1005,7 +1013,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
if font_picker(ui, &mut fam, full) {
app.ui.tool_options.type_font = fam.clone();
let st = styles(&fam);
- let style = if st.contains(&c.font_style) { c.font_style.clone() } else { st.first().cloned().unwrap_or_else(|| "Regular".into()) };
+ let style = if st.contains(&c.font_style) { c.font_style.clone() } else { st.first().cloned().unwrap_or_else(|| tl!("Regular").into()) };
apply(app, ui.ctx(), json!({"font": fam, "fontStyle": style}));
}
});
@@ -1056,7 +1064,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
// Colour: label + a swatch filling the rest of the second column.
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = LABEL_GAP;
- let g = ui.painter().layout_no_wrap("Color".into(), egui::FontId::proportional(12.0), t.text_dim);
+ let g = ui.painter().layout_no_wrap(tl!("Color").into(), egui::FontId::proportional(12.0), t.text_dim);
let lw = g.size().x.max(LABEL_W);
let (lr, _) = ui.allocate_exact_size(egui::vec2(lw, 22.0), egui::Sense::hover());
ui.painter().galley(egui::pos2(lr.left(), lr.center().y - g.size().y / 2.0), g, t.text_dim);
@@ -1066,7 +1074,7 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
let (rect, resp) = ui.allocate_exact_size(egui::vec2(sw, 22.0), egui::Sense::click());
ui.painter().rect_filled(rect, t.radius_sm, Color32::from_rgb(q(rgb[0]), q(rgb[1]), q(rgb[2])));
ui.painter().rect_stroke(rect, t.radius_sm, Stroke::new(1.0, t.field_border), egui::StrokeKind::Inside);
- let resp = resp.on_hover_text("Text color");
+ let resp = resp.on_hover_text(tl!("Text color"));
egui::Popup::from_toggle_button_response(&resp).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| {
let mut col = Color32::from_rgb(q(rgb[0]), q(rgb[1]), q(rgb[2]));
if egui::color_picker::color_picker_color32(ui, &mut col, egui::color_picker::Alpha::Opaque) {
@@ -1082,13 +1090,13 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
("T", "Faux Italic", c.faux_italic, json!({"fauxItalic": !c.faux_italic})),
(
"TT",
- "All Caps",
+ tl!("All Caps"),
caps == photocraft_doc::text::Caps::AllCaps,
json!({"caps": if caps == photocraft_doc::text::Caps::AllCaps { "normal" } else { "allCaps" }}),
),
(
"Tᴛ",
- "Small Caps",
+ tl!("Small Caps"),
caps == photocraft_doc::text::Caps::SmallCaps,
json!({"caps": if caps == photocraft_doc::text::Caps::SmallCaps { "normal" } else { "smallCaps" }}),
),
@@ -1128,18 +1136,18 @@ fn type_sections(app: &mut PhotocraftApp, ui: &mut egui::Ui, character: bool, pa
});
ui.add_space(ROW_GAP);
}
- if paragraph && section(ui, "paragraph", "Paragraph") {
+ if paragraph && section(ui, "paragraph", tl!("Paragraph")) {
use photocraft_doc::text::TextAlign as A;
let full = ui.available_width();
let w = field_width(full, 2, LABEL_W);
let items = [
- ("left", "Left align text", A::Left),
- ("center", "Center text", A::Center),
- ("right", "Right align text", A::Right),
- ("justifyLeft", "Justify last left", A::JustifyLeft),
- ("justifyCenter", "Justify last centered", A::JustifyCenter),
- ("justifyRight", "Justify last right", A::JustifyRight),
- ("justifyAll", "Justify all", A::JustifyAll),
+ ("left", tl!("Left align text"), A::Left),
+ ("center", tl!("Center text"), A::Center),
+ ("right", tl!("Right align text"), A::Right),
+ ("justifyLeft", tl!("Justify last left"), A::JustifyLeft),
+ ("justifyCenter", tl!("Justify last centered"), A::JustifyCenter),
+ ("justifyRight", tl!("Justify last right"), A::JustifyRight),
+ ("justifyAll", tl!("Justify all"), A::JustifyAll),
];
let cw = cell_width(full, items.len());
ui.horizontal(|ui| {
@@ -1212,7 +1220,7 @@ fn type_options(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = crate::theme::Tokens::get(ui.ctx());
let (r, resp) = ui.allocate_exact_size(egui::vec2(crate::props_layout::LABEL_W, 22.0), egui::Sense::hover());
ui.painter().text(r.center(), egui::Align2::CENTER_CENTER, "aa", crate::theme::semibold(11.0), t.text_dim);
- resp.on_hover_text("Anti-aliasing method");
+ resp.on_hover_text(tl!("Anti-aliasing method"));
let mut cur = aa.clone();
let opts: Vec<(String, &str)> = ["none", "sharp", "crisp", "strong", "smooth", "windowsLcd", "windows"]
.into_iter()
diff --git a/crates/ui-egui/src/variables_ui.rs b/crates/ui-egui/src/variables_ui.rs
index 8953d2a8e..fba921ac4 100644
--- a/crates/ui-egui/src/variables_ui.rs
+++ b/crates/ui-egui/src/variables_ui.rs
@@ -116,9 +116,9 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, fields: &mut Map<String,
ui.set_min_width(420.0);
// Page switcher.
ui.horizontal(|ui| {
- for (id, label) in [("define", "Define"), ("dataSets", "Data Sets")] {
+ for (id, label) in [("define", tl!("Define")), ("dataSets", tl!("Data Sets"))] {
let sel = page == id;
- if ui.selectable_label(sel, label).clicked() {
+ if ui.selectable_label(sel, tl!(&label)).clicked() {
page = id.to_string();
}
}
@@ -126,7 +126,7 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, fields: &mut Map<String,
ui.separator();
if layers.is_empty() {
- ui.weak("Open a document to define variables.");
+ ui.weak(tl!("Open a document to define variables."));
} else if page == "define" {
define_page(ui, &t, &layers, &mut state);
} else {
@@ -139,14 +139,14 @@ pub fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, fields: &mut Map<String,
fn define_page(ui: &mut egui::Ui, _t: &Tokens, layers: &[(u64, String, bool)], state: &mut Value) {
let Some(defs) = state.get_mut("defs").and_then(Value::as_array_mut) else { return };
- ui.label("Variables bind a layer's visibility, text or pixels to a named data slot.");
+ ui.label(tl!("Variables bind a layer's visibility, text or pixels to a named data slot."));
ui.add_space(4.0);
let mut remove = None;
for (i, d) in defs.iter_mut().enumerate() {
ui.horizontal(|ui| {
// name
let mut name = d.get("name").and_then(Value::as_str).unwrap_or("").to_string();
- if ui.add(egui::TextEdit::singleline(&mut name).hint_text("name").desired_width(110.0)).changed() {
+ if ui.add(egui::TextEdit::singleline(&mut name).hint_text(tl!("name")).desired_width(110.0)).changed() {
d["name"] = json!(name);
}
// layer
@@ -168,7 +168,7 @@ fn define_page(ui: &mut egui::Ui, _t: &Tokens, layers: &[(u64, String, bool)], s
d["method"] = json!(m);
}
}
- if ui.button("−").on_hover_text("Remove variable").clicked() {
+ if ui.button("−").on_hover_text(tl!("Remove variable")).clicked() {
remove = Some(i);
}
});
@@ -177,7 +177,7 @@ fn define_page(ui: &mut egui::Ui, _t: &Tokens, layers: &[(u64, String, bool)], s
defs.remove(i);
}
ui.add_space(4.0);
- if ui.button("+ Add variable").clicked() {
+ if ui.button(tl!("+ Add variable")).clicked() {
let n = defs.len() + 1;
defs.push(json!({"name": format!("var{n}"), "layer": layers[0].0, "type": "visibility", "method": "fit", "align": "center", "clip": false}));
}
@@ -196,7 +196,7 @@ fn data_sets_page(ui: &mut egui::Ui, _t: &Tokens, state: &mut Value, fields: &mu
})
.unwrap_or_default();
if def_meta.is_empty() {
- ui.weak("Define at least one variable first.");
+ ui.weak(tl!("Define at least one variable first."));
return;
}
let Some(sets) = state.get_mut("dataSets").and_then(Value::as_array_mut) else { return };
@@ -211,12 +211,12 @@ fn data_sets_page(ui: &mut egui::Ui, _t: &Tokens, state: &mut Value, fields: &mu
if ui.button("▶").clicked() && cur + 1 < sets.len() {
cur += 1;
}
- if ui.button("New").clicked() {
+ if ui.button(tl!("New")).clicked() {
let n = sets.len() + 1;
sets.push(json!({"name": format!("Data Set {n}"), "values": []}));
cur = sets.len() - 1;
}
- if !sets.is_empty() && ui.button("Delete").clicked() {
+ if !sets.is_empty() && ui.button(tl!("Delete")).clicked() {
sets.remove(cur);
cur = cur.saturating_sub(1);
}
@@ -227,7 +227,7 @@ fn data_sets_page(ui: &mut egui::Ui, _t: &Tokens, state: &mut Value, fields: &mu
// name
let mut sname = set.get("name").and_then(Value::as_str).unwrap_or("").to_string();
ui.horizontal(|ui| {
- ui.label("Name:");
+ ui.label(tl!("Name:"));
if ui.add(egui::TextEdit::singleline(&mut sname).desired_width(200.0)).changed() {
set["name"] = json!(sname);
}
@@ -254,13 +254,13 @@ fn data_sets_page(ui: &mut egui::Ui, _t: &Tokens, state: &mut Value, fields: &mu
match vty.as_str() {
"visibility" => {
let mut on = values[i].get("value").and_then(Value::as_bool).unwrap_or(true);
- if ui.checkbox(&mut on, "Visible").changed() {
+ if ui.checkbox(&mut on, tl!("Visible")).changed() {
values[i]["value"] = json!(on);
}
}
"pixelReplacement" => {
let mut p = values[i].get("value").and_then(Value::as_str).unwrap_or("").to_string();
- if ui.add(egui::TextEdit::singleline(&mut p).hint_text("image file path").desired_width(240.0)).changed() {
+ if ui.add(egui::TextEdit::singleline(&mut p).hint_text(tl!("image file path")).desired_width(240.0)).changed() {
values[i]["value"] = json!(p);
}
}
@@ -274,7 +274,7 @@ fn data_sets_page(ui: &mut egui::Ui, _t: &Tokens, state: &mut Value, fields: &mu
});
}
ui.add_space(6.0);
- if crate::widgets::secondary_button(ui, "Apply", 84.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Apply"), 84.0).clicked() {
fields.insert("__apply".into(), json!(sname));
}
}
diff --git a/crates/ui-egui/src/vector_ui.rs b/crates/ui-egui/src/vector_ui.rs
index a6d95efcd..d35e9a586 100644
--- a/crates/ui-egui/src/vector_ui.rs
+++ b/crates/ui-egui/src/vector_ui.rs
@@ -353,35 +353,41 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
};
let o = &mut app.ui.tool_options;
if tool == Tool::PathSelection {
- lbl(ui, if app.ui.vector_mask_target { "Drag to move the targeted vector mask" } else { "Drag to move the active shape's path or the Work Path" });
+ lbl(ui, if app.ui.vector_mask_target { "Drag to move the targeted vector mask" } else { tl!("Drag to move the active shape's path or the Work Path") });
return true;
}
if tool == Tool::Pen {
- let opts = [("path".to_string(), "Path"), ("shape".to_string(), "Shape")];
+ let opts = [("path".to_string(), tl!("Path")), ("shape".to_string(), tl!("Shape"))];
crate::widgets::dropdown(ui, "pen-mode", &mut o.vector_mode, &opts, 80.0);
crate::widgets::vline(ui, 22.0);
- lbl(ui, &format!("Click: corner · Drag: smooth · Click first point: close · {} finish · Esc cancel", crate::shortcuts::pretty("Enter")));
+ lbl(
+ ui,
+ &crate::i18n::fmt(
+ tl!("Click: corner · Drag: smooth · Click first point: close · {key} finish · Esc cancel"),
+ &[("key", &crate::shortcuts::pretty("Enter"))],
+ ),
+ );
return true;
}
let mut mode = "shape".to_string();
- crate::widgets::dropdown(ui, "shape-mode", &mut mode, &[("shape".to_string(), "Shape")], 80.0);
+ crate::widgets::dropdown(ui, "shape-mode", &mut mode, &[("shape".to_string(), tl!("Shape"))], 80.0);
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Fill:");
+ lbl(ui, tl!("Fill:"));
crate::widgets::checkbox(ui, &mut o.shape_fill, "");
let (r, _) = ui.allocate_exact_size(vec2(22.0, 16.0), Sense::hover());
ui.painter().rect_filled(r, 2.0, rgb32(app.session.tools.foreground));
ui.painter().rect_stroke(r, 2.0, Stroke::new(1.0, t.field_border), egui::StrokeKind::Outside);
- lbl(ui, "Stroke:");
+ lbl(ui, tl!("Stroke:"));
crate::widgets::value_field(ui, &mut o.stroke_width, 0.0..=288.0, "px", 58.0);
match tool {
Tool::Rectangle => {
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Radius:");
+ lbl(ui, tl!("Radius:"));
crate::widgets::value_field(ui, &mut o.corner_radius, 0.0..=10000.0, "px", 62.0);
}
Tool::Polygon => {
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Sides:");
+ lbl(ui, tl!("Sides:"));
let mut s = o.polygon_sides as f32;
if crate::widgets::value_field(ui, &mut s, 3.0..=100.0, "", 48.0).changed() {
o.polygon_sides = s.round().clamp(3.0, 100.0) as u32;
@@ -389,7 +395,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui, tool: Tool) -> bo
}
Tool::Line => {
crate::widgets::vline(ui, 22.0);
- lbl(ui, "Weight:");
+ lbl(ui, tl!("Weight:"));
crate::widgets::value_field(ui, &mut o.line_weight, 1.0..=1000.0, "px", 58.0);
}
Tool::CustomShape => {
@@ -463,7 +469,7 @@ fn swatch(ui: &mut egui::Ui, fill: Option<&photocraft_doc::Fill>, tip: &str) ->
if egui::color_picker::color_picker_color32(ui, &mut c, egui::color_picker::Alpha::Opaque) {
out = Some(format!("#{:02x}{:02x}{:02x}", c.r(), c.g(), c.b()));
}
- if fill.is_some() && ui.button("No Color").clicked() {
+ if fill.is_some() && ui.button(tl!("No Color")).clicked() {
out = Some("none".into());
}
});
@@ -482,15 +488,15 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra
let mut edit: Option<Value> = None;
let key = |k: &str| format!("shape-{}-{k}", id.0);
// The shared collapsible section headers (#155).
- if crate::props_layout::section(ui, "appearance", "Appearance") {
+ if crate::props_layout::section(ui, "appearance", tl!("Appearance")) {
ui.horizontal(|ui| {
- ui.label(egui::RichText::new("Fill").color(t.text_dim).size(12.0));
- if let Some(c) = swatch(ui, sh.fill.as_ref(), "Set shape fill type") {
+ ui.label(egui::RichText::new(tl!("Fill")).color(t.text_dim).size(12.0));
+ if let Some(c) = swatch(ui, sh.fill.as_ref(), tl!("Set shape fill type")) {
edit = Some(if c == "none" { json!({"fill": null}) } else { json!({"fill": c, "coalesce": key("fill")}) });
}
ui.add_space(12.0);
- ui.label(egui::RichText::new("Stroke").color(t.text_dim).size(12.0));
- if let Some(c) = swatch(ui, sh.stroke.as_ref().map(|s| &s.paint), "Set shape stroke type") {
+ ui.label(egui::RichText::new(tl!("Stroke")).color(t.text_dim).size(12.0));
+ if let Some(c) = swatch(ui, sh.stroke.as_ref().map(|s| &s.paint), tl!("Set shape stroke type")) {
edit = Some(if c == "none" {
json!({"stroke": null})
} else {
@@ -516,10 +522,10 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra
});
}
if let Some(live) = &sh.live
- && crate::props_layout::section(ui, "liveShape", "Shape")
+ && crate::props_layout::section(ui, "liveShape", tl!("Shape"))
{
let num = |ui: &mut egui::Ui, label: &str, v: &mut f32, range: std::ops::RangeInclusive<f32>, unit: &str| -> bool {
- ui.label(egui::RichText::new(label).color(t.text_dim).size(12.0));
+ ui.label(egui::RichText::new(tl!(&label)).color(t.text_dim).size(12.0));
crate::widgets::value_field(ui, v, range, unit, 64.0).changed()
};
match live {
@@ -540,23 +546,23 @@ pub fn shape_properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, id: photocra
ui.horizontal(|ui| match live {
photocraft_doc::vector::LiveShape::Rect { radii, .. } => {
let mut r = radii[0] as f32;
- if num(ui, "Corner radius", &mut r, 0.0..=100000.0, "px") {
+ if num(ui, tl!("Corner radius"), &mut r, 0.0..=100000.0, "px") {
edit = Some(json!({"radii": r, "coalesce": key("radius")}));
}
}
photocraft_doc::vector::LiveShape::Polygon { sides, star_ratio, .. } => {
let mut n = *sides as f32;
- if num(ui, "Sides", &mut n, 3.0..=100.0, "") {
+ if num(ui, tl!("Sides"), &mut n, 3.0..=100.0, "") {
edit = Some(json!({"sides": n.round() as u32, "coalesce": key("sides")}));
}
let mut sr = (*star_ratio * 100.0) as f32;
- if num(ui, "Star ratio", &mut sr, 1.0..=100.0, "%") {
+ if num(ui, tl!("Star ratio"), &mut sr, 1.0..=100.0, "%") {
edit = Some(json!({"starRatio": sr as f64 / 100.0, "coalesce": key("star")}));
}
}
photocraft_doc::vector::LiveShape::Line { weight, .. } => {
let mut w = *weight as f32;
- if num(ui, "Weight", &mut w, 1.0..=10000.0, "px") {
+ if num(ui, tl!("Weight"), &mut w, 1.0..=10000.0, "px") {
edit = Some(json!({"weight": w, "coalesce": key("weight")}));
}
}
@@ -645,7 +651,7 @@ pub fn paths_footer(ctx: &egui::Context) -> Option<Rect> {
pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let Some(st) = app.session.active() else {
- ui.label(egui::RichText::new("No document").color(t.text_faint));
+ ui.label(egui::RichText::new(tl!("No document")).color(t.text_faint));
return;
};
let doc = st.doc.clone();
@@ -660,7 +666,7 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui,
|ui| {
if rows.is_empty() {
- ui.label(egui::RichText::new("Draw with the Pen tool (P) or make a work path from a selection.").color(t.text_faint).size(11.5));
+ ui.label(egui::RichText::new(tl!("Draw with the Pen tool (P) or make a work path from a selection.")).color(t.text_faint).size(11.5));
}
for PathEntry { name, path, kind } in &rows {
let (r, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 36.0), Sense::click());
@@ -681,7 +687,11 @@ pub fn paths_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let mut job = egui::text::LayoutJob::default();
// Temporary paths (the work path, the selected layer's shape path or vector mask) are italic.
let italics = *kind != PathRow::Saved;
- job.append(name, 0.0, egui::TextFormat { font_id: egui::FontId::proportional(12.0), color: t.text, italics, ..Default::default() });
+ job.append(
+ if *kind == PathRow::Work { tl!(name) } else { name },
+ 0.0,
+ egui::TextFormat { font_id: egui::FontId::proportional(12.0), color: t.text, italics, ..Default::default() },
+ );
let g = ui.painter().layout_job(job);
ui.painter().galley(pos2(r.left() + 46.0, r.center().y - g.size().y / 2.0), g, t.text);
if resp.clicked() {
diff --git a/crates/ui-egui/src/wide_angle_ui.rs b/crates/ui-egui/src/wide_angle_ui.rs
index dc388b613..9f568227c 100644
--- a/crates/ui-egui/src/wide_angle_ui.rs
+++ b/crates/ui-egui/src/wide_angle_ui.rs
@@ -202,7 +202,7 @@ pub fn menu(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, params: &Val
}
fn commit(app: &mut PhotocraftApp) -> Result<Value, String> {
- let d = app.wide_angle.take().ok_or("Adaptive Wide Angle isn't open")?;
+ let d = app.wide_angle.take().ok_or(tl!("Adaptive Wide Angle isn't open"))?;
app.run("filter.adaptiveWideAngle", d.command_params())
}
@@ -320,17 +320,17 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let mut props = ui.new_child(egui::UiBuilder::new().max_rect(right.shrink2(vec2(14.0, 10.0))));
egui::ScrollArea::vertical().id_salt("awa-props").show(&mut props, |ui| {
ui.spacing_mut().item_spacing.y = 5.0;
- widgets::section_label(ui, "Correction");
+ widgets::section_label(ui, tl!("Correction"));
let mut model = d.params.model;
if widgets::dropdown(
ui,
"awa-model",
&mut model,
&[
- (WideModel::Auto, "Auto"),
- (WideModel::Fisheye, "Fisheye"),
- (WideModel::Perspective, "Perspective"),
- (WideModel::FullSpherical, "Full Spherical"),
+ (WideModel::Auto, tl!("Auto")),
+ (WideModel::Fisheye, tl!("Fisheye")),
+ (WideModel::Perspective, tl!("Perspective")),
+ (WideModel::FullSpherical, tl!("Full Spherical")),
],
200.0,
) {
@@ -338,22 +338,22 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
d.dirty = true;
}
let mut v = d.params.scale as f32;
- if widgets::slider_row(ui, "Scale", &mut v, 50.0..=150.0, "%", None).changed() {
+ if widgets::slider_row(ui, tl!("Scale"), &mut v, 50.0..=150.0, "%", None).changed() {
d.params.scale = v as f64;
d.dirty = true;
}
let mut v = d.params.focal_length as f32;
- if widgets::slider_row(ui, "Focal Length", &mut v, 0.0..=200.0, "mm", None).changed() {
+ if widgets::slider_row(ui, tl!("Focal Length"), &mut v, 0.0..=200.0, "mm", None).changed() {
d.params.focal_length = v as f64;
d.dirty = true;
}
let mut v = d.params.crop_factor as f32;
- if widgets::slider_row(ui, "Crop Factor", &mut v, 0.1..=10.0, "", None).changed() {
+ if widgets::slider_row(ui, tl!("Crop Factor"), &mut v, 0.1..=10.0, "", None).changed() {
d.params.crop_factor = v as f64;
d.dirty = true;
}
widgets::hairline(ui);
- widgets::section_label(ui, &format!("Constraints ({})", d.params.constraints.len()));
+ widgets::section_label(ui, &crate::i18n::fmt(tl!("Constraints ({n})"), &[("n", &d.params.constraints.len().to_string())]));
let mut remove = None;
for (i, c) in d.params.constraints.iter_mut().enumerate() {
ui.horizontal(|ui| {
@@ -363,13 +363,13 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui,
&format!("awa-o-{i}"),
&mut o,
- &[(Orientation::Free, "Free"), (Orientation::Horizontal, "Horizontal"), (Orientation::Vertical, "Vertical")],
+ &[(Orientation::Free, tl!("Free")), (Orientation::Horizontal, tl!("Horizontal")), (Orientation::Vertical, tl!("Vertical"))],
120.0,
) {
c.orientation = o;
d.dirty = true;
}
- if widgets::secondary_button(ui, "Delete", 60.0).clicked() {
+ if widgets::secondary_button(ui, tl!("Delete"), 60.0).clicked() {
remove = Some(i);
}
});
@@ -379,9 +379,9 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
d.dirty = true;
}
widgets::hairline(ui);
- widgets::checkbox(ui, &mut d.preview, "Preview");
+ widgets::checkbox(ui, &mut d.preview, tl!("Preview"));
ui.label(
- egui::RichText::new("Drag on the image to add a constraint; Shift for horizontal/vertical; right-click to delete.")
+ egui::RichText::new(tl!("Drag on the image to add a constraint; Shift for horizontal/vertical; right-click to delete."))
.color(t.text_faint)
.size(11.0),
);
@@ -389,10 +389,10 @@ pub fn show(app: &mut PhotocraftApp, ctx: &egui::Context) {
let foot = ERect::from_min_max(pos2(full.left(), full.bottom() - footer_h), full.max);
painter.rect_filled(foot, 0.0, t.dock);
let mut fu = ui.new_child(egui::UiBuilder::new().max_rect(foot.shrink2(vec2(16.0, 9.0))).layout(egui::Layout::right_to_left(egui::Align::Center)));
- if widgets::primary_button(&mut fu, "OK", 90.0).clicked() {
+ if widgets::primary_button(&mut fu, tl!("OK"), 90.0).clicked() {
action = Some("ok");
}
- if widgets::secondary_button(&mut fu, "Cancel", 90.0).clicked() {
+ if widgets::secondary_button(&mut fu, tl!("Cancel"), 90.0).clicked() {
action = Some("cancel");
}
fu.label(egui::RichText::new(format!("{:.0} ms · straightness {:.1} px", d.render_ms, d.residual)).color(t.text_faint));
diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs
index 4864bdb5e..c82f5ee98 100644
--- a/crates/ui-egui/src/widgets.rs
+++ b/crates/ui-egui/src/widgets.rs
@@ -59,7 +59,7 @@ pub fn card_ex(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, colla
let strip = ui.interact(strip_rect, ui.id().with((id, "strip")), Sense::click_and_drag());
// Pill tabs left of the menu button; they elide or overflow into a chevron (#151).
let (row, _) = ui.allocate_exact_size(vec2(ui.available_width(), 24.0), Sense::hover());
- let tip = format!("{} options", tabs.get(*selected).copied().unwrap_or(id));
+ let tip = crate::i18n::fmt(tl!("{name} options"), &[("name", tl!(tabs.get(*selected).copied().unwrap_or(id)))]);
let menu_rect = Rect::from_min_max(pos2(row.right() - 22.0, row.top() + 1.0), pos2(row.right(), row.bottom() - 1.0));
let menu = crate::icons::button(&mut ui.new_child(egui::UiBuilder::new().max_rect(menu_rect)), "ellipsis", 22.0, false, &tip);
let area = Rect::from_min_max(row.min, pos2((menu_rect.left() - 4.0).max(row.left()), row.bottom()));
@@ -112,7 +112,7 @@ fn pro_panel(ui: &mut Ui, id: &str, tabs: &[&str], selected: &mut usize, collaps
pub fn pill_tab(ui: &mut Ui, label: &str, selected: bool) -> Response {
let t = Tokens::get(ui.ctx());
let font = theme::medium(12.5);
- let galley = ui.painter().layout_no_wrap(label.to_owned(), font, t.text);
+ let galley = ui.painter().layout_no_wrap(tl!(label).to_owned(), font, t.text);
let size = vec2(galley.size().x + 20.0, 24.0);
let (rect, resp) = ui.allocate_exact_size(size, Sense::click());
if selected {
@@ -235,7 +235,7 @@ pub fn slider_row(ui: &mut Ui, label: &str, value: &mut f32, range: std::ops::Ra
let t = Tokens::get(ui.ctx());
let mut changed_resp = None;
ui.horizontal(|ui| {
- ui.label(egui::RichText::new(label).color(t.text_dim));
+ ui.label(egui::RichText::new(tl!(label)).color(t.text_dim));
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
changed_resp = Some(value_field(ui, value, range.clone(), suffix, 74.0));
});
@@ -269,7 +269,7 @@ pub fn toggle(ui: &mut Ui, on: &mut bool, label: &str) -> Response {
}
let x = egui::lerp((rect.left() + 8.5)..=(rect.right() - 8.5), how_on);
ui.painter().circle_filled(pos2(x, rect.center().y), 6.5, Color32::WHITE);
- ui.label(egui::RichText::new(label).color(if *on { t.text } else { t.text_dim }));
+ ui.label(egui::RichText::new(tl!(label)).color(if *on { t.text } else { t.text_dim }));
resp
})
.inner;
@@ -293,7 +293,7 @@ pub fn secondary_button(ui: &mut Ui, label: &str, min_width: f32) -> Response {
fn button_impl(ui: &mut Ui, label: &str, min_width: f32, bg: Color32, fg: Color32, primary: bool) -> Response {
let t = Tokens::get(ui.ctx());
- let galley = ui.painter().layout_no_wrap(label.to_owned(), theme::medium(13.0), fg);
+ let galley = ui.painter().layout_no_wrap(tl!(label).to_owned(), theme::medium(13.0), fg);
let h = if t.pro { 28.0 } else { 30.0 };
let size = vec2((galley.size().x + 28.0).max(min_width), h);
let (rect, resp) = ui.allocate_exact_size(size, Sense::click());
@@ -339,7 +339,7 @@ fn button_impl(ui: &mut Ui, label: &str, min_width: f32, bg: Color32, fg: Color3
/// Small caps section label.
pub fn section_label(ui: &mut Ui, text: &str) {
let t = Tokens::get(ui.ctx());
- ui.label(egui::RichText::new(text).font(theme::medium(11.5)).color(t.text_faint));
+ ui.label(egui::RichText::new(tl!(text)).font(theme::medium(11.5)).color(t.text_faint));
}
/// Hairline separator.
@@ -369,11 +369,11 @@ pub fn hue_stops() -> Vec<Color32> {
/// A compact labelled dropdown in the studio style.
pub fn dropdown<T: PartialEq + Clone>(ui: &mut Ui, id: &str, current: &mut T, options: &[(T, &str)], width: f32) -> bool {
- let label = options.iter().find(|(v, _)| v == current).map(|(_, l)| *l).unwrap_or("—");
+ let label = options.iter().find(|(v, _)| v == current).map(|(_, l)| tl!(l)).unwrap_or("—");
let mut changed = false;
egui::ComboBox::from_id_salt(id).selected_text(label).width(width).height(420.0).icon(chevron_icon).show_ui(ui, |ui| {
for (v, l) in options {
- if ui.selectable_label(v == current, *l).clicked() {
+ if ui.selectable_label(v == current, tl!(l)).clicked() {
*current = v.clone();
changed = true;
}
@@ -416,7 +416,7 @@ pub fn checkbox(ui: &mut Ui, on: &mut bool, label: &str) -> Response {
p.rect_filled(rect, 2.0, t.field);
p.rect_stroke(rect, 2.0, Stroke::new(1.5, if resp.hovered() { t.text_dim } else { t.text_faint }), StrokeKind::Inside);
}
- let l = ui.add(egui::Label::new(egui::RichText::new(label).color(t.text_dim)).sense(Sense::click()));
+ let l = ui.add(egui::Label::new(egui::RichText::new(tl!(label)).color(t.text_dim)).sense(Sense::click()));
resp.union(l)
})
.inner;
diff --git a/crates/ui-egui/src/workspace_ui.rs b/crates/ui-egui/src/workspace_ui.rs
index 7c6eaa2d6..178354f2e 100644
--- a/crates/ui-egui/src/workspace_ui.rs
+++ b/crates/ui-egui/src/workspace_ui.rs
@@ -295,8 +295,8 @@ pub fn windows(app: &mut PhotocraftApp, ctx: &egui::Context) {
let cmd = crate::shortcuts::pretty("Cmd");
let shift = crate::shortcuts::pretty("Shift");
let alt = crate::shortcuts::pretty("Alt");
- crate::analysis_ui::panel_window(app, ctx, "modifier-keys", "Modifier Keys", vec2(-420.0, 80.0), 150.0, |ui| {
- close = crate::analysis_ui::title_row(ui, "Modifier Keys");
+ crate::analysis_ui::panel_window(app, ctx, "modifier-keys", tl!("Modifier Keys"), vec2(-420.0, 80.0), 150.0, |ui| {
+ close = crate::analysis_ui::title_row(ui, tl!("Modifier Keys"));
ui.horizontal(|ui| {
for (label, on) in [(&*shift, &mut s.sticky_shift), (&*cmd, &mut s.sticky_command), (&*alt, &mut s.sticky_alt)] {
if ui.add(egui::Button::new(RichText::new(label).size(14.0)).selected(*on).min_size(vec2(40.0, 30.0))).clicked() {
@@ -328,12 +328,12 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
egui::Window::new(title).id(egui::Id::new("shell-dialog")).collapsible(false).resizable(false).anchor(Align2::CENTER_CENTER, vec2(0.0, 0.0)).show(
ctx,
|ui| {
- ui.label(RichText::new(title).color(t.text).size(13.0).strong());
+ ui.label(RichText::new(tl!(&title)).color(t.text).size(13.0).strong());
crate::widgets::hairline(ui);
ui.add_space(6.0);
let text = |ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str| {
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim).size(11.0));
let mut v = f.get(key).and_then(Value::as_str).unwrap_or("").to_string();
if ui.add(egui::TextEdit::singleline(&mut v).desired_width(180.0)).changed() {
f.insert(key.into(), json!(v));
@@ -348,7 +348,7 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
};
let number = |ui: &mut egui::Ui, f: &mut Map<String, Value>, key: &str, label: &str, range: std::ops::RangeInclusive<f32>| {
ui.horizontal(|ui| {
- ui.label(RichText::new(label).color(t.text_dim).size(11.0));
+ ui.label(RichText::new(tl!(&label)).color(t.text_dim).size(11.0));
let mut v = f.get(key).and_then(Value::as_f64).unwrap_or(0.0) as f32;
if crate::widgets::slider(ui, &mut v, range.clone(), None).changed() | crate::widgets::value_field(ui, &mut v, range, "", 60.0).changed() {
f.insert(key.into(), json!(v));
@@ -357,16 +357,16 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
};
match kind.as_str() {
"newWorkspace" => {
- text(ui, &mut f, "name", "Name:");
- ui.label(RichText::new("Capture").color(t.text_dim).size(11.0));
+ text(ui, &mut f, "name", tl!("Name:"));
+ ui.label(RichText::new(tl!("Capture")).color(t.text_dim).size(11.0));
ui.label(
- RichText::new("Panel locations are saved in the workspace. Keyboard shortcuts, menus and toolbar are optional.")
+ RichText::new(tl!("Panel locations are saved in the workspace. Keyboard shortcuts, menus and toolbar are optional."))
.color(t.text_faint)
.size(10.5),
);
- check(ui, &mut f, "keyboardShortcuts", "Keyboard Shortcuts");
- check(ui, &mut f, "menus", "Menus");
- check(ui, &mut f, "toolbar", "Toolbar");
+ check(ui, &mut f, "keyboardShortcuts", tl!("Keyboard Shortcuts"));
+ check(ui, &mut f, "menus", tl!("Menus"));
+ check(ui, &mut f, "toolbar", tl!("Toolbar"));
}
"deleteWorkspace" => {
let mut cur = f.get("name").and_then(Value::as_str).unwrap_or("").to_string();
@@ -376,8 +376,8 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
}
}
"customPar" => {
- text(ui, &mut f, "name", "Name:");
- number(ui, &mut f, "ratio", "Factor:", 0.1..=10.0);
+ text(ui, &mut f, "name", tl!("Name:"));
+ number(ui, &mut f, "ratio", tl!("Factor:"), 0.1..=10.0);
}
"preview32" => {
let mut m = f.get("method").and_then(Value::as_str).unwrap_or("exposureGamma").to_string();
@@ -385,31 +385,31 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
ui,
"p32-method",
&mut m,
- &[("exposureGamma".to_string(), "Exposure and Gamma"), ("highlightCompression".to_string(), "Highlight Compression")],
+ &[("exposureGamma".to_string(), tl!("Exposure and Gamma")), ("highlightCompression".to_string(), tl!("Highlight Compression"))],
180.0,
) {
f.insert("method".into(), json!(m));
}
ui.add_enabled_ui(m == "exposureGamma", |ui| {
- number(ui, &mut f, "exposure", "Exposure:", -20.0..=20.0);
- number(ui, &mut f, "gamma", "Gamma:", 0.1..=9.99);
+ number(ui, &mut f, "exposure", tl!("Exposure:"), -20.0..=20.0);
+ number(ui, &mut f, "gamma", tl!("Gamma:"), 0.1..=9.99);
});
}
_ => {
for (k, label) in [
- ("layerEdges", "Layer Edges"),
- ("selectionEdges", "Selection Edges"),
- ("targetPath", "Target Path"),
- ("notes", "Notes"),
- ("pixelGrid", "Pixel Grid"),
- ("slices", "Slices"),
- ("count", "Count"),
- ("smartGuides", "Smart Guides"),
- ("brushPreview", "Brush Preview"),
- ("mesh", "Mesh"),
- ("editPins", "Edit Pins"),
- ("canvasGuides", "Canvas Guides"),
- ("artboardGuides", "Artboard Guides"),
+ ("layerEdges", tl!("Layer Edges")),
+ ("selectionEdges", tl!("Selection Edges")),
+ ("targetPath", tl!("Target Path")),
+ ("notes", tl!("Notes")),
+ ("pixelGrid", tl!("Pixel Grid")),
+ ("slices", tl!("Slices")),
+ ("count", tl!("Count")),
+ ("smartGuides", tl!("Smart Guides")),
+ ("brushPreview", tl!("Brush Preview")),
+ ("mesh", tl!("Mesh")),
+ ("editPins", tl!("Edit Pins")),
+ ("canvasGuides", tl!("Canvas Guides")),
+ ("artboardGuides", tl!("Artboard Guides")),
] {
check(ui, &mut f, k, label);
}
@@ -422,7 +422,7 @@ fn dialog(app: &mut PhotocraftApp, ctx: &egui::Context) {
if crate::widgets::primary_button(ui, ok, 70.0).clicked() {
result = Some(true);
}
- if crate::widgets::secondary_button(ui, "Cancel", 70.0).clicked() {
+ if crate::widgets::secondary_button(ui, tl!("Cancel"), 70.0).clicked() {
result = Some(false);
}
});
diff --git a/docs/scorecard.md b/docs/scorecard.md
index 57dbb6102..f17e02b73 100644
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js
| [Performance](#performance) | 3 | 22 | 10 | 44 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 0 not run, 10 not measurable yet (baseline 2026-10-05) |
| [File compatibility](#file-compatibility) | 0 | 6 | 21 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 229/309, round trip ≥ 307/309; photoshop oracles: oracle ≥ 126/256, round trip ≥ 256/256 |
| [Tools](#tools) | 0 | 16 | 14 | |
-| [Workspace and UI](#workspace-and-ui) | 0 | 3 | 20 | settings that do nothing: 61 of 131 (target 0) |
+| [Workspace and UI](#workspace-and-ui) | 0 | 3 | 20 | settings that do nothing: 61 of 132 (target 0) |
| [Type](#type) | 0 | 3 | 6 | |
| [Automation](#automation) | 1 | 3 | 7 | 626 of 626 menu items live (100.0%) |
| [Reliability](#reliability) | 2 | 1 | 4 | never-crash lints on 26 of 26 crates; panic_hunt present |
@@ -151,7 +151,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
## Workspace and UI
-**Settings that do nothing: 61 of 131** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
+**Settings that do nothing: 61 of 132** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.
Unread: `general.color_picker`, `general.beep_when_done`, `general.export_clipboard`, `general.resize_image_during_place`, `general.always_create_smart_objects_when_placing`, `general.animated_zoom`, `general.zoom_resizes_windows`, `general.use_legacy_free_transform`, `interface.ui_font_size`, `interface.show_channels_in_color`, `interface.dynamic_color_sliders`, `workspace.auto_collapse_icon_panels`, `workspace.auto_show_hidden_panels`, `workspace.open_documents_as_tabs`, `workspace.enable_floating_document_window_docking`, `workspace.large_tabs`, `workspace.enable_narrow_options_bar`, `tools.zoom_clicked_point_to_center`, `tools.enable_flick_panning`, `tools.vary_round_brush_hardness_on_hud`, `tools.show_transformation_values`, `tools.overscroll`, `tools.double_click_layer_mask_launches_select_and_mask`, `file_handling.image_previews`, `file_handling.lowercase_extension`, `file_handling.save_in_background`, `file_handling.ignore_exif_profile_tag`, `file_handling.ask_before_saving_layered_tiff`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `cursors.brush_preview_color`, `units_and_rulers.type_units`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `units_and_rulers.print_resolution`, `units_and_rulers.screen_resolution`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.smart_quotes`, `type_.missing_glyph_protection`, `type_.show_font_names_in_english`, `type_.use_esc_to_commit`, `type_.text_engine`, `type_.font_preview`, `type_.fill_new_type_layers_with_placeholder`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `enhanced_controls.zoom_with_trackpad_pinch`, `enhanced_controls.rotate_view_with_trackpad`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.
diff --git a/docs/ui-design.md b/docs/ui-design.md
index 63514644b..94fbf3c4d 100644
--- a/docs/ui-design.md
+++ b/docs/ui-design.md
@@ -63,3 +63,32 @@ including portrait displays, and updates when the window moves between monitors.
size is unavailable, Auto follows system DPI. The 100% and 200% choices set an absolute UI
scale, allowing large 4K displays to use smaller controls when desired. Canvas zoom shortcuts
continue to control the document independently of UI scaling.
+
+## Localisation
+
+Strings in code stay English and are the default lookup keys. `crates/ui-egui/src/i18n` maps them
+to display text at render time from one catalog per language (`i18n/<code>.tsv`; the format is
+documented in the header of `ja.tsv`). Command ids, menu paths used for logic, the control channel,
+the CLI and MCP always use the English ids and labels.
+
+- `tr(lang, s)` plain strings; `tr_ctx` when one English word needs different translations;
+ `tr_id(lang, command_id, label)` for menu items (keyed by command id, English label as the
+ fallback); `trn(lang, n, one, other)` for plurals; `fmt` fills `{name}` placeholders, which
+ translators may reorder.
+- The language is Preferences › Interface › Language (`interface.language`: `auto` or a language
+ code; `auto` follows the system locale, an unknown code falls back to `auto`).
+- To add a language: add `<code>.tsv` and one row in `i18n::LANGUAGES` (code, native name, catalog,
+ plural rule). The dropdown, locale matching and the catalog tests (well-formed, no duplicates,
+ placeholders and ellipses agree, command ids exist) pick it up. Set `complete_menus` once every
+ menu string is translated; a test then enforces it.
+- Translations are clean-room: written from the meaning of the English text in ordinary vocabulary,
+ never from another product's localisation resources.
+
+Localised so far: menus, the command palette, dialogs and panels (literals wrapped in `tl!("…")`;
+widgets such as `checkbox`, `slider_row`, `dropdown` and the buttons translate their labels
+themselves). A test fails when a `tl!` literal, a menu string, a blend mode name or a generated
+preference label has no entry in a language marked `complete_menus`. Not translated: status-bar
+messages and errors (they stay English, also for agents), names that are user data (layers, styles,
+documents), strings assembled with `format!` that were not converted to `fmt`/`trn`. Not done yet:
+per-language font fallback (the CJK fallback prefers Japanese forms), right-to-left layout,
+locale-aware number and date formats, automatic language detection on Windows and the web build.