Update banner and dialog: texts from the built-in English and Chinese catalog (Ely UPD-1)
This commit is contained in:
2 files changed
+41
-14
No files matched your search
@@ -41,6 +41,16 @@ const EN: &[(&str, &str)] = &[
|
|||||||
("templates.use", "Use template"),
|
("templates.use", "Use template"),
|
||||||
("templates.none", "No template matches"),
|
("templates.none", "No template matches"),
|
||||||
("comments.reply", "Reply"),
|
("comments.reply", "Reply"),
|
||||||
|
("update.title", "Software Update"),
|
||||||
|
("update.available", "Version {version} is available."),
|
||||||
|
("update.downloading", "Downloading {version}… {percent}%"),
|
||||||
|
("update.ready", "Version {version} is ready."),
|
||||||
|
("update.download", "Download"),
|
||||||
|
("update.restart", "Restart to update"),
|
||||||
|
("update.later", "Later"),
|
||||||
|
("update.headline.available", "{name} {version} is available"),
|
||||||
|
("update.headline.ready", "{name} {version} is ready"),
|
||||||
|
("update.current", "You have {current}."),
|
||||||
("comments.resolve", "Resolve"),
|
("comments.resolve", "Resolve"),
|
||||||
("comments.reopen", "Reopen"),
|
("comments.reopen", "Reopen"),
|
||||||
("comments.open", "Open {n}"),
|
("comments.open", "Open {n}"),
|
||||||
@@ -142,6 +152,16 @@ const ZH_CN: &[(&str, &str)] = &[
|
|||||||
("templates.use", "使用模板"),
|
("templates.use", "使用模板"),
|
||||||
("templates.none", "没有匹配的模板"),
|
("templates.none", "没有匹配的模板"),
|
||||||
("comments.reply", "回复"),
|
("comments.reply", "回复"),
|
||||||
|
("update.title", "软件更新"),
|
||||||
|
("update.available", "{version} 版可以更新。"),
|
||||||
|
("update.downloading", "正在下载 {version}… {percent}%"),
|
||||||
|
("update.ready", "{version} 版已下载好。"),
|
||||||
|
("update.download", "下载"),
|
||||||
|
("update.restart", "重新启动以更新"),
|
||||||
|
("update.later", "以后"),
|
||||||
|
("update.headline.available", "{name} {version} 可以更新"),
|
||||||
|
("update.headline.ready", "{name} {version} 已下载好"),
|
||||||
|
("update.current", "当前为 {current}。"),
|
||||||
("comments.resolve", "解决"),
|
("comments.resolve", "解决"),
|
||||||
("comments.reopen", "重新打开"),
|
("comments.reopen", "重新打开"),
|
||||||
("comments.open", "未解决 {n}"),
|
("comments.open", "未解决 {n}"),
|
||||||
|
|||||||
+21
-14
@@ -8,6 +8,7 @@ use gpui::{
|
|||||||
use super::{Hosted, open_hosted};
|
use super::{Hosted, open_hosted};
|
||||||
use crate::{
|
use crate::{
|
||||||
buttons::{Button, ButtonVariant, IconButton},
|
buttons::{Button, ButtonVariant, IconButton},
|
||||||
|
i18n::text,
|
||||||
layout::ScrollArea,
|
layout::ScrollArea,
|
||||||
motion::ProgressBar,
|
motion::ProgressBar,
|
||||||
primitives::{Icon, IconName},
|
primitives::{Icon, IconName},
|
||||||
@@ -43,7 +44,7 @@ fn progress_line(state: UpdateState) -> Option<AnyElement> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn buttons(state: UpdateState, actions: &Actions, size: ControlSize) -> Vec<Button> {
|
fn buttons(state: UpdateState, actions: &Actions, size: ControlSize, cx: &App) -> Vec<Button> {
|
||||||
let wire = |button: Button, action: &Option<Action>| {
|
let wire = |button: Button, action: &Option<Action>| {
|
||||||
action.clone().map(|action| {
|
action.clone().map(|action| {
|
||||||
button
|
button
|
||||||
@@ -52,17 +53,17 @@ fn buttons(state: UpdateState, actions: &Actions, size: ControlSize) -> Vec<Butt
|
|||||||
})
|
})
|
||||||
};
|
};
|
||||||
let later = wire(
|
let later = wire(
|
||||||
Button::new("update-later", "Later").variant(ButtonVariant::Ghost),
|
Button::new("update-later", text(cx, "update.later", &[])).variant(ButtonVariant::Ghost),
|
||||||
&actions.later,
|
&actions.later,
|
||||||
);
|
);
|
||||||
let main = match state {
|
let main = match state {
|
||||||
UpdateState::Available => wire(
|
UpdateState::Available => wire(
|
||||||
Button::new("update-download", "Download").primary(),
|
Button::new("update-download", text(cx, "update.download", &[])).primary(),
|
||||||
&actions.download,
|
&actions.download,
|
||||||
),
|
),
|
||||||
UpdateState::Downloading(_) => None,
|
UpdateState::Downloading(_) => None,
|
||||||
UpdateState::Ready => wire(
|
UpdateState::Ready => wire(
|
||||||
Button::new("update-restart", "Restart to update").primary(),
|
Button::new("update-restart", text(cx, "update.restart", &[])).primary(),
|
||||||
&actions.restart,
|
&actions.restart,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -118,14 +119,16 @@ impl UpdateBanner {
|
|||||||
|
|
||||||
impl RenderOnce for UpdateBanner {
|
impl RenderOnce for UpdateBanner {
|
||||||
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let theme = cx.theme();
|
let version = &self.version;
|
||||||
let message = match self.state {
|
let message = match self.state {
|
||||||
UpdateState::Available => format!("Version {} is available.", self.version),
|
UpdateState::Available => text(cx, "update.available", &[("version", version)]),
|
||||||
UpdateState::Downloading(value) => {
|
UpdateState::Downloading(value) => {
|
||||||
format!("Downloading {}… {}%", self.version, (value * 100.0).round())
|
let percent = (value * 100.0).round().to_string();
|
||||||
|
text(cx, "update.downloading", &[("version", version), ("percent", &percent)])
|
||||||
}
|
}
|
||||||
UpdateState::Ready => format!("Version {} is ready.", self.version),
|
UpdateState::Ready => text(cx, "update.ready", &[("version", version)]),
|
||||||
};
|
};
|
||||||
|
let theme = cx.theme();
|
||||||
let dismiss = self.actions.later.clone();
|
let dismiss = self.actions.later.clone();
|
||||||
div()
|
div()
|
||||||
.id(self.id)
|
.id(self.id)
|
||||||
@@ -153,6 +156,7 @@ impl RenderOnce for UpdateBanner {
|
|||||||
..self.actions.clone()
|
..self.actions.clone()
|
||||||
},
|
},
|
||||||
ControlSize::Sm,
|
ControlSize::Sm,
|
||||||
|
cx,
|
||||||
))
|
))
|
||||||
.when_some(dismiss, |banner, dismiss| {
|
.when_some(dismiss, |banner, dismiss| {
|
||||||
banner.child(
|
banner.child(
|
||||||
@@ -210,18 +214,20 @@ impl UpdateDialog {
|
|||||||
|
|
||||||
pub fn open(self, cx: &mut App) -> anyhow::Result<WindowHandle<Hosted<UpdateDialog>>> {
|
pub fn open(self, cx: &mut App) -> anyhow::Result<WindowHandle<Hosted<UpdateDialog>>> {
|
||||||
let size = cx.theme().dialog_window();
|
let size = cx.theme().dialog_window();
|
||||||
open_hosted("Software Update", size, self, cx)
|
open_hosted(text(cx, "update.title", &[]), size, self, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce for UpdateDialog {
|
impl RenderOnce for UpdateDialog {
|
||||||
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
|
let args = [("name", self.name.as_ref()), ("version", self.version.as_ref())];
|
||||||
|
let headline = match self.state {
|
||||||
|
UpdateState::Ready => text(cx, "update.headline.ready", &args),
|
||||||
|
_ => text(cx, "update.headline.available", &args),
|
||||||
|
};
|
||||||
|
let current = text(cx, "update.current", &[("current", &self.current)]);
|
||||||
let theme = cx.theme();
|
let theme = cx.theme();
|
||||||
let colors = &theme.colors;
|
let colors = &theme.colors;
|
||||||
let headline = match self.state {
|
|
||||||
UpdateState::Ready => format!("{} {} is ready", self.name, self.version),
|
|
||||||
_ => format!("{} {} is available", self.name, self.version),
|
|
||||||
};
|
|
||||||
div()
|
div()
|
||||||
.flex_1()
|
.flex_1()
|
||||||
.min_h_0()
|
.min_h_0()
|
||||||
@@ -236,7 +242,7 @@ impl RenderOnce for UpdateDialog {
|
|||||||
.flex_col()
|
.flex_col()
|
||||||
.gap_1()
|
.gap_1()
|
||||||
.child(Title::new(headline))
|
.child(Title::new(headline))
|
||||||
.child(Caption::new(format!("You have {}.", self.current))),
|
.child(Caption::new(current)),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
div()
|
div()
|
||||||
@@ -265,6 +271,7 @@ impl RenderOnce for UpdateDialog {
|
|||||||
self.state,
|
self.state,
|
||||||
&self.actions,
|
&self.actions,
|
||||||
ControlSize::Md,
|
ControlSize::Md,
|
||||||
|
cx,
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user