feat: add multi-language (i18n) support with Japanese UI
This commit is contained in:
1 parent
fc8b71956c
commit
3afd6ae447
11 files changed
+647
-80
No files matched your search
@@ -307,7 +307,14 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
|
||||
t.app_bar
|
||||
},
|
||||
);
|
||||
ui.painter().text(home.center(), Align2::CENTER_CENTER, "Home", FontId::proportional(13.0), if app.home.open { t.text } else { t.app_bar_text });
|
||||
let home_text = app.tr("Home");
|
||||
ui.painter().text(
|
||||
home.center(),
|
||||
Align2::CENTER_CENTER,
|
||||
home_text,
|
||||
FontId::proportional(13.0),
|
||||
if app.home.open { t.text } else { t.app_bar_text },
|
||||
);
|
||||
crate::scenario::publish_handle("tab:home", home.center());
|
||||
if response.clicked() {
|
||||
app.home.show(app.session.revision);
|
||||
@@ -342,7 +349,8 @@ pub fn tabs(app: &mut SolveApp, ui: &mut egui::Ui, r: Rect, x0: f32, x1: f32) {
|
||||
};
|
||||
ui.painter().rect_filled(tr, egui::CornerRadius { nw: 5, ne: 5, sw: 0, se: 0 }, fill);
|
||||
let ink = if active { t.text } else { t.app_bar_text };
|
||||
let label = format!("{name}{}", if *dirty { " •" } else { "" });
|
||||
let name_display = if name == "Untitled" { app.tr("Untitled") } else { name };
|
||||
let label = format!("{name_display}{}", if *dirty { " •" } else { "" });
|
||||
let g = ui.painter().layout_no_wrap(label, FontId::proportional(13.0), ink);
|
||||
let text_w = (tr.width() - 30.0).max(10.0);
|
||||
let clip = Rect::from_min_size(tr.min, vec2(text_w + 10.0, tr.height()));
|
||||
@@ -447,23 +455,33 @@ pub fn prompt(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
quit_step(app);
|
||||
let Some(i) = app.docs.closing else { return };
|
||||
let name = tabs_info(app).get(i).map(|x| x.0.clone()).unwrap_or_default();
|
||||
let name_display = if name == "Untitled" { crate::i18n::tr("Untitled") } else { &name };
|
||||
let mut answer: Option<Answer> = None;
|
||||
crate::frame::window(ctx, format!("Save changes to {name}?"), crate::frame::Width::Normal)
|
||||
let title = if crate::i18n::current_lang() == "ja" {
|
||||
format!("{name_display} への変更を保存しますか?")
|
||||
} else {
|
||||
format!("Save changes to {name}?")
|
||||
};
|
||||
crate::frame::window(ctx, title, crate::frame::Width::Normal)
|
||||
.id(egui::Id::new("sc_close_prompt"))
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.anchor(Align2::CENTER_CENTER, vec2(0.0, 0.0))
|
||||
.show(ctx, |ui| {
|
||||
ui.label(format!("{name} has unsaved changes. If you don't save, they are lost."));
|
||||
if crate::i18n::current_lang() == "ja" {
|
||||
ui.label(format!("{name_display} には保存されていない変更があります。保存しない場合、変更内容は失われます。"));
|
||||
} else {
|
||||
ui.label(format!("{name} has unsaved changes. If you don't save, they are lost."));
|
||||
}
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Save").clicked() {
|
||||
if ui.button(crate::i18n::tr("Save")).clicked() {
|
||||
answer = Some(Answer::Save);
|
||||
}
|
||||
if ui.button("Don't Save").clicked() {
|
||||
if ui.button(crate::i18n::tr("Don't Save")).clicked() {
|
||||
answer = Some(Answer::DontSave);
|
||||
}
|
||||
if ui.button("Cancel").clicked() {
|
||||
if ui.button(crate::i18n::tr("Cancel")).clicked() {
|
||||
answer = Some(Answer::Cancel);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user