多语言基础设施:rust-i18n 接入,界面语言默认跟随系统
文案放进 locales/<模块>.yml,经 crate::i18n 的 t! / tn! 取用;启动时先按设置定语言, 改设置时实时切换并发出 UiLocale。守卫测试检查两种语言齐全、占位一致、没有遗漏和死键。 UI 测试夹具固定中文并隔离本线程的语言。共用件(shared/)先转换。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8f7473e42
commit
1c855f1508
34 files changed
+921
-83
No files matched your search
@@ -12,7 +12,7 @@ pub fn open_workspace_with_tester(
|
||||
store: HostStore,
|
||||
tester: Arc<FakeConnectionTester>,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
let mut workspace = None;
|
||||
let handle = cx.open_window(size(px(1280.), px(800.)), |window, cx| {
|
||||
@@ -23,7 +23,7 @@ pub fn open_workspace_with_tester(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
@@ -11,7 +11,7 @@ pub fn open_workspace_with_credentials(
|
||||
remote: Arc<RecordingRemoteProvider>,
|
||||
tester: Arc<FakeConnectionTester>,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
let mut workspace = None;
|
||||
let handle = cx.open_window(size(px(1280.), px(800.)), |window, cx| {
|
||||
@@ -19,7 +19,7 @@ pub fn open_workspace_with_credentials(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
@@ -142,7 +142,7 @@ pub fn open_sized_workspace_with_forwards(
|
||||
provider: Arc<FakeForwardProvider>,
|
||||
window_size: gpui_kit::Size<gpui_kit::Pixels>,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
// The forward dialog's diagram plays a flow over real time, and dialogs
|
||||
// slide in: both would move targets between locating and clicking them.
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
@@ -155,7 +155,7 @@ pub fn open_sized_workspace_with_forwards(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
@@ -109,6 +109,23 @@ pub fn one_host_store(auth: AuthKind) -> (HostStore, HostId) {
|
||||
(store, id)
|
||||
}
|
||||
|
||||
/// What every fixture starts with: ShellRS's globals, in Chinese, the
|
||||
/// language the assertions are written in. The test's interface language is
|
||||
/// its own, so one that switches to English switches no other test.
|
||||
pub fn init_app(cx: &mut TestAppContext) {
|
||||
shellrs::i18n::isolate_thread();
|
||||
shellrs::i18n::set_locale("zh-CN");
|
||||
cx.update(shellrs::init);
|
||||
}
|
||||
|
||||
/// Settings kept in memory, in Chinese: by default the interface follows the
|
||||
/// system, and CI's is English.
|
||||
pub fn settings_store() -> SettingsStore {
|
||||
let mut store = SettingsStore::in_memory();
|
||||
store.update_unnotified(|settings| settings.language = InterfaceLanguage::SimplifiedChinese);
|
||||
store
|
||||
}
|
||||
|
||||
pub fn appearance_dropdown(window: &mut gpui_kit::Window, item: usize) -> Option<String> {
|
||||
window
|
||||
.within("settings")
|
||||
|
||||
@@ -435,7 +435,7 @@ pub fn open_workspace_with_services(
|
||||
provider: Arc<FakeSftpProvider>,
|
||||
local: FakeLocalDirectory,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
// Dialogs slide in over real time; small targets such as checkboxes
|
||||
// would move between the frame that locates them and the click.
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
@@ -448,7 +448,7 @@ pub fn open_workspace_with_services(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
provider,
|
||||
|
||||
@@ -204,7 +204,7 @@ pub fn open_workspace_with_remote_factory(
|
||||
store: HostStore,
|
||||
factory: Arc<dyn TerminalTransportFactory>,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
// Dialogs still, as in every fixture: see `open_workspace_with_tester`.
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
let mut workspace = None;
|
||||
@@ -214,7 +214,7 @@ pub fn open_workspace_with_remote_factory(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
@@ -7,7 +7,7 @@ fn open_workspace_with_factory(
|
||||
cx: &mut TestAppContext,
|
||||
factory: Arc<FakeTerminalFactory>,
|
||||
) -> (WindowHandle<Root>, Entity<Workspace>) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
// Dialogs still, as in every fixture: see `open_workspace_with_tester`.
|
||||
cx.update(|cx| cx.set_reduce_motion(true));
|
||||
let mut workspace = None;
|
||||
@@ -19,7 +19,7 @@ fn open_workspace_with_factory(
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
factory.clone(),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
@@ -797,7 +797,7 @@ async fn a_dialog_says_what_is_wrong_in_a_notification_that_goes_with_it(cx: &mu
|
||||
/// crashed the app at launch.
|
||||
#[gpui_kit::test]
|
||||
fn a_problem_found_while_the_window_is_built_is_shown_once_it_is_open(cx: &mut TestAppContext) {
|
||||
cx.update(shellrs::init);
|
||||
init_app(cx);
|
||||
let handle = cx.open_window(size(px(1280.), px(800.)), |window, cx| {
|
||||
let store = cx.new(|_| HostStore::empty());
|
||||
let remote = Arc::new(FixedRemoteTerminalTransportProvider::new(Arc::new(
|
||||
@@ -806,7 +806,7 @@ fn a_problem_found_while_the_window_is_built_is_shown_once_it_is_open(cx: &mut T
|
||||
let view = cx.new(|cx| {
|
||||
Workspace::new_with_services(
|
||||
store,
|
||||
cx.new(|_| SettingsStore::in_memory()),
|
||||
cx.new(|_| settings_store()),
|
||||
remote,
|
||||
Arc::new(FakeTerminalFactory::default()),
|
||||
Arc::new(FakeSftpProvider::default()),
|
||||
|
||||
Reference in new issue
Block a user