Skip to content

Commit

Permalink
Add I18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Jul 19, 2024
1 parent 272be98 commit dfcfe37
Show file tree
Hide file tree
Showing 16 changed files with 711 additions and 89 deletions.
158 changes: 156 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"crates/headless",
"crates/html_to_markdown",
"crates/http",
"crates/i18n",
"crates/image_viewer",
"crates/indexed_docs",
"crates/inline_completion_button",
Expand Down Expand Up @@ -196,6 +197,7 @@ gpui_macros = { path = "crates/gpui_macros" }
headless = { path = "crates/headless" }
html_to_markdown = { path = "crates/html_to_markdown" }
http = { path = "crates/http" }
i18n = { path = "crates/i18n" }
image_viewer = { path = "crates/image_viewer" }
indexed_docs = { path = "crates/indexed_docs" }
inline_completion_button = { path = "crates/inline_completion_button" }
Expand Down Expand Up @@ -350,6 +352,7 @@ runtimelib = { version = "0.12", default-features = false, features = [
] }
rusqlite = { version = "0.29.0", features = ["blob", "array", "modern_sqlite"] }
rust-embed = { version = "8.4", features = ["include-exclude"] }
rust-i18n = "3"
schemars = "0.8"
semver = "1.0"
serde = { version = "1.0", features = ["derive", "rc"] }
Expand Down
25 changes: 25 additions & 0 deletions assets/locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
About Zed…: About Zed…
Check for Updates: Check for Updates
Settings: Settings
Extensions: Extensions
Themes…: Themes…
Sign in: Sign In
Sign Out: Sign Out
Toggle User Menu: Toggle User Menu
File: File
Edit: Edit
New: New
New Window: New Window
Open…: Open…
Open Recent...: Open Recent...
Add Folder to Project…: Add Folder to Project…
Save: Save
Save As…: Save As…
Save All: Save All
Close Editor: Close Editor
Close Window: Close Window
Undo: Undo
Redo: Redo
Cut: Cut
Copy: Copy
Paste: Paste
25 changes: 25 additions & 0 deletions assets/locales/zh-CN.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
About Zed…: 关于 Zed…
Check for Updates: 检查更新
Settings: 设置
Extensions: 扩展
Themes…: 主题…
Sign in: 登录
Sign Out: 登出
Toggle User Menu: 切换用户菜单
File: 文件
Edit: 编辑
New: 新建
New Window: 新建窗口
Open…: 打开…
Open Recent...: 打开最近…
Add Folder to Project…: 添加文件夹到项目…
Save: 保存
Save As…: 另存为…
Save All: 全部保存
Close Editor: 关闭编辑器
Close Window: 关闭窗口
Undo: 撤销
Redo: 重做
Cut: 剪切"
Copy: 复制
Paste: 粘贴
2 changes: 2 additions & 0 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"light": "One Light",
"dark": "One Dark"
},
// The UI language, which can be one of: en, zh-CN
"locale": "en",
// The name of a base set of key bindings to use.
// This setting can take four values, each named after another
// text editor:
Expand Down
1 change: 1 addition & 0 deletions crates/assets/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use rust_embed::RustEmbed;
#[include = "themes/**/*"]
#[exclude = "themes/src/*"]
#[include = "sounds/**/*"]
#[include = "locales/*"]
#[include = "*.md"]
#[exclude = "*.DS_Store"]
pub struct Assets;
Expand Down
2 changes: 2 additions & 0 deletions crates/collab_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ emojis.workspace = true
futures.workspace = true
fuzzy.workspace = true
gpui.workspace = true
i18n.workspace = true
language.workspace = true
lazy_static.workspace = true
menu.workspace = true
Expand All @@ -51,6 +52,7 @@ project.workspace = true
release_channel.workspace = true
rich_text.workspace = true
rpc.workspace = true
rust-i18n.workspace = true
schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true
Expand Down
5 changes: 3 additions & 2 deletions crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use gpui::{
Render, SharedString, Styled, Subscription, Task, TextStyle, View, ViewContext, VisualContext,
WeakView, WhiteSpace,
};
use i18n::t;
use menu::{Cancel, Confirm, SecondaryConfirm, SelectNext, SelectPrev};
use project::{Fs, Project};
use rpc::{
Expand Down Expand Up @@ -2057,7 +2058,7 @@ impl CollabPanel {
v_flex()
.gap_2()
.child(
Button::new("sign_in", "Sign in")
Button::new("sign_in", t!("Sign in"))
.icon_color(Color::Muted)
.icon(IconName::Github)
.icon_position(IconPosition::Start)
Expand All @@ -2076,7 +2077,7 @@ impl CollabPanel {
)
.child(
div().flex().w_full().items_center().child(
Label::new("Sign in to enable collaboration.")
Label::new(t!("Sign in to enable collaboration."))
.color(Color::Muted)
.size(LabelSize::Small),
),
Expand Down
Loading

0 comments on commit dfcfe37

Please sign in to comment.