mirror of
https://github.com/storytold/effectcraft.git
synced 2026-10-24 10:09:32 -06:00
i18n: Settings page titles read the menu bar's Settings rows
The panel catalog's \"Type\" is the kind (Camera Settings, the Project column), so the Type page drew as \"kind\" in Chinese; its title now comes from the app.settings menu row (文字), as the Settings submenu draws it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YMTAbGNRxnMEzRvYnQGphF
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
60dab98e9b
commit
ad8db289cf
@@ -173,6 +173,14 @@ pub(crate) fn command_label<'a>(command: &str, source: &'a str) -> &'a str {
|
||||
row(source).or_else(|| row(dotted.as_deref()?)).unwrap_or_else(|| tr(source))
|
||||
}
|
||||
|
||||
/// A Settings page's title as the menu bar's Settings submenu draws it, without the ellipsis; the
|
||||
/// panel catalog's row for pages that have no menu row. The panel catalog's "Type" is the kind
|
||||
/// (Camera Settings, the Project panel's column), while the Type page is about text.
|
||||
pub(crate) fn settings_page_title(title: &str) -> &str {
|
||||
let menu = menu_catalog(ui::current()).and_then(|c| c.iter().find(|(id, en, _)| *id == "app.settings" && en.strip_suffix("...") == Some(title)));
|
||||
menu.and_then(|(_, _, translated)| translated.strip_suffix("...")).unwrap_or_else(|| tr(title))
|
||||
}
|
||||
|
||||
/// `source` looked up in `catalog` by (command, English label); the source itself when the pair is
|
||||
/// absent, so computed labels and user names stay verbatim.
|
||||
fn lookup<'a>(catalog: &[(&str, &str, &'a str)], command: &str, source: &'a str) -> &'a str {
|
||||
@@ -6691,6 +6699,16 @@ mod tests {
|
||||
assert_eq!(command_label("window.panel", "Project"), "Project");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_page_titles_read_the_menu_row() {
|
||||
set_current("zh-hans");
|
||||
assert_eq!(settings_page_title("Type"), "文字");
|
||||
assert_eq!(tr("Type"), "类型");
|
||||
assert_eq!(settings_page_title("Roto Brush"), tr("Roto Brush"));
|
||||
set_current("en");
|
||||
assert_eq!(settings_page_title("Type"), "Type");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn match_system_takes_the_first_browser_language_with_a_catalog() {
|
||||
let tags = |t: &[&str]| t.iter().map(|s| s.to_string()).collect::<Vec<_>>();
|
||||
|
||||
@@ -677,7 +677,7 @@ pub fn show(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
|
||||
ui.painter().text(
|
||||
r.left_center() + vec2(10.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
tr(p.title),
|
||||
crate::i18n::settings_page_title(p.title),
|
||||
Tokens::ui(12.5),
|
||||
if sel { Color32::WHITE } else { t.text },
|
||||
);
|
||||
@@ -694,7 +694,7 @@ pub fn show(app: &mut EffectcraftApp, ctx: &egui::Context, t: &Tokens) {
|
||||
// dialog scrolled sideways a little (#284).
|
||||
ui.set_width(ui.available_width());
|
||||
let p = &all[idx];
|
||||
ui.label(RichText::new(tr(p.title)).font(Tokens::semibold(14.0)).color(t.tab_text_active));
|
||||
ui.label(RichText::new(crate::i18n::settings_page_title(p.title)).font(Tokens::semibold(14.0)).color(t.tab_text_active));
|
||||
ui.add_space(6.0);
|
||||
egui::ScrollArea::vertical().max_height((body_h - 30.0).max(0.0)).auto_shrink([false, false]).show(ui, |ui| {
|
||||
page_ui(app, ui, p, &cur, t, &mut acts);
|
||||
|
||||
Reference in New Issue
Block a user