Merge pull request #9679 from dotCooCoo/fix/stroke-miter-limit-localization

Use the existing Miter Limit translations in the Stroke panel
This commit is contained in:
.CooCoo authored and GitHub committed 2026-11-26 21:34:54 -08:00
commit f7cbd78cad
2 files changed
+57 -3

No files matched your search

+13 -3
View File
@@ -371,6 +371,8 @@ pub(crate) fn link_field(app: &mut VectorcraftApp, ui: &mut Ui, label: &'static
/// The Stroke panel: the weight, the stroke editor (cap, corner, align, dashes), arrowheads, scale, align and the
/// width profile.
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
use craft::ui::runtime::env::{WordRows, WordsOverride, with_env};
let st = current_stroke(app);
let mixed = stroke_mixed(app, ui.ctx());
let weight = shown_weight(app, st.as_ref(), &mixed);
@@ -381,11 +383,19 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
return;
}
let style = style_of(st.as_ref());
let output = StrokeEditor::new(tl!("Stroke"), Bind::given(style.clone()))
let editor = StrokeEditor::new(tl!("Stroke"), Bind::given(style.clone()))
.sections(StrokeSections::PANEL | StrokeSections::DASH_ALIGN)
.closed(mixed.can_align)
.mixed(&mixed_of(&mixed))
.show(ui);
.mixed(&mixed_of(&mixed));
// VectorCraft's catalog calls this field "Miter Limit".
let word = craft::i18n::Word::keyed("strokeEditor.miterLimit", "Miter limit");
let lang = app.ui_language();
let translated = crate::i18n::tr(lang, "Miter Limit");
let output = if translated != "Miter Limit" && crate::i18n::tr_id(lang, word.id, word.english) == word.english {
with_env(ui, |env| env.words = Some(WordsOverride::Overlay(WordRows::new().row(word, translated))), |ui| editor.show(ui))
} else {
editor.show(ui)
};
if let (Some(new), Some(field)) = (output.events.landed(), output.field) {
apply_style(app, &style, new.clone(), field);
}
@@ -191,3 +191,47 @@ fn the_spinner_of_a_blank_weight_steps_from_a_quarter_point() {
}
}
}
#[test]
fn compact_stroke_miter_limit_uses_the_interface_language() {
use crate::i18n::{Lang, LangExt as _, tr};
use craft::ui::contract::Role;
use egui::{Key, Pos2, Rect};
for lang in ["en", "fr", "de", "el"] {
let name = if lang == "en" {
"Miter limit"
} else {
let name = tr(Lang::from_code(lang).unwrap(), "Miter Limit");
assert_ne!(name, "Miter Limit", "{lang} has a catalog entry");
name
};
for width in [crate::panel_docking::PANEL_MIN_WIDTH, 320.0] {
let mut app = app_with_rect();
app.session.prefs.interface_language = lang.into();
run(&mut app, "paint.setStroke", json!({"color": "#222222"}));
run(&mut app, "stroke.set", json!({"join": "miter", "miterLimit": 4}));
let original = current_stroke(&app).unwrap();
let baseline = app.session.active().unwrap().history.undo.len();
let mut panel = Panel::new(app, stroke::show);
let room = egui::vec2(width, 500.0);
panel.room(room).frame();
let field = panel.rect_role(name, Role::SPIN_BUTTON);
assert!(Rect::from_min_size(Pos2::ZERO, room).contains_rect(field), "{lang} {width}: {field:?}");
let value = panel.app().host.i18n().unwrap().format().number(8.5, 1);
panel.click_at(field.center());
panel.key(Key::A, Modifiers::COMMAND);
panel.type_text(&value);
panel.key(Key::Enter, Modifiers::NONE);
let mut expected = original.clone();
expected.miter_limit = 8.5;
assert_eq!(current_stroke(&panel.app()).unwrap(), expected, "{lang} {width}: {name}");
assert_eq!(panel.app().session.active().unwrap().history.undo.len(), baseline + 1);
panel.app().run("edit.undo", json!({})).unwrap();
panel.frame();
assert_eq!(current_stroke(&panel.app()).unwrap(), original);
}
}
}