mirror of
https://github.com/storytold/gridcraft.git
synced 2026-11-22 05:52:37 -06:00
i18n(ru): name the Insert tab «Вставка», translate AutoSave
Russian names the Insert tab and the Insert command differently («Вставка» vs «Вставить»). Ribbon tabs now look up a `Tab|<name>` key first and fall back to the plain label, so other languages are unchanged. Also translates the AutoSave toggle and adds the two French header/footer labels whose absence failed the catalog completeness test.
This commit is contained in:
@@ -112,7 +112,19 @@ impl Language {
|
||||
/// A label that needs two translations (Home's text "Orientation" vs Page Layout's print
|
||||
/// "Orientation") is keyed `context|label`: English shows only the part after the `|`.
|
||||
pub fn tr(self, text: &str) -> &str {
|
||||
let translated = match self {
|
||||
self.lookup(text).unwrap_or_else(|| text.rsplit_once('|').map_or(text, |(_, label)| label))
|
||||
}
|
||||
|
||||
/// A ribbon tab's name. Where a language names the tab differently from a command with the
|
||||
/// same English label (Russian: the Insert tab is «Вставка», the Insert button «Вставить»), its
|
||||
/// catalog keys the tab `Tab|name`; every other language falls back to the plain label.
|
||||
pub fn tr_tab(self, tab: &str) -> &str {
|
||||
self.lookup(&format!("Tab|{tab}")).unwrap_or_else(|| self.tr(tab))
|
||||
}
|
||||
|
||||
/// The catalog entry for `text`, if this language has one.
|
||||
fn lookup(self, text: &str) -> Option<&'static str> {
|
||||
match self {
|
||||
Self::En => None,
|
||||
Self::Es => es::translate(text),
|
||||
Self::Ja => JAPANESE.iter().find(|(english, _)| *english == text).map(|(_, translated)| *translated),
|
||||
@@ -123,8 +135,7 @@ impl Language {
|
||||
Self::De => de::translate(text),
|
||||
Self::Cs => cs::translate(text),
|
||||
Self::Fr => fr::translate(text),
|
||||
};
|
||||
translated.unwrap_or_else(|| text.rsplit_once('|').map_or(text, |(_, label)| label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,6 +603,13 @@ mod tests {
|
||||
assert_eq!(Language::Zh.tr("Data"), "数据");
|
||||
assert_eq!(Language::Ko.tr("Data"), "데이터");
|
||||
assert_eq!(Language::Ru.tr("Data"), "Данные");
|
||||
// The Insert tab and the Insert command have different Russian names; elsewhere the tab
|
||||
// name is the plain label.
|
||||
assert_eq!(Language::Ru.tr_tab("Insert"), "Вставка");
|
||||
assert_eq!(Language::Ru.tr("Insert"), "Вставить");
|
||||
assert_eq!(Language::Ru.tr_tab("Data"), "Данные");
|
||||
assert_eq!(Language::Es.tr_tab("Insert"), Language::Es.tr("Insert"));
|
||||
assert_eq!(Language::En.tr_tab("Insert"), "Insert");
|
||||
assert_eq!(Language::PtBr.tr("Data"), "Dados");
|
||||
assert_eq!(Language::Es.tr("Data"), "Datos");
|
||||
assert_eq!(Language::Es.tr("Freeze Panes"), "Inmovilizar paneles");
|
||||
|
||||
@@ -381,6 +381,8 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
|
||||
"Workbook calculation" => "Calcul du classeur",
|
||||
"Enable iterative calculation" => "Classeur Excel (*.xlsx)",
|
||||
"Calculation settings are saved with the workbook." => "Modifier le type de fichier",
|
||||
"Different First Page" => "Première page différente",
|
||||
"Different Odd & Even Pages" => "Pages paires et impaires différentes",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -960,6 +960,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
|
||||
"— VBA project (preserved, not run)" => "— проект VBA (сохраняется, не выполняется)",
|
||||
"— {steps} steps" => "— шагов: {steps}",
|
||||
"€ Euro" => "€ евро",
|
||||
"Tab|Insert" => "Вставка",
|
||||
"AutoSave" => "Автосохранение",
|
||||
"AutoSave: save after every change (workbooks saved to a file)" => {
|
||||
"Автосохранение: сохранять после каждого изменения (для книг, сохранённых в файл)"
|
||||
}
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -52,14 +52,14 @@ pub fn title_bar(app: &mut SheetApp, ui: &mut Ui) {
|
||||
ui.horizontal_centered(|ui| {
|
||||
ui.add_space(TITLE_LEFT_PAD);
|
||||
// AutoSave toggle (saves after each change when the workbook has a file).
|
||||
ui.label(egui::RichText::new("AutoSave").font(theme::ui_font(12.5)).color(t.text_dim));
|
||||
ui.label(egui::RichText::new(app.ui.language.tr("AutoSave")).font(theme::ui_font(12.5)).color(t.text_dim));
|
||||
let on = app.grid.autosave();
|
||||
let (r, resp) = ui.allocate_exact_size(vec2(30.0, 16.0), Sense::click());
|
||||
ui.painter().rect_filled(r, 8.0, if on { t.accent } else { Color32::TRANSPARENT });
|
||||
ui.painter().rect_stroke(r, 8.0, Stroke::new(1.0, if on { t.accent } else { t.text_dim }), StrokeKind::Inside);
|
||||
let knob = if on { pos2(r.right() - 8.0, r.center().y) } else { pos2(r.left() + 8.0, r.center().y) };
|
||||
ui.painter().circle_filled(knob, 5.0, if on { Color32::WHITE } else { t.text_dim });
|
||||
if resp.on_hover_text("AutoSave: save after every change (workbooks saved to a file)").clicked() {
|
||||
if resp.on_hover_text(app.ui.language.tr("AutoSave: save after every change (workbooks saved to a file)")).clicked() {
|
||||
app.grid.toggle_autosave();
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
@@ -181,7 +181,7 @@ pub fn show(app: &mut SheetApp, ui: &mut Ui) {
|
||||
let active = app.ui.ribbon_tab == tab;
|
||||
let contextual = ctx_tabs.contains(&tab);
|
||||
let font = theme::ui_font(13.5);
|
||||
let label = app.ui.language.tr(tab);
|
||||
let label = app.ui.language.tr_tab(tab);
|
||||
let tw = ui.painter().layout_no_wrap(label.to_string(), font.clone(), t.text).size().x;
|
||||
let (r, resp) = ui.allocate_exact_size(vec2(tw + 22.0, 30.0), Sense::click());
|
||||
if resp.hovered() && !active {
|
||||
|
||||
Reference in New Issue
Block a user