Skip to content

PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.

界面支持中文、英文、日文:默认跟随系统语言,可在设置里切换

baiyuzecb9b43c2cdc0
diff --git a/README.md b/README.md
index 5315f0c..552abdc 100644
--- a/README.md
+++ b/README.md
@@ -28,7 +28,7 @@
</p>
<p align="center">
- <img src="docs/assets/screenshots/history.png" alt="CopySync's history view: files, images and text arriving from other Macs">
+ <img src="docs/assets/screenshots/en/history.png" alt="CopySync's history view: files, images and text arriving from other Macs">
</p>
> The app's interface is in Simplified Chinese for now. The screenshots below are annotated in the alt text.
@@ -69,12 +69,12 @@ With CopySync you pair two computers once. After that, copy on one and paste on
<table>
<tr>
- <td><img src="docs/assets/screenshots/devices.png" alt="Devices: paired Macs and whether each is connected directly or through the relay"></td>
- <td><img src="docs/assets/screenshots/verify.png" alt="Pairing: compare the fingerprint shown on both Macs before confirming"></td>
+ <td><img src="docs/assets/screenshots/en/devices.png" alt="Devices: paired Macs and whether each is connected directly or through the relay"></td>
+ <td><img src="docs/assets/screenshots/en/verify.png" alt="Pairing: compare the fingerprint shown on both Macs before confirming"></td>
</tr>
<tr>
- <td><img src="docs/assets/screenshots/settings.png" alt="Settings: server address, auto-sync size limit, content types"></td>
- <td><img src="docs/assets/screenshots/history-dark.png" alt="History in dark appearance"></td>
+ <td><img src="docs/assets/screenshots/en/settings.png" alt="Settings: server address, auto-sync size limit, content types"></td>
+ <td><img src="docs/assets/screenshots/en/history-dark.png" alt="History in dark appearance"></td>
</tr>
</table>
diff --git a/client-core/cmd/copysyncd/lang_other.go b/client-core/cmd/copysyncd/lang_other.go
new file mode 100644
index 0000000..0ba225b
--- /dev/null
+++ b/client-core/cmd/copysyncd/lang_other.go
@@ -0,0 +1,6 @@
+//go:build !windows
+
+package main
+
+// 只有 Windows 的托盘用得到;其他平台没有托盘。
+func systemLanguage() string { return "en" }
diff --git a/client-core/cmd/copysyncd/lang_windows.go b/client-core/cmd/copysyncd/lang_windows.go
new file mode 100644
index 0000000..14369ad
--- /dev/null
+++ b/client-core/cmd/copysyncd/lang_windows.go
@@ -0,0 +1,20 @@
+//go:build windows
+
+package main
+
+import "golang.org/x/sys/windows"
+
+var procGetUserDefaultUILanguage = windows.NewLazySystemDLL("kernel32.dll").NewProc("GetUserDefaultUILanguage")
+
+// systemLanguage 按 Windows 的界面语言返回 "zh"、"ja" 或 "en"。
+func systemLanguage() string {
+ id, _, _ := procGetUserDefaultUILanguage.Call()
+ switch id & 0x3ff { // 低 10 位是主语言
+ case 0x04: // LANG_CHINESE
+ return "zh"
+ case 0x11: // LANG_JAPANESE
+ return "ja"
+ default:
+ return "en"
+ }
+}
diff --git a/client-core/cmd/copysyncd/main.go b/client-core/cmd/copysyncd/main.go
index 18e1e38..8bb6d4e 100644
--- a/client-core/cmd/copysyncd/main.go
+++ b/client-core/cmd/copysyncd/main.go
@@ -386,6 +386,7 @@ func run(dataDir string) error {
// 托盘属于后台服务:关掉界面后仍能打开它。独立数据目录用于测试,
// 不创建托盘,避免与用户正在运行的实例混在一起。
+ trayLanguage = func() string { return loadCfg().Language }
stopTray := startTray(ctx, cancel, dataDir == "")
defer stopTray()
diff --git a/client-core/cmd/copysyncd/tray_labels.go b/client-core/cmd/copysyncd/tray_labels.go
new file mode 100644
index 0000000..b10d213
--- /dev/null
+++ b/client-core/cmd/copysyncd/tray_labels.go
@@ -0,0 +1,22 @@
+package main
+
+import "strings"
+
+// trayLanguage 返回界面语言设置(空字符串表示跟随系统)。由 run 在读到配置后设置,
+// 托盘每次弹出菜单时读取,用户在界面里改了语言,下次右键就是新语言。
+var trayLanguage = func() string { return "" }
+
+// trayLabels 返回托盘菜单的「打开」与「退出」两项。lang 为空时按系统界面语言。
+func trayLabels(lang string) (open, quit string) {
+ if lang == "" {
+ lang = systemLanguage()
+ }
+ switch {
+ case strings.HasPrefix(lang, "zh"):
+ return "打开 CopySync", "退出 CopySync"
+ case strings.HasPrefix(lang, "ja"):
+ return "CopySync を開く", "CopySync を終了"
+ default:
+ return "Open CopySync", "Quit CopySync"
+ }
+}
diff --git a/client-core/cmd/copysyncd/tray_labels_test.go b/client-core/cmd/copysyncd/tray_labels_test.go
new file mode 100644
index 0000000..edb1da7
--- /dev/null
+++ b/client-core/cmd/copysyncd/tray_labels_test.go
@@ -0,0 +1,16 @@
+package main
+
+import "testing"
+
+func TestTrayLabels(t *testing.T) {
+ cases := map[string]string{"zh-Hans": "打开 CopySync", "en": "Open CopySync", "ja": "CopySync を開く"}
+ for lang, want := range cases {
+ if open, _ := trayLabels(lang); open != want {
+ t.Errorf("trayLabels(%q) = %q,应为 %q", lang, open, want)
+ }
+ }
+ // 跟随系统时总有一个结果,不会是空的
+ if open, quit := trayLabels(""); open == "" || quit == "" {
+ t.Error("跟随系统时菜单文字为空")
+ }
+}
diff --git a/client-core/cmd/copysyncd/tray_windows.go b/client-core/cmd/copysyncd/tray_windows.go
index a8c8047..5039cd4 100644
--- a/client-core/cmd/copysyncd/tray_windows.go
+++ b/client-core/cmd/copysyncd/tray_windows.go
@@ -222,8 +222,9 @@ func (t *windowsTray) showMenu() {
return
}
defer trayDestroyMenu.Call(menu)
- open, _ := windows.UTF16PtrFromString("打开 CopySync")
- exit, _ := windows.UTF16PtrFromString("退出 CopySync")
+ openLabel, quitLabel := trayLabels(trayLanguage())
+ open, _ := windows.UTF16PtrFromString(openLabel)
+ exit, _ := windows.UTF16PtrFromString(quitLabel)
trayAppendMenu.Call(menu, 0, trayOpenCommand, uintptr(unsafe.Pointer(open)))
trayAppendMenu.Call(menu, 0x800, 0, 0) // MF_SEPARATOR
trayAppendMenu.Call(menu, 0, trayQuitCommand, uintptr(unsafe.Pointer(exit)))
diff --git a/client-core/internal/config/config.go b/client-core/internal/config/config.go
index fcb3fa5..77e551d 100644
--- a/client-core/internal/config/config.go
+++ b/client-core/internal/config/config.go
@@ -35,6 +35,10 @@ type Config struct {
// (与任何 WebRTC 应用一样,看不到内容),介意的用户可以关掉;代价是多出口网络里
// 可能探测不全,直连机会变小。
OnlyOwnSTUN bool `json:"only_own_stun"`
+
+ // Language 是界面语言:空字符串跟随系统,否则为 "zh-Hans"、"en"、"ja" 之一。
+ // 托盘菜单(Windows)也按它显示
+ Language string `json:"language,omitempty"`
}
func Default() Config {
@@ -80,6 +84,12 @@ func (c *Config) Validate() {
if c.CacheTTL > c.HistoryTTL {
c.CacheTTL = c.HistoryTTL
}
+ // 不认识的语言(比如更新版本的界面写进来的)当作跟随系统
+ switch c.Language {
+ case "", "zh-Hans", "en", "ja":
+ default:
+ c.Language = ""
+ }
}
// ─────────────────────────── 目录布局 ───────────────────────────
diff --git a/client-core/internal/config/config_test.go b/client-core/internal/config/config_test.go
index 0de93aa..a812421 100644
--- a/client-core/internal/config/config_test.go
+++ b/client-core/internal/config/config_test.go
@@ -143,6 +143,18 @@ func TestValidateCapsCacheTTLByHistoryTTL(t *testing.T) {
}
}
+// 界面语言只认这几种;别的值(拼错的、以后版本新增的)退回跟随系统。
+func TestValidateLanguage(t *testing.T) {
+ for in, want := range map[string]string{"": "", "zh-Hans": "zh-Hans", "en": "en", "ja": "ja", "fr": "", "zh": ""} {
+ c := Default()
+ c.Language = in
+ c.Validate()
+ if c.Language != want {
+ t.Errorf("Language %q 校验后为 %q,应为 %q", in, c.Language, want)
+ }
+ }
+}
+
func TestLoadRejectsCorruptFile(t *testing.T) {
p := PathsUnder(t.TempDir())
if err := p.EnsureDirs(); err != nil {
diff --git a/client-core/internal/rpc/convert.go b/client-core/internal/rpc/convert.go
index 243f661..8ed2b63 100644
--- a/client-core/internal/rpc/convert.go
+++ b/client-core/internal/rpc/convert.go
@@ -52,6 +52,7 @@ func configToProto(c config.Config) *pb.Config {
DeviceName: c.DeviceName,
SignalingUrl: c.SignalingURL,
OnlyOwnStun: c.OnlyOwnSTUN,
+ Language: c.Language,
}
}
@@ -85,6 +86,8 @@ func configFromProto(in *pb.Config, base config.Config) config.Config {
c.AutoApplyToClipboard = in.GetAutoApplyToClipboard()
c.LaunchAtLogin = in.GetLaunchAtLogin()
c.OnlyOwnSTUN = in.GetOnlyOwnStun()
+ // 空字符串就是「跟随系统」,与「没设置」同义,直接覆盖
+ c.Language = in.GetLanguage()
return c
}
diff --git a/docs/assets/screenshots/en/card-verify-dark.png b/docs/assets/screenshots/en/card-verify-dark.png
new file mode 100644
index 0000000..cb1bb2f
Binary files /dev/null and b/docs/assets/screenshots/en/card-verify-dark.png differ
diff --git a/docs/assets/screenshots/en/card-verify.png b/docs/assets/screenshots/en/card-verify.png
new file mode 100644
index 0000000..ac3ad3f
Binary files /dev/null and b/docs/assets/screenshots/en/card-verify.png differ
diff --git a/docs/assets/screenshots/en/devices.png b/docs/assets/screenshots/en/devices.png
new file mode 100644
index 0000000..5589903
Binary files /dev/null and b/docs/assets/screenshots/en/devices.png differ
diff --git a/docs/assets/screenshots/en/history-dark.png b/docs/assets/screenshots/en/history-dark.png
new file mode 100644
index 0000000..df7da39
Binary files /dev/null and b/docs/assets/screenshots/en/history-dark.png differ
diff --git a/docs/assets/screenshots/en/history.png b/docs/assets/screenshots/en/history.png
new file mode 100644
index 0000000..ab6fd13
Binary files /dev/null and b/docs/assets/screenshots/en/history.png differ
diff --git a/docs/assets/screenshots/en/pairing.png b/docs/assets/screenshots/en/pairing.png
new file mode 100644
index 0000000..13543e4
Binary files /dev/null and b/docs/assets/screenshots/en/pairing.png differ
diff --git a/docs/assets/screenshots/en/settings.png b/docs/assets/screenshots/en/settings.png
new file mode 100644
index 0000000..101f8dc
Binary files /dev/null and b/docs/assets/screenshots/en/settings.png differ
diff --git a/docs/assets/screenshots/en/verify.png b/docs/assets/screenshots/en/verify.png
new file mode 100644
index 0000000..3e1e736
Binary files /dev/null and b/docs/assets/screenshots/en/verify.png differ
diff --git a/docs/assets/screenshots/en/welcome.png b/docs/assets/screenshots/en/welcome.png
new file mode 100644
index 0000000..28e3696
Binary files /dev/null and b/docs/assets/screenshots/en/welcome.png differ
diff --git a/docs/assets/screenshots/history-dark.png b/docs/assets/screenshots/history-dark.png
index 3455b62..364f652 100644
Binary files a/docs/assets/screenshots/history-dark.png and b/docs/assets/screenshots/history-dark.png differ
diff --git a/docs/assets/screenshots/history.png b/docs/assets/screenshots/history.png
index 047da6d..8264af8 100644
Binary files a/docs/assets/screenshots/history.png and b/docs/assets/screenshots/history.png differ
diff --git a/docs/assets/screenshots/settings.png b/docs/assets/screenshots/settings.png
index 2bff6ae..20b1aff 100644
Binary files a/docs/assets/screenshots/settings.png and b/docs/assets/screenshots/settings.png differ
diff --git a/docs/en/index.html b/docs/en/index.html
index 4c1fd4c..10f5373 100644
--- a/docs/en/index.html
+++ b/docs/en/index.html
@@ -49,7 +49,7 @@
"downloadUrl": "https://github.com/baiyuze/copysync/releases/latest",
"codeRepository": "https://github.com/baiyuze/copysync",
"image": "https://baiyuze.github.io/copysync/assets/icon.png",
- "screenshot": "https://baiyuze.github.io/copysync/assets/screenshots/history.png",
+ "screenshot": "https://baiyuze.github.io/copysync/assets/screenshots/en/history.png",
"fileSize": "45MB",
"featureList": [
"Syncs plain text, rich text, images, files and folders",
@@ -184,8 +184,8 @@
<p class="intro">History keeps the last 3 days, ready to go back on the clipboard. Files under 50 MB have already arrived by the time you switch Macs; larger ones are a click away. The interface is in Simplified Chinese for now.</p>
<figure class="shot">
<picture>
- <source media="(prefers-color-scheme: dark)" srcset="../assets/screenshots/history-dark.png">
- <img src="../assets/screenshots/history.png" width="2112" height="1472" alt="CopySync history: files, images and text from a MacBook Air and a Mac mini; a large file shows a button to pull it to this Mac">
+ <source media="(prefers-color-scheme: dark)" srcset="../assets/screenshots/en/history-dark.png">
+ <img src="../assets/screenshots/en/history.png" width="2112" height="1472" alt="CopySync history: files, images and text from a MacBook Air and a Mac mini; a large file shows a button to pull it to this Mac">
</picture>
</figure>
</div>
@@ -348,8 +348,8 @@
</div>
<figure class="card-shot">
<picture>
- <source media="(prefers-color-scheme: dark)" srcset="../assets/screenshots/card-verify-dark.png">
- <img src="../assets/screenshots/card-verify.png" width="1120" height="800" loading="lazy" alt="The fingerprint check during pairing shows R8NF-2WTC-QL5J and asks you to confirm it matches the other Mac exactly">
+ <source media="(prefers-color-scheme: dark)" srcset="../assets/screenshots/en/card-verify-dark.png">
+ <img src="../assets/screenshots/en/card-verify.png" width="1120" height="800" loading="lazy" alt="The fingerprint check during pairing shows R8NF-2WTC-QL5J and asks you to confirm it matches the other Mac exactly">
</picture>
</figure>
</div>
diff --git a/proto/copysync/v1/daemon.proto b/proto/copysync/v1/daemon.proto
index 8c0ac31..fb7a7ca 100644
--- a/proto/copysync/v1/daemon.proto
+++ b/proto/copysync/v1/daemon.proto
@@ -226,6 +226,10 @@ message Config {
// 只用自己的服务器探测网络出口,不用公共 STUN 服务器。
// 默认 false(即允许公共服务器):旧版界面不发这个字段时,不会被误关掉。
bool only_own_stun = 12;
+
+ // 界面语言:空字符串表示跟随系统;否则是 "zh-Hans"、"en"、"ja" 之一。
+ // 存在后台服务这里而不是界面里:Windows 的托盘菜单由后台服务画,也要跟着变。
+ string language = 13;
}
// 最近一轮网络出口探测的结果。
diff --git a/proto/gen/copysync/v1/daemon.pb.go b/proto/gen/copysync/v1/daemon.pb.go
index 016b4f5..2e5a908 100644
--- a/proto/gen/copysync/v1/daemon.pb.go
+++ b/proto/gen/copysync/v1/daemon.pb.go
@@ -1431,7 +1431,10 @@ type Config struct {
SignalingUrl string `protobuf:"bytes,11,opt,name=signaling_url,json=signalingUrl,proto3" json:"signaling_url,omitempty"`
// 只用自己的服务器探测网络出口,不用公共 STUN 服务器。
// 默认 false(即允许公共服务器):旧版界面不发这个字段时,不会被误关掉。
- OnlyOwnStun bool `protobuf:"varint,12,opt,name=only_own_stun,json=onlyOwnStun,proto3" json:"only_own_stun,omitempty"`
+ OnlyOwnStun bool `protobuf:"varint,12,opt,name=only_own_stun,json=onlyOwnStun,proto3" json:"only_own_stun,omitempty"`
+ // 界面语言:空字符串表示跟随系统;否则是 "zh-Hans"、"en"、"ja" 之一。
+ // 存在后台服务这里而不是界面里:Windows 的托盘菜单由后台服务画,也要跟着变。
+ Language string `protobuf:"bytes,13,opt,name=language,proto3" json:"language,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -1550,6 +1553,13 @@ func (x *Config) GetOnlyOwnStun() bool {
return false
}
+func (x *Config) GetLanguage() string {
+ if x != nil {
+ return x.Language
+ }
+ return ""
+}
+
// 最近一轮网络出口探测的结果。
type NetworkInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
@@ -1962,7 +1972,7 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
"\x0fpairing_session\x18\x01 \x01(\tR\x0epairingSession\x12\x16\n" +
"\x06accept\x18\x02 \x01(\bR\x06accept\",\n" +
"\rUnpairRequest\x12\x1b\n" +
- "\tdevice_id\x18\x01 \x01(\tR\bdeviceId\"\xde\x03\n" +
+ "\tdevice_id\x18\x01 \x01(\tR\bdeviceId\"\xfa\x03\n" +
"\x06Config\x129\n" +
"\x19auto_sync_threshold_bytes\x18\x01 \x01(\x03R\x16autoSyncThresholdBytes\x12.\n" +
"\x13history_ttl_seconds\x18\x02 \x01(\x03R\x11historyTtlSeconds\x12*\n" +
@@ -1978,7 +1988,8 @@ const file_copysync_v1_daemon_proto_rawDesc = "" +
" \x01(\tR\n" +
"deviceName\x12#\n" +
"\rsignaling_url\x18\v \x01(\tR\fsignalingUrl\x12\"\n" +
- "\ronly_own_stun\x18\f \x01(\bR\vonlyOwnStun\"\xbe\x01\n" +
+ "\ronly_own_stun\x18\f \x01(\bR\vonlyOwnStun\x12\x1a\n" +
+ "\blanguage\x18\r \x01(\tR\blanguage\"\xbe\x01\n" +
"\vNetworkInfo\x12\x1d\n" +
"\n" +
"local_port\x18\x01 \x01(\x05R\tlocalPort\x126\n" +
diff --git a/tools/screenshots/render.sh b/tools/screenshots/render.sh
index aaa4f39..dcc4dbb 100755
--- a/tools/screenshots/render.sh
+++ b/tools/screenshots/render.sh
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
-# 重新生成 README 与网站用的界面截图,输出到 docs/assets/screenshots/。
+# 重新生成 README 与网站用的界面截图:中文界面输出到 docs/assets/screenshots/,
+# 英文界面输出到 docs/assets/screenshots/en/。
#
# ./tools/screenshots/render.sh
#
@@ -15,9 +16,15 @@ trap 'rm -rf "$FONTS"' EXIT
echo "▶ 准备字体"
python3 tools/screenshots/prepare_fonts.py "$FONTS"
-echo "▶ 渲染界面"
-rm -rf ui/tool/screenshots/out
-(cd ui && SCREENSHOT_FONTS="$FONTS" flutter test tool/screenshots/screenshots_test.dart 2>&1 | tail -1)
+for lang in zh en; do
+ out=docs/assets/screenshots
+ [ "$lang" = zh ] || out="$out/$lang"
-echo "▶ 加窗口外框"
-swift tools/screenshots/frame.swift ui/tool/screenshots/out docs/assets/screenshots
+ echo "▶ 渲染界面($lang)"
+ rm -rf ui/tool/screenshots/out
+ (cd ui && SCREENSHOT_FONTS="$FONTS" SCREENSHOT_LANG="$lang" flutter test tool/screenshots/screenshots_test.dart 2>&1 | tail -1)
+
+ echo "▶ 加窗口外框($lang)"
+ mkdir -p "$out"
+ swift tools/screenshots/frame.swift ui/tool/screenshots/out "$out"
+done
diff --git a/ui/l10n.yaml b/ui/l10n.yaml
new file mode 100644
index 0000000..ec4c75b
--- /dev/null
+++ b/ui/l10n.yaml
@@ -0,0 +1,7 @@
+# 界面文案的多语言。英文为模板,中文、日文各一份。
+# flutter pub get 或 flutter gen-l10n 时生成 lib/l10n/app_localizations*.dart。
+arb-dir: lib/l10n
+template-arb-file: app_en.arb
+output-localization-file: app_localizations.dart
+output-class: AppLocalizations
+nullable-getter: false
diff --git a/ui/lib/app_state.dart b/ui/lib/app_state.dart
index 1aef20a..7b8382b 100644
--- a/ui/lib/app_state.dart
+++ b/ui/lib/app_state.dart
@@ -5,6 +5,7 @@ import 'package:grpc/grpc.dart';
import 'background_service.dart';
import 'daemon_client.dart';
+import 'i18n.dart';
import 'gen/copysync/v1/daemon.pb.dart';
import 'gen/copysync/v1/daemon.pbgrpc.dart' show DaemonServiceClient;
@@ -94,8 +95,8 @@ class AppState extends ChangeNotifier {
_events = conn.client.subscribe(SubscribeRequest()).listen(
_onEvent,
- onError: (Object e) => _scheduleRetry('连接中断:${_describe(e)}'),
- onDone: () => _scheduleRetry('后台服务已断开'),
+ onError: (Object e) => _scheduleRetry(appL10n.linkConnectionLost(_describe(e))),
+ onDone: () => _scheduleRetry(appL10n.linkServiceDisconnected),
);
_serviceState = null;
@@ -103,7 +104,7 @@ class AppState extends ChangeNotifier {
_ensureServiceCurrent();
} on DaemonNotRunning {
await _refreshServiceState();
- _scheduleRetry('后台服务未运行');
+ _scheduleRetry(appL10n.linkServiceNotRunning);
} catch (e) {
await _refreshServiceState();
_scheduleRetry(_describe(e));
@@ -187,7 +188,7 @@ class AppState extends ChangeNotifier {
_retry?.cancel();
await service.uninstall();
await _refreshServiceState();
- _scheduleRetry('后台服务已停用');
+ _scheduleRetry(appL10n.linkServiceDisabled);
}
Future<void> _loadDevices() async {
@@ -302,7 +303,7 @@ class AppState extends ChangeNotifier {
DaemonServiceClient get _client {
final c = _conn;
- if (c == null) throw StateError('后台服务未连接');
+ if (c == null) throw StateError(appL10n.errServiceNotConnected);
return c.client;
}
@@ -389,11 +390,11 @@ class AppState extends ChangeNotifier {
/// 把 gRPC 异常翻译成用户能看懂的话,而不是抛一串堆栈。
static String _describe(Object e) {
if (e is GrpcError) {
- if (e.code == StatusCode.unimplemented) return '该功能尚未接入';
- if (e.code == StatusCode.unavailable) return '无法连接后台服务';
+ if (e.code == StatusCode.unimplemented) return appL10n.errUnimplemented;
+ if (e.code == StatusCode.unavailable) return appL10n.errUnavailable;
return e.message ?? e.codeName;
}
- if (e is DaemonNotRunning) return '后台服务未运行';
+ if (e is DaemonNotRunning) return appL10n.linkServiceNotRunning;
if (e is StateError) return e.message;
return e.toString();
}
diff --git a/ui/lib/background_service.dart b/ui/lib/background_service.dart
index cbe4194..2145273 100644
--- a/ui/lib/background_service.dart
+++ b/ui/lib/background_service.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'background_service_windows.dart';
+import 'i18n.dart';
/// 构建时注入的版本号(build.sh 传 --dart-define=APP_VERSION)。
/// 用来判断后台服务是不是跟界面同一个版本。
@@ -118,7 +119,7 @@ class MacBackgroundService implements BackgroundService {
final r = await Process.run('launchctl', ['bootstrap', await _domain(), plistPath]);
if (r.exitCode != 0) {
- throw ServiceException('启动后台服务失败:${'${r.stderr}'.trim()}');
+ throw ServiceException(appL10n.errServiceStart('${r.stderr}'.trim()));
}
}
@@ -127,7 +128,7 @@ class MacBackgroundService implements BackgroundService {
Future<void> restart() async {
final r = await Process.run('launchctl', ['kickstart', '-k', await _target()]);
if (r.exitCode != 0) {
- throw ServiceException('重启后台服务失败:${'${r.stderr}'.trim()}');
+ throw ServiceException(appL10n.errServiceRestart('${r.stderr}'.trim()));
}
}
diff --git a/ui/lib/background_service_windows.dart b/ui/lib/background_service_windows.dart
index 2e69a72..6f38093 100644
--- a/ui/lib/background_service_windows.dart
+++ b/ui/lib/background_service_windows.dart
@@ -1,6 +1,7 @@
import 'dart:io';
import 'background_service.dart';
+import 'i18n.dart';
/// Windows:后台服务 `copysyncd.exe` 与 `CopySync.exe` 放在同一个目录。
///
@@ -60,7 +61,7 @@ class WindowsBackgroundService implements BackgroundService {
'add', _runKey, '/v', _valueName, '/t', 'REG_SZ', '/d', _command, '/f', //
]);
if (r.exitCode != 0) {
- throw ServiceException('登记开机自启失败:${_output(r)}');
+ throw ServiceException(appL10n.errAutostart(_output(r)));
}
await restart();
}
diff --git a/ui/lib/gen/copysync/v1/daemon.pb.dart b/ui/lib/gen/copysync/v1/daemon.pb.dart
index 3e18176..a52fa73 100644
--- a/ui/lib/gen/copysync/v1/daemon.pb.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pb.dart
@@ -1559,6 +1559,7 @@ class Config extends $pb.GeneratedMessage {
$core.String? deviceName,
$core.String? signalingUrl,
$core.bool? onlyOwnStun,
+ $core.String? language,
}) {
final result = Config._();
if (autoSyncThresholdBytes != null)
@@ -1575,6 +1576,7 @@ class Config extends $pb.GeneratedMessage {
if (deviceName != null) result.deviceName = deviceName;
if (signalingUrl != null) result.signalingUrl = signalingUrl;
if (onlyOwnStun != null) result.onlyOwnStun = onlyOwnStun;
+ if (language != null) result.language = language;
return result;
}
@@ -1603,6 +1605,7 @@ class Config extends $pb.GeneratedMessage {
..aOS(10, _omitFieldNames ? '' : 'deviceName')
..aOS(11, _omitFieldNames ? '' : 'signalingUrl')
..aOB(12, _omitFieldNames ? '' : 'onlyOwnStun')
+ ..aOS(13, _omitFieldNames ? '' : 'language')
..hasRequiredFields = false;
@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')
@@ -1736,6 +1739,17 @@ class Config extends $pb.GeneratedMessage {
$core.bool hasOnlyOwnStun() => $_has(11);
@$pb.TagNumber(12)
void clearOnlyOwnStun() => $_clearField(12);
+
+ /// 界面语言:空字符串表示跟随系统;否则是 "zh-Hans"、"en"、"ja" 之一。
+ /// 存在后台服务这里而不是界面里:Windows 的托盘菜单由后台服务画,也要跟着变。
+ @$pb.TagNumber(13)
+ $core.String get language => $_getSZ(12);
+ @$pb.TagNumber(13)
+ set language($core.String value) => $_setString(12, value);
+ @$pb.TagNumber(13)
+ $core.bool hasLanguage() => $_has(12);
+ @$pb.TagNumber(13)
+ void clearLanguage() => $_clearField(13);
}
/// 最近一轮网络出口探测的结果。
diff --git a/ui/lib/gen/copysync/v1/daemon.pbjson.dart b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
index 708f1c6..26f018a 100644
--- a/ui/lib/gen/copysync/v1/daemon.pbjson.dart
+++ b/ui/lib/gen/copysync/v1/daemon.pbjson.dart
@@ -543,6 +543,7 @@ const Config$json = {
{'1': 'device_name', '3': 10, '4': 1, '5': 9, '10': 'deviceName'},
{'1': 'signaling_url', '3': 11, '4': 1, '5': 9, '10': 'signalingUrl'},
{'1': 'only_own_stun', '3': 12, '4': 1, '5': 8, '10': 'onlyOwnStun'},
+ {'1': 'language', '3': 13, '4': 1, '5': 9, '10': 'language'},
],
};
@@ -556,7 +557,8 @@ final $typed_data.Uint8List configDescriptor = $convert.base64Decode(
'I1ChdhdXRvX2FwcGx5X3RvX2NsaXBib2FyZBgIIAEoCFIUYXV0b0FwcGx5VG9DbGlwYm9hcmQS'
'JgoPbGF1bmNoX2F0X2xvZ2luGAkgASgIUg1sYXVuY2hBdExvZ2luEh8KC2RldmljZV9uYW1lGA'
'ogASgJUgpkZXZpY2VOYW1lEiMKDXNpZ25hbGluZ191cmwYCyABKAlSDHNpZ25hbGluZ1VybBIi'
- 'Cg1vbmx5X293bl9zdHVuGAwgASgIUgtvbmx5T3duU3R1bg==');
+ 'Cg1vbmx5X293bl9zdHVuGAwgASgIUgtvbmx5T3duU3R1bhIaCghsYW5ndWFnZRgNIAEoCVIIbG'
+ 'FuZ3VhZ2U=');
@$core.Deprecated('Use networkInfoDescriptor instead')
const NetworkInfo$json = {
diff --git a/ui/lib/i18n.dart b/ui/lib/i18n.dart
new file mode 100644
index 0000000..fffa8ac
--- /dev/null
+++ b/ui/lib/i18n.dart
@@ -0,0 +1,36 @@
+import 'dart:ui';
+
+import 'package:flutter/widgets.dart';
+
+import 'l10n/app_localizations.dart';
+
+export 'l10n/app_localizations.dart';
+
+/// 界面支持的语言。文案在 tool/l10n/strings.py 里,改完运行它再 flutter gen-l10n。
+const supportedLocales = [Locale('en'), Locale('zh'), Locale('ja')];
+
+/// 设置里存的语言(Config.language)→ 界面用的 Locale。空字符串表示跟随系统,返回 null。
+Locale? localeFromSetting(String value) => switch (value) {
+ 'zh-Hans' => const Locale('zh'),
+ 'en' => const Locale('en'),
+ 'ja' => const Locale('ja'),
+ _ => null,
+ };
+
+/// 按系统的语言偏好顺序,取第一个支持的;繁体中文也用简体,都不支持时用英文。
+Locale resolveLocale(List<Locale>? preferred) {
+ for (final l in preferred ?? const <Locale>[]) {
+ for (final s in supportedLocales) {
+ if (s.languageCode == l.languageCode) return s;
+ }
+ }
+ return const Locale('en');
+}
+
+/// 不在 widget 里的代码(AppState 的错误提示、相对时间等)用它取文案。
+/// MaterialApp 每次构建时按当前语言更新;启动前先按系统语言给一个。
+AppLocalizations appL10n = lookupAppLocalizations(resolveLocale(PlatformDispatcher.instance.locales));
+
+extension L10nContext on BuildContext {
+ AppLocalizations get l10n => AppLocalizations.of(this);
+}
diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arb
new file mode 100644
index 0000000..04c55a8
--- /dev/null
+++ b/ui/lib/l10n/app_en.arb
@@ -0,0 +1,381 @@
+{
+ "@@locale": "en",
+ "navHistory": "History",
+ "navDevices": "Devices",
+ "navSettings": "Settings",
+ "linkConnecting": "Connecting…",
+ "linkServiceNotRunning": "Service not running",
+ "linkNoServer": "No server connection",
+ "linkOnlinePeers": "{count, plural, =1{1 device online} other{{count} devices online}}",
+ "@linkOnlinePeers": {
+ "placeholders": {
+ "count": {
+ "type": "int"
+ }
+ }
+ },
+ "linkServerConnected": "Connected to the server",
+ "linkConnectionLost": "Connection lost: {detail}",
+ "@linkConnectionLost": {
+ "placeholders": {
+ "detail": {
+ "type": "String"
+ }
+ }
+ },
+ "linkServiceDisconnected": "Service disconnected",
+ "linkServiceDisabled": "Background sync is off",
+ "errServiceNotConnected": "Not connected to the background service",
+ "errUnimplemented": "This isn't available yet",
+ "errUnavailable": "Can't reach the background service",
+ "errServiceStart": "Couldn't start the background service: {detail}",
+ "@errServiceStart": {
+ "placeholders": {
+ "detail": {
+ "type": "String"
+ }
+ }
+ },
+ "errServiceRestart": "Couldn't restart the background service: {detail}",
+ "@errServiceRestart": {
+ "placeholders": {
+ "detail": {
+ "type": "String"
+ }
+ }
+ },
+ "errAutostart": "Couldn't set CopySync to start at login: {detail}",
+ "@errAutostart": {
+ "placeholders": {
+ "detail": {
+ "type": "String"
+ }
+ }
+ },
+ "thisMacTitle": "This Mac",
+ "thisPcTitle": "This computer",
+ "thisMacInText": "this Mac",
+ "thisPcInText": "this computer",
+ "bothMacs": "both Macs",
+ "bothDevices": "both devices",
+ "thisDeviceShort": "This device",
+ "fromDevice": "From {name}",
+ "@fromDevice": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "cancel": "Cancel",
+ "close": "Close",
+ "save": "Save",
+ "retry": "Try again",
+ "continueAction": "Continue",
+ "justNow": "Just now",
+ "secondsAgo": "{n}s ago",
+ "@secondsAgo": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "minutesAgo": "{n, plural, =1{1 minute ago} other{{n} minutes ago}}",
+ "@minutesAgo": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "hoursAgo": "{n, plural, =1{1 hour ago} other{{n} hours ago}}",
+ "@hoursAgo": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "daysAgo": "{n, plural, =1{Yesterday} other{{n} days ago}}",
+ "@daysAgo": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "monthDay": "{month}/{day}",
+ "@monthDay": {
+ "placeholders": {
+ "month": {
+ "type": "int"
+ },
+ "day": {
+ "type": "int"
+ }
+ }
+ },
+ "durationHours": "{n, plural, =1{1 hour} other{{n} hours}}",
+ "@durationHours": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "durationDays": "{n, plural, =1{1 day} other{{n} days}}",
+ "@durationDays": {
+ "placeholders": {
+ "n": {
+ "type": "int"
+ }
+ }
+ },
+ "historyEmptySubtitle": "Copy on any of your devices and it shows up here",
+ "historyCount": "{count, plural, =1{1 item} other{{count} items}}",
+ "@historyCount": {
+ "placeholders": {
+ "count": {
+ "type": "int"
+ }
+ }
+ },
+ "historyCountKept": "{count, plural, =1{1 item} other{{count} items}}, kept for {ttl}",
+ "@historyCountKept": {
+ "placeholders": {
+ "count": {
+ "type": "int"
+ },
+ "ttl": {
+ "type": "String"
+ }
+ }
+ },
+ "filterAll": "All",
+ "filterText": "Text",
+ "filterImage": "Images",
+ "filterFile": "Files",
+ "historyClearTooltip": "Clear history",
+ "historyEmptyTitle": "Nothing here yet",
+ "historyEmptyFilteredTitle": "Nothing of this kind",
+ "historyEmptyBody": "Copy text, an image or a file on any paired device and it appears here.",
+ "clearConfirmTitle": "Clear the whole history?",
+ "clearConfirmBody": "Everything synced from your devices, and the cached files, will be removed from {device}. The original files aren't affected.",
+ "@clearConfirmBody": {
+ "placeholders": {
+ "device": {
+ "type": "String"
+ }
+ }
+ },
+ "clear": "Clear",
+ "historyCleared": "History cleared",
+ "permDeniedTitle": "CopySync can't read the clipboard",
+ "permAskTitle": "Allow CopySync to read the clipboard",
+ "permDeniedBody": "What you copy on this Mac won't be synced. In System Settings, set CopySync Daemon to Allow.",
+ "permAskBody": "Otherwise macOS asks every time. In System Settings, set CopySync Daemon to Allow.",
+ "openSystemSettings": "Open System Settings",
+ "fetch": "Pull to this device",
+ "fetchStarted": "Pulling…",
+ "transferFailed": "Transfer failed",
+ "expired": "Expired",
+ "preview": "Preview",
+ "putOnClipboard": "Copy to clipboard",
+ "putOnClipboardDone": "On the clipboard",
+ "deleteRecord": "Delete this item",
+ "deleted": "Deleted",
+ "emptyRecord": "(empty)",
+ "imageRecord": "Image",
+ "itemsSummary": "{name} and {others, plural, =1{1 more} other{{others} more}}",
+ "@itemsSummary": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ },
+ "others": {
+ "type": "int"
+ },
+ "count": {
+ "type": "int"
+ }
+ }
+ },
+ "imagePreviewTitle": "Image preview",
+ "closePreview": "Close preview",
+ "previewHint": "Scroll or pinch to zoom, drag to move around",
+ "fitWindow": "Fit to window",
+ "previewDeleted": "This image has been deleted from the history",
+ "previewExpired": "This image has expired and can't be previewed",
+ "previewDownloading": "Downloading the image…",
+ "previewDownloadFailed": "The download failed. Try again.",
+ "previewNotDownloaded": "This image isn't on this computer yet",
+ "downloadAndPreview": "Download and preview",
+ "previewUnavailable": "This image can't be previewed right now",
+ "imageSemantic": "Image from the history",
+ "previewUnreadable": "Can't read the image. The file may have been cleaned up or damaged.",
+ "devicesSubtitleEmpty": "Once paired, your devices share one clipboard",
+ "devicesSubtitle": "{paired} paired, {online} online",
+ "@devicesSubtitle": {
+ "placeholders": {
+ "paired": {
+ "type": "int"
+ },
+ "online": {
+ "type": "int"
+ }
+ }
+ },
+ "addDevice": "Add device",
+ "thisDeviceFootnote": "When pairing, {both} show the same two lines of security fingerprints, one for each device. Confirm only if they match character for character.",
+ "@thisDeviceFootnote": {
+ "placeholders": {
+ "both": {
+ "type": "String"
+ }
+ }
+ },
+ "noDevicesTitle": "No paired devices yet",
+ "noDevicesBody": "Open CopySync on your other computer and link the two with a 6-character pairing code.",
+ "noDevicesNeedServer": "Connect to a signaling server in Settings before pairing.",
+ "pairedDevices": "Paired devices",
+ "pairedFootnote": "Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.",
+ "offline": "Offline",
+ "direct": "Direct",
+ "relay": "Relay",
+ "online": "Online",
+ "moreActions": "More",
+ "copyFingerprint": "Copy fingerprint",
+ "unpairEllipsis": "Unpair…",
+ "fingerprintCopied": "Fingerprint copied",
+ "unpairTitle": "Unpair “{name}”?",
+ "@unpairTitle": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "unpairBody": "The two devices will stop syncing. To sync again, you'll need to pair them and check the fingerprints again.",
+ "unpair": "Unpair",
+ "unpaired": "Unpaired",
+ "generateCode": "Show a code",
+ "enterCode": "Enter a code",
+ "codeFailedTitle": "Couldn't create a pairing code",
+ "enterOnOther": "Enter this code on your other device",
+ "codeCopied": "Code copied",
+ "codeHint": "Click to copy. Valid for 5 minutes.",
+ "afterEnterFootnote": "Once it's entered, {both} show the same two lines of security fingerprints. Confirm only if they match.",
+ "@afterEnterFootnote": {
+ "placeholders": {
+ "both": {
+ "type": "String"
+ }
+ }
+ },
+ "codeInvalid": "A pairing code is 6 letters or digits",
+ "enterCodeShown": "Enter the code shown on your other device",
+ "pairingDone": "Paired",
+ "pairingRejected": "Pairing declined",
+ "verifyTitle": "Check the security fingerprints",
+ "pairingWith": "Pairing with “{name}”",
+ "@pairingWith": {
+ "placeholders": {
+ "name": {
+ "type": "String"
+ }
+ }
+ },
+ "verifyBody": "The two lines on {both} must be identical. If even one character differs, someone may be tampering with the connection, so decline.",
+ "@verifyBody": {
+ "placeholders": {
+ "both": {
+ "type": "String"
+ }
+ }
+ },
+ "rejectMismatch": "Mismatch, decline",
+ "confirmMatch": "They match, pair",
+ "server": "Server",
+ "serverFootnote": "The server only helps devices find each other and set up a direct connection. It can't see what they send.",
+ "signalingUrl": "Signaling server",
+ "signalingUrlDesc": "Press Return to save; it reconnects right away",
+ "signalingUrlPlaceholder": "ws://server-address:8787/signal",
+ "publicStun": "Probe with public servers",
+ "publicStunDesc": "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.",
+ "connectionStatus": "Connection",
+ "connectedDesc": "Connected to the signaling server",
+ "disconnectedDesc": "Can't reach the server. Check the address and that the server is running.",
+ "connected": "Connected",
+ "notConnected": "Not connected",
+ "deviceName": "Device name",
+ "deviceNameDesc": "Shown in the list on your other devices",
+ "language": "Language",
+ "languageSystem": "System",
+ "sync": "Sync",
+ "syncFootnote": "Items under the limit are pushed to your other devices as you copy. Larger ones sync as a record; pull them from History when you need them, so big files don't waste bandwidth or disk space.",
+ "autoSyncLimit": "Auto-sync limit",
+ "autoSyncLimitDesc": "Larger files are pulled by hand",
+ "autoApply": "Put received items on the clipboard",
+ "autoApplyDesc": "When off, put them on the clipboard from History yourself",
+ "whatToSync": "What to sync",
+ "syncFiles": "Files and folders",
+ "syncText": "Plain text",
+ "syncRich": "Rich text",
+ "syncImages": "Images and screenshots",
+ "storage": "Storage",
+ "storageFootnote": "Expired items and cached files are cleaned up automatically.",
+ "keepHistory": "Keep history for",
+ "keepCache": "Keep cached files for",
+ "keepCacheDesc": "Never longer than the history",
+ "cacheUsage": "Cache size",
+ "backgroundSync": "Background sync",
+ "backgroundFootnote": "When off, nothing syncs and CopySync doesn't start at login. History and pairings are kept; open the app to turn it back on.",
+ "backgroundService": "Background service",
+ "backgroundServiceDesc": "Starts at login and keeps syncing with the window closed",
+ "restart": "Restart",
+ "restarted": "Background service restarted",
+ "disableEllipsis": "Turn off…",
+ "about": "About",
+ "aboutDesc": "Open source, MIT License",
+ "homepage": "Website",
+ "feedback": "Report a problem",
+ "disableTitle": "Turn off background sync?",
+ "disableBody": "CopySync on {device} will stop syncing and won't start at login. History and pairings are kept.",
+ "@disableBody": {
+ "placeholders": {
+ "device": {
+ "type": "String"
+ }
+ }
+ },
+ "disable": "Turn off",
+ "disabled": "Background sync is off",
+ "urlMustBeWs": "The address must start with ws:// or wss://",
+ "serverUpdated": "Server updated. Reconnecting…",
+ "deviceNameUpdated": "Device name updated",
+ "svcExtractTitle": "Install or extract CopySync first",
+ "svcExtractBody": "CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.",
+ "svcMoveTitle": "Move CopySync to Applications first",
+ "svcMoveBody": "CopySync is running straight from the disk image. Drag it into Applications, eject the disk image, and open it from Applications to turn on background sync.",
+ "svcStartTitle": "Get started with CopySync",
+ "svcStartBody": "CopySync runs a small background process that notices clipboard changes and stays connected to your other devices. Once on, it starts at login and keeps syncing even with this window closed.",
+ "svcEnable": "Turn on background sync",
+ "svcStaleTitle": "Turn background sync on again",
+ "svcStaleBodyWin": "CopySync has moved, but starting at login still points to the old place. Turn it on again so the background process uses this copy. History and pairings are kept.",
+ "svcStaleBodyMac": "CopySync has moved, or was installed with an old script. Turn it on again so the background process uses this app. History and pairings are kept.",
+ "svcReenable": "Turn on again",
+ "svcStoppedTitle": "The background service isn't running",
+ "svcStoppedBody": "It may have just quit; the system usually restarts it within seconds. If you stay on this page, restart it with the button below.",
+ "svcDevBodyWin": "This is a development build with no copysyncd.exe next to it. Run scripts\\build-windows.ps1 in the source folder to build a complete version.",
+ "svcDevBodyMac": "This is a development build without the background service. Run ./scripts/install-macos.sh in the source folder to install it.",
+ "svcLogPath": "Log: {path}",
+ "@svcLogPath": {
+ "placeholders": {
+ "path": {
+ "type": "String"
+ }
+ }
+ },
+ "svcCanDisable": "You can turn background sync off anytime in Settings."
+}
diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arb
new file mode 100644
index 0000000..a73403d
--- /dev/null
+++ b/ui/lib/l10n/app_ja.arb
@@ -0,0 +1,191 @@
+{
+ "@@locale": "ja",
+ "navHistory": "履歴",
+ "navDevices": "デバイス",
+ "navSettings": "設定",
+ "linkConnecting": "接続中…",
+ "linkServiceNotRunning": "サービス停止中",
+ "linkNoServer": "サーバーに未接続",
+ "linkOnlinePeers": "{count} 台がオンライン",
+ "linkServerConnected": "サーバーに接続済み",
+ "linkConnectionLost": "接続が切れました:{detail}",
+ "linkServiceDisconnected": "サービスとの接続が切れました",
+ "linkServiceDisabled": "同期はオフです",
+ "errServiceNotConnected": "バックグラウンドサービスに接続していません",
+ "errUnimplemented": "この機能はまだ使えません",
+ "errUnavailable": "バックグラウンドサービスに接続できません",
+ "errServiceStart": "バックグラウンドサービスを起動できませんでした:{detail}",
+ "errServiceRestart": "バックグラウンドサービスを再起動できませんでした:{detail}",
+ "errAutostart": "ログイン時の自動起動を設定できませんでした:{detail}",
+ "thisMacTitle": "この Mac",
+ "thisPcTitle": "このコンピューター",
+ "thisMacInText": "この Mac ",
+ "thisPcInText": "このコンピューター",
+ "bothMacs": "両方の Mac ",
+ "bothDevices": "両方のデバイス",
+ "thisDeviceShort": "このデバイス",
+ "fromDevice": "{name} から",
+ "cancel": "キャンセル",
+ "close": "閉じる",
+ "save": "保存",
+ "retry": "再試行",
+ "continueAction": "続ける",
+ "justNow": "たった今",
+ "secondsAgo": "{n} 秒前",
+ "minutesAgo": "{n} 分前",
+ "hoursAgo": "{n} 時間前",
+ "daysAgo": "{n} 日前",
+ "monthDay": "{month}月{day}日",
+ "durationHours": "{n} 時間",
+ "durationDays": "{n} 日",
+ "historyEmptySubtitle": "どのデバイスでコピーしても、ここに表示されます",
+ "historyCount": "{count} 件",
+ "historyCountKept": "{count} 件、{ttl}保存",
+ "filterAll": "すべて",
+ "filterText": "テキスト",
+ "filterImage": "画像",
+ "filterFile": "ファイル",
+ "historyClearTooltip": "履歴を消去",
+ "historyEmptyTitle": "まだ履歴がありません",
+ "historyEmptyFilteredTitle": "この種類の履歴はありません",
+ "historyEmptyBody": "ペアリングしたどのデバイスでテキスト、画像、ファイルをコピーしても、ここに表示されます。",
+ "clearConfirmTitle": "履歴をすべて消去しますか?",
+ "clearConfirmBody": "同期した履歴とキャッシュしたファイルが{device}から削除されます。元のファイルには影響しません。",
+ "clear": "消去",
+ "historyCleared": "履歴を消去しました",
+ "permDeniedTitle": "CopySync はクリップボードを読み取れません",
+ "permAskTitle": "CopySync にクリップボードの読み取りを許可してください",
+ "permDeniedBody": "この Mac でコピーした内容は同期されません。システム設定で CopySync Daemon を「許可」にしてください。",
+ "permAskBody": "許可しないと macOS が毎回確認します。システム設定で CopySync Daemon を「許可」にしてください。",
+ "openSystemSettings": "システム設定を開く",
+ "fetch": "このデバイスに取り込む",
+ "fetchStarted": "取り込みを開始しました",
+ "transferFailed": "転送に失敗しました",
+ "expired": "期限切れ",
+ "preview": "プレビュー",
+ "putOnClipboard": "クリップボードに入れる",
+ "putOnClipboardDone": "クリップボードに入れました",
+ "deleteRecord": "この履歴を削除",
+ "deleted": "削除しました",
+ "emptyRecord": "(空)",
+ "imageRecord": "画像",
+ "itemsSummary": "{name} ほか {others} 件",
+ "imagePreviewTitle": "画像プレビュー",
+ "closePreview": "プレビューを閉じる",
+ "previewHint": "ホイールやトラックパッドで拡大縮小、ドラッグで移動",
+ "fitWindow": "ウィンドウに合わせる",
+ "previewDeleted": "この画像は履歴から削除されました",
+ "previewExpired": "この画像は期限切れのためプレビューできません",
+ "previewDownloading": "画像をダウンロード中…",
+ "previewDownloadFailed": "ダウンロードに失敗しました。もう一度お試しください。",
+ "previewNotDownloaded": "この画像はまだこのコンピューターにありません",
+ "downloadAndPreview": "ダウンロードしてプレビュー",
+ "previewUnavailable": "現在この画像はプレビューできません",
+ "imageSemantic": "履歴の画像",
+ "previewUnreadable": "画像を読み込めません。ファイルが削除されたか破損している可能性があります。",
+ "devicesSubtitleEmpty": "ペアリングすると、デバイス間でクリップボードが同期されます",
+ "devicesSubtitle": "ペアリング済み {paired} 台、オンライン {online} 台",
+ "addDevice": "デバイスを追加",
+ "thisDeviceFootnote": "ペアリング時、{both}に同じ 2 行のセキュリティ指紋(このデバイスと相手のもの)が表示されます。1 文字ずつ一致を確かめてから確定してください。",
+ "noDevicesTitle": "ペアリングしたデバイスはまだありません",
+ "noDevicesBody": "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。",
+ "noDevicesNeedServer": "ペアリングの前に、「設定」でシグナリングサーバーに接続してください。",
+ "pairedDevices": "ペアリング済みのデバイス",
+ "pairedFootnote": "直接接続:データは 2 台のデバイス間で直接やり取りされます。中継:直接つながらないネットワークでは、あなたのサーバーを経由します。内容はエンドツーエンドで暗号化されたままです。",
+ "offline": "オフライン",
+ "direct": "直接接続",
+ "relay": "中継",
+ "online": "オンライン",
+ "moreActions": "その他の操作",
+ "copyFingerprint": "指紋をコピー",
+ "unpairEllipsis": "ペアリングを解除…",
+ "fingerprintCopied": "指紋をコピーしました",
+ "unpairTitle": "「{name}」とのペアリングを解除しますか?",
+ "unpairBody": "2 台のデバイスは同期しなくなります。再開するには、もう一度ペアリングして指紋を確かめる必要があります。",
+ "unpair": "ペアリングを解除",
+ "unpaired": "ペアリングを解除しました",
+ "generateCode": "コードを表示",
+ "enterCode": "コードを入力",
+ "codeFailedTitle": "ペアリングコードを作成できませんでした",
+ "enterOnOther": "もう一台のデバイスでこのコードを入力してください",
+ "codeCopied": "コードをコピーしました",
+ "codeHint": "クリックでコピー。有効期間は 5 分です。",
+ "afterEnterFootnote": "入力されると、{both}に同じ 2 行のセキュリティ指紋が表示されます。一致を確かめてから確定してください。",
+ "codeInvalid": "ペアリングコードは 6 桁の英数字です",
+ "enterCodeShown": "もう一台のデバイスに表示されたコードを入力してください",
+ "pairingDone": "ペアリングしました",
+ "pairingRejected": "ペアリングを拒否しました",
+ "verifyTitle": "セキュリティ指紋を確認",
+ "pairingWith": "「{name}」とペアリング中",
+ "verifyBody": "{both}に表示された 2 行は完全に同じはずです。1 文字でも違う場合は、第三者が通信を改ざんしている可能性があるため、拒否してください。",
+ "rejectMismatch": "不一致、拒否",
+ "confirmMatch": "一致、ペアリング",
+ "server": "サーバー",
+ "serverFootnote": "サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。",
+ "signalingUrl": "シグナリングサーバー",
+ "signalingUrlDesc": "Enter で保存し、すぐに再接続します",
+ "signalingUrlPlaceholder": "ws://サーバーアドレス:8787/signal",
+ "publicStun": "公開サーバーで出口を調べる",
+ "publicStunDesc": "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。",
+ "connectionStatus": "接続状態",
+ "connectedDesc": "シグナリングサーバーに接続しています",
+ "disconnectedDesc": "サーバーに接続できません。アドレスとサーバーの稼働を確認してください。",
+ "connected": "接続済み",
+ "notConnected": "未接続",
+ "deviceName": "デバイス名",
+ "deviceNameDesc": "他のデバイスの一覧に表示されます",
+ "language": "言語",
+ "languageSystem": "システムに合わせる",
+ "sync": "同期",
+ "syncFootnote": "上限より小さい内容はコピーした時点で他のデバイスに送られます。大きいものは記録だけを同期し、必要なときに「履歴」から取り込むので、帯域やディスクを無駄に使いません。",
+ "autoSyncLimit": "自動同期の上限",
+ "autoSyncLimitDesc": "これより大きいファイルは手動で取り込みます",
+ "autoApply": "受け取った内容をクリップボードに入れる",
+ "autoApplyDesc": "オフの場合は「履歴」から手動でクリップボードに入れます",
+ "whatToSync": "同期する内容",
+ "syncFiles": "ファイルとフォルダ",
+ "syncText": "プレーンテキスト",
+ "syncRich": "書式付きテキスト",
+ "syncImages": "画像とスクリーンショット",
+ "storage": "ストレージ",
+ "storageFootnote": "期限切れの履歴とキャッシュは自動で削除されます。",
+ "keepHistory": "履歴の保存期間",
+ "keepCache": "キャッシュの保存期間",
+ "keepCacheDesc": "履歴の保存期間を超えません",
+ "cacheUsage": "キャッシュ容量",
+ "backgroundSync": "バックグラウンド同期",
+ "backgroundFootnote": "オフにすると同期せず、ログイン時にも起動しません。履歴とペアリングは残り、アプリを開けば再び有効にできます。",
+ "backgroundService": "バックグラウンドサービス",
+ "backgroundServiceDesc": "ログイン時に起動し、ウィンドウを閉じても同期を続けます",
+ "restart": "再起動",
+ "restarted": "バックグラウンドサービスを再起動しました",
+ "disableEllipsis": "オフにする…",
+ "about": "このアプリについて",
+ "aboutDesc": "オープンソース(MIT ライセンス)",
+ "homepage": "ウェブサイト",
+ "feedback": "問題を報告",
+ "disableTitle": "バックグラウンド同期をオフにしますか?",
+ "disableBody": "{device}は同期を停止し、ログイン時にも起動しなくなります。履歴とペアリングは残ります。",
+ "disable": "オフにする",
+ "disabled": "バックグラウンド同期をオフにしました",
+ "urlMustBeWs": "アドレスは ws:// または wss:// で始めてください",
+ "serverUpdated": "サーバーを更新しました。再接続しています…",
+ "deviceNameUpdated": "デバイス名を更新しました",
+ "svcExtractTitle": "先に CopySync をインストールまたは展開してください",
+ "svcExtractBody": "CopySync は zip から直接開かれていて、閉じると一時フォルダごと消えます。インストーラーを実行するか、フォルダ全体を展開してから開くと、バックグラウンド同期を有効にできます。",
+ "svcMoveTitle": "先に CopySync を「アプリケーション」に移動してください",
+ "svcMoveBody": "CopySync はディスクイメージから直接開かれています。「アプリケーション」にドラッグしてディスクイメージを取り出し、「アプリケーション」から開くと、バックグラウンド同期を有効にできます。",
+ "svcStartTitle": "CopySync を始める",
+ "svcStartBody": "CopySync は小さなバックグラウンドプロセスを動かし、クリップボードの変化を検知して他のデバイスとつながり続けます。有効にするとログイン時に起動し、このウィンドウを閉じても同期を続けます。",
+ "svcEnable": "バックグラウンド同期を有効にする",
+ "svcStaleTitle": "バックグラウンド同期をもう一度有効にする",
+ "svcStaleBodyWin": "CopySync の場所が変わりましたが、自動起動は以前の場所を指しています。もう一度有効にすると、このコピーを使うようになります。履歴とペアリングは残ります。",
+ "svcStaleBodyMac": "CopySync の場所が変わったか、古いスクリプトでインストールされています。もう一度有効にすると、このアプリを使うようになります。履歴とペアリングは残ります。",
+ "svcReenable": "もう一度有効にする",
+ "svcStoppedTitle": "バックグラウンドサービスが動いていません",
+ "svcStoppedBody": "終了した直後かもしれません。通常は数秒で再起動されます。この画面のままなら、下のボタンで再起動してください。",
+ "svcDevBodyWin": "開発ビルドのため copysyncd.exe がありません。ソースフォルダで scripts\\build-windows.ps1 を実行して完全版をビルドしてください。",
+ "svcDevBodyMac": "開発ビルドのためバックグラウンドサービスが含まれていません。ソースフォルダで ./scripts/install-macos.sh を実行してインストールしてください。",
+ "svcLogPath": "ログ:{path}",
+ "svcCanDisable": "バックグラウンド同期は「設定」でいつでもオフにできます。"
+}
diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dart
new file mode 100644
index 0000000..70db96b
--- /dev/null
+++ b/ui/lib/l10n/app_localizations.dart
@@ -0,0 +1,1266 @@
+import 'dart:async';
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/widgets.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
+import 'package:intl/intl.dart' as intl;
+
+import 'app_localizations_en.dart';
+import 'app_localizations_ja.dart';
+import 'app_localizations_zh.dart';
+
+// ignore_for_file: type=lint
+
+/// Callers can lookup localized strings with an instance of AppLocalizations
+/// returned by `AppLocalizations.of(context)`.
+///
+/// Applications need to include `AppLocalizations.delegate()` in their app's
+/// `localizationDelegates` list, and the locales they support in the app's
+/// `supportedLocales` list. For example:
+///
+/// ```dart
+/// import 'l10n/app_localizations.dart';
+///
+/// return MaterialApp(
+/// localizationsDelegates: AppLocalizations.localizationsDelegates,
+/// supportedLocales: AppLocalizations.supportedLocales,
+/// home: MyApplicationHome(),
+/// );
+/// ```
+///
+/// ## Update pubspec.yaml
+///
+/// Please make sure to update your pubspec.yaml to include the following
+/// packages:
+///
+/// ```yaml
+/// dependencies:
+/// # Internationalization support.
+/// flutter_localizations:
+/// sdk: flutter
+/// intl: any # Use the pinned version from flutter_localizations
+///
+/// # Rest of dependencies
+/// ```
+///
+/// ## iOS Applications
+///
+/// iOS applications define key application metadata, including supported
+/// locales, in an Info.plist file that is built into the application bundle.
+/// To configure the locales supported by your app, you’ll need to edit this
+/// file.
+///
+/// First, open your project’s ios/Runner.xcworkspace Xcode workspace file.
+/// Then, in the Project Navigator, open the Info.plist file under the Runner
+/// project’s Runner folder.
+///
+/// Next, select the Information Property List item, select Add Item from the
+/// Editor menu, then select Localizations from the pop-up menu.
+///
+/// Select and expand the newly-created Localizations item then, for each
+/// locale your application supports, add a new item and select the locale
+/// you wish to add from the pop-up menu in the Value field. This list should
+/// be consistent with the languages listed in the AppLocalizations.supportedLocales
+/// property.
+abstract class AppLocalizations {
+ AppLocalizations(String locale)
+ : localeName = intl.Intl.canonicalizedLocale(locale.toString());
+
+ final String localeName;
+
+ static AppLocalizations of(BuildContext context) {
+ return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
+ }
+
+ static const LocalizationsDelegate<AppLocalizations> delegate =
+ _AppLocalizationsDelegate();
+
+ /// A list of this localizations delegate along with the default localizations
+ /// delegates.
+ ///
+ /// Returns a list of localizations delegates containing this delegate along with
+ /// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
+ /// and GlobalWidgetsLocalizations.delegate.
+ ///
+ /// Additional delegates can be added by appending to this list in
+ /// MaterialApp. This list does not have to be used at all if a custom list
+ /// of delegates is preferred or required.
+ static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
+ <LocalizationsDelegate<dynamic>>[
+ delegate,
+ GlobalMaterialLocalizations.delegate,
+ GlobalCupertinoLocalizations.delegate,
+ GlobalWidgetsLocalizations.delegate,
+ ];
+
+ /// A list of this localizations delegate's supported locales.
+ static const List<Locale> supportedLocales = <Locale>[
+ Locale('en'),
+ Locale('ja'),
+ Locale('zh'),
+ ];
+
+ /// No description provided for @navHistory.
+ ///
+ /// In en, this message translates to:
+ /// **'History'**
+ String get navHistory;
+
+ /// No description provided for @navDevices.
+ ///
+ /// In en, this message translates to:
+ /// **'Devices'**
+ String get navDevices;
+
+ /// No description provided for @navSettings.
+ ///
+ /// In en, this message translates to:
+ /// **'Settings'**
+ String get navSettings;
+
+ /// No description provided for @linkConnecting.
+ ///
+ /// In en, this message translates to:
+ /// **'Connecting…'**
+ String get linkConnecting;
+
+ /// No description provided for @linkServiceNotRunning.
+ ///
+ /// In en, this message translates to:
+ /// **'Service not running'**
+ String get linkServiceNotRunning;
+
+ /// No description provided for @linkNoServer.
+ ///
+ /// In en, this message translates to:
+ /// **'No server connection'**
+ String get linkNoServer;
+
+ /// No description provided for @linkOnlinePeers.
+ ///
+ /// In en, this message translates to:
+ /// **'{count, plural, =1{1 device online} other{{count} devices online}}'**
+ String linkOnlinePeers(int count);
+
+ /// No description provided for @linkServerConnected.
+ ///
+ /// In en, this message translates to:
+ /// **'Connected to the server'**
+ String get linkServerConnected;
+
+ /// No description provided for @linkConnectionLost.
+ ///
+ /// In en, this message translates to:
+ /// **'Connection lost: {detail}'**
+ String linkConnectionLost(String detail);
+
+ /// No description provided for @linkServiceDisconnected.
+ ///
+ /// In en, this message translates to:
+ /// **'Service disconnected'**
+ String get linkServiceDisconnected;
+
+ /// No description provided for @linkServiceDisabled.
+ ///
+ /// In en, this message translates to:
+ /// **'Background sync is off'**
+ String get linkServiceDisabled;
+
+ /// No description provided for @errServiceNotConnected.
+ ///
+ /// In en, this message translates to:
+ /// **'Not connected to the background service'**
+ String get errServiceNotConnected;
+
+ /// No description provided for @errUnimplemented.
+ ///
+ /// In en, this message translates to:
+ /// **'This isn\'t available yet'**
+ String get errUnimplemented;
+
+ /// No description provided for @errUnavailable.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t reach the background service'**
+ String get errUnavailable;
+
+ /// No description provided for @errServiceStart.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t start the background service: {detail}'**
+ String errServiceStart(String detail);
+
+ /// No description provided for @errServiceRestart.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t restart the background service: {detail}'**
+ String errServiceRestart(String detail);
+
+ /// No description provided for @errAutostart.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t set CopySync to start at login: {detail}'**
+ String errAutostart(String detail);
+
+ /// No description provided for @thisMacTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'This Mac'**
+ String get thisMacTitle;
+
+ /// No description provided for @thisPcTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'This computer'**
+ String get thisPcTitle;
+
+ /// No description provided for @thisMacInText.
+ ///
+ /// In en, this message translates to:
+ /// **'this Mac'**
+ String get thisMacInText;
+
+ /// No description provided for @thisPcInText.
+ ///
+ /// In en, this message translates to:
+ /// **'this computer'**
+ String get thisPcInText;
+
+ /// No description provided for @bothMacs.
+ ///
+ /// In en, this message translates to:
+ /// **'both Macs'**
+ String get bothMacs;
+
+ /// No description provided for @bothDevices.
+ ///
+ /// In en, this message translates to:
+ /// **'both devices'**
+ String get bothDevices;
+
+ /// No description provided for @thisDeviceShort.
+ ///
+ /// In en, this message translates to:
+ /// **'This device'**
+ String get thisDeviceShort;
+
+ /// No description provided for @fromDevice.
+ ///
+ /// In en, this message translates to:
+ /// **'From {name}'**
+ String fromDevice(String name);
+
+ /// No description provided for @cancel.
+ ///
+ /// In en, this message translates to:
+ /// **'Cancel'**
+ String get cancel;
+
+ /// No description provided for @close.
+ ///
+ /// In en, this message translates to:
+ /// **'Close'**
+ String get close;
+
+ /// No description provided for @save.
+ ///
+ /// In en, this message translates to:
+ /// **'Save'**
+ String get save;
+
+ /// No description provided for @retry.
+ ///
+ /// In en, this message translates to:
+ /// **'Try again'**
+ String get retry;
+
+ /// No description provided for @continueAction.
+ ///
+ /// In en, this message translates to:
+ /// **'Continue'**
+ String get continueAction;
+
+ /// No description provided for @justNow.
+ ///
+ /// In en, this message translates to:
+ /// **'Just now'**
+ String get justNow;
+
+ /// No description provided for @secondsAgo.
+ ///
+ /// In en, this message translates to:
+ /// **'{n}s ago'**
+ String secondsAgo(int n);
+
+ /// No description provided for @minutesAgo.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, =1{1 minute ago} other{{n} minutes ago}}'**
+ String minutesAgo(int n);
+
+ /// No description provided for @hoursAgo.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, =1{1 hour ago} other{{n} hours ago}}'**
+ String hoursAgo(int n);
+
+ /// No description provided for @daysAgo.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, =1{Yesterday} other{{n} days ago}}'**
+ String daysAgo(int n);
+
+ /// No description provided for @monthDay.
+ ///
+ /// In en, this message translates to:
+ /// **'{month}/{day}'**
+ String monthDay(int month, int day);
+
+ /// No description provided for @durationHours.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, =1{1 hour} other{{n} hours}}'**
+ String durationHours(int n);
+
+ /// No description provided for @durationDays.
+ ///
+ /// In en, this message translates to:
+ /// **'{n, plural, =1{1 day} other{{n} days}}'**
+ String durationDays(int n);
+
+ /// No description provided for @historyEmptySubtitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Copy on any of your devices and it shows up here'**
+ String get historyEmptySubtitle;
+
+ /// No description provided for @historyCount.
+ ///
+ /// In en, this message translates to:
+ /// **'{count, plural, =1{1 item} other{{count} items}}'**
+ String historyCount(int count);
+
+ /// No description provided for @historyCountKept.
+ ///
+ /// In en, this message translates to:
+ /// **'{count, plural, =1{1 item} other{{count} items}}, kept for {ttl}'**
+ String historyCountKept(int count, String ttl);
+
+ /// No description provided for @filterAll.
+ ///
+ /// In en, this message translates to:
+ /// **'All'**
+ String get filterAll;
+
+ /// No description provided for @filterText.
+ ///
+ /// In en, this message translates to:
+ /// **'Text'**
+ String get filterText;
+
+ /// No description provided for @filterImage.
+ ///
+ /// In en, this message translates to:
+ /// **'Images'**
+ String get filterImage;
+
+ /// No description provided for @filterFile.
+ ///
+ /// In en, this message translates to:
+ /// **'Files'**
+ String get filterFile;
+
+ /// No description provided for @historyClearTooltip.
+ ///
+ /// In en, this message translates to:
+ /// **'Clear history'**
+ String get historyClearTooltip;
+
+ /// No description provided for @historyEmptyTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Nothing here yet'**
+ String get historyEmptyTitle;
+
+ /// No description provided for @historyEmptyFilteredTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Nothing of this kind'**
+ String get historyEmptyFilteredTitle;
+
+ /// No description provided for @historyEmptyBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Copy text, an image or a file on any paired device and it appears here.'**
+ String get historyEmptyBody;
+
+ /// No description provided for @clearConfirmTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Clear the whole history?'**
+ String get clearConfirmTitle;
+
+ /// No description provided for @clearConfirmBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Everything synced from your devices, and the cached files, will be removed from {device}. The original files aren\'t affected.'**
+ String clearConfirmBody(String device);
+
+ /// No description provided for @clear.
+ ///
+ /// In en, this message translates to:
+ /// **'Clear'**
+ String get clear;
+
+ /// No description provided for @historyCleared.
+ ///
+ /// In en, this message translates to:
+ /// **'History cleared'**
+ String get historyCleared;
+
+ /// No description provided for @permDeniedTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync can\'t read the clipboard'**
+ String get permDeniedTitle;
+
+ /// No description provided for @permAskTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Allow CopySync to read the clipboard'**
+ String get permAskTitle;
+
+ /// No description provided for @permDeniedBody.
+ ///
+ /// In en, this message translates to:
+ /// **'What you copy on this Mac won\'t be synced. In System Settings, set CopySync Daemon to Allow.'**
+ String get permDeniedBody;
+
+ /// No description provided for @permAskBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Otherwise macOS asks every time. In System Settings, set CopySync Daemon to Allow.'**
+ String get permAskBody;
+
+ /// No description provided for @openSystemSettings.
+ ///
+ /// In en, this message translates to:
+ /// **'Open System Settings'**
+ String get openSystemSettings;
+
+ /// No description provided for @fetch.
+ ///
+ /// In en, this message translates to:
+ /// **'Pull to this device'**
+ String get fetch;
+
+ /// No description provided for @fetchStarted.
+ ///
+ /// In en, this message translates to:
+ /// **'Pulling…'**
+ String get fetchStarted;
+
+ /// No description provided for @transferFailed.
+ ///
+ /// In en, this message translates to:
+ /// **'Transfer failed'**
+ String get transferFailed;
+
+ /// No description provided for @expired.
+ ///
+ /// In en, this message translates to:
+ /// **'Expired'**
+ String get expired;
+
+ /// No description provided for @preview.
+ ///
+ /// In en, this message translates to:
+ /// **'Preview'**
+ String get preview;
+
+ /// No description provided for @putOnClipboard.
+ ///
+ /// In en, this message translates to:
+ /// **'Copy to clipboard'**
+ String get putOnClipboard;
+
+ /// No description provided for @putOnClipboardDone.
+ ///
+ /// In en, this message translates to:
+ /// **'On the clipboard'**
+ String get putOnClipboardDone;
+
+ /// No description provided for @deleteRecord.
+ ///
+ /// In en, this message translates to:
+ /// **'Delete this item'**
+ String get deleteRecord;
+
+ /// No description provided for @deleted.
+ ///
+ /// In en, this message translates to:
+ /// **'Deleted'**
+ String get deleted;
+
+ /// No description provided for @emptyRecord.
+ ///
+ /// In en, this message translates to:
+ /// **'(empty)'**
+ String get emptyRecord;
+
+ /// No description provided for @imageRecord.
+ ///
+ /// In en, this message translates to:
+ /// **'Image'**
+ String get imageRecord;
+
+ /// No description provided for @itemsSummary.
+ ///
+ /// In en, this message translates to:
+ /// **'{name} and {others, plural, =1{1 more} other{{others} more}}'**
+ String itemsSummary(String name, int others, int count);
+
+ /// No description provided for @imagePreviewTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Image preview'**
+ String get imagePreviewTitle;
+
+ /// No description provided for @closePreview.
+ ///
+ /// In en, this message translates to:
+ /// **'Close preview'**
+ String get closePreview;
+
+ /// No description provided for @previewHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Scroll or pinch to zoom, drag to move around'**
+ String get previewHint;
+
+ /// No description provided for @fitWindow.
+ ///
+ /// In en, this message translates to:
+ /// **'Fit to window'**
+ String get fitWindow;
+
+ /// No description provided for @previewDeleted.
+ ///
+ /// In en, this message translates to:
+ /// **'This image has been deleted from the history'**
+ String get previewDeleted;
+
+ /// No description provided for @previewExpired.
+ ///
+ /// In en, this message translates to:
+ /// **'This image has expired and can\'t be previewed'**
+ String get previewExpired;
+
+ /// No description provided for @previewDownloading.
+ ///
+ /// In en, this message translates to:
+ /// **'Downloading the image…'**
+ String get previewDownloading;
+
+ /// No description provided for @previewDownloadFailed.
+ ///
+ /// In en, this message translates to:
+ /// **'The download failed. Try again.'**
+ String get previewDownloadFailed;
+
+ /// No description provided for @previewNotDownloaded.
+ ///
+ /// In en, this message translates to:
+ /// **'This image isn\'t on this computer yet'**
+ String get previewNotDownloaded;
+
+ /// No description provided for @downloadAndPreview.
+ ///
+ /// In en, this message translates to:
+ /// **'Download and preview'**
+ String get downloadAndPreview;
+
+ /// No description provided for @previewUnavailable.
+ ///
+ /// In en, this message translates to:
+ /// **'This image can\'t be previewed right now'**
+ String get previewUnavailable;
+
+ /// No description provided for @imageSemantic.
+ ///
+ /// In en, this message translates to:
+ /// **'Image from the history'**
+ String get imageSemantic;
+
+ /// No description provided for @previewUnreadable.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t read the image. The file may have been cleaned up or damaged.'**
+ String get previewUnreadable;
+
+ /// No description provided for @devicesSubtitleEmpty.
+ ///
+ /// In en, this message translates to:
+ /// **'Once paired, your devices share one clipboard'**
+ String get devicesSubtitleEmpty;
+
+ /// No description provided for @devicesSubtitle.
+ ///
+ /// In en, this message translates to:
+ /// **'{paired} paired, {online} online'**
+ String devicesSubtitle(int paired, int online);
+
+ /// No description provided for @addDevice.
+ ///
+ /// In en, this message translates to:
+ /// **'Add device'**
+ String get addDevice;
+
+ /// No description provided for @thisDeviceFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'When pairing, {both} show the same two lines of security fingerprints, one for each device. Confirm only if they match character for character.'**
+ String thisDeviceFootnote(String both);
+
+ /// No description provided for @noDevicesTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'No paired devices yet'**
+ String get noDevicesTitle;
+
+ /// No description provided for @noDevicesBody.
+ ///
+ /// In en, this message translates to:
+ /// **'Open CopySync on your other computer and link the two with a 6-character pairing code.'**
+ String get noDevicesBody;
+
+ /// No description provided for @noDevicesNeedServer.
+ ///
+ /// In en, this message translates to:
+ /// **'Connect to a signaling server in Settings before pairing.'**
+ String get noDevicesNeedServer;
+
+ /// No description provided for @pairedDevices.
+ ///
+ /// In en, this message translates to:
+ /// **'Paired devices'**
+ String get pairedDevices;
+
+ /// No description provided for @pairedFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.'**
+ String get pairedFootnote;
+
+ /// No description provided for @offline.
+ ///
+ /// In en, this message translates to:
+ /// **'Offline'**
+ String get offline;
+
+ /// No description provided for @direct.
+ ///
+ /// In en, this message translates to:
+ /// **'Direct'**
+ String get direct;
+
+ /// No description provided for @relay.
+ ///
+ /// In en, this message translates to:
+ /// **'Relay'**
+ String get relay;
+
+ /// No description provided for @online.
+ ///
+ /// In en, this message translates to:
+ /// **'Online'**
+ String get online;
+
+ /// No description provided for @moreActions.
+ ///
+ /// In en, this message translates to:
+ /// **'More'**
+ String get moreActions;
+
+ /// No description provided for @copyFingerprint.
+ ///
+ /// In en, this message translates to:
+ /// **'Copy fingerprint'**
+ String get copyFingerprint;
+
+ /// No description provided for @unpairEllipsis.
+ ///
+ /// In en, this message translates to:
+ /// **'Unpair…'**
+ String get unpairEllipsis;
+
+ /// No description provided for @fingerprintCopied.
+ ///
+ /// In en, this message translates to:
+ /// **'Fingerprint copied'**
+ String get fingerprintCopied;
+
+ /// No description provided for @unpairTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Unpair “{name}”?'**
+ String unpairTitle(String name);
+
+ /// No description provided for @unpairBody.
+ ///
+ /// In en, this message translates to:
+ /// **'The two devices will stop syncing. To sync again, you\'ll need to pair them and check the fingerprints again.'**
+ String get unpairBody;
+
+ /// No description provided for @unpair.
+ ///
+ /// In en, this message translates to:
+ /// **'Unpair'**
+ String get unpair;
+
+ /// No description provided for @unpaired.
+ ///
+ /// In en, this message translates to:
+ /// **'Unpaired'**
+ String get unpaired;
+
+ /// No description provided for @generateCode.
+ ///
+ /// In en, this message translates to:
+ /// **'Show a code'**
+ String get generateCode;
+
+ /// No description provided for @enterCode.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter a code'**
+ String get enterCode;
+
+ /// No description provided for @codeFailedTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t create a pairing code'**
+ String get codeFailedTitle;
+
+ /// No description provided for @enterOnOther.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter this code on your other device'**
+ String get enterOnOther;
+
+ /// No description provided for @codeCopied.
+ ///
+ /// In en, this message translates to:
+ /// **'Code copied'**
+ String get codeCopied;
+
+ /// No description provided for @codeHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Click to copy. Valid for 5 minutes.'**
+ String get codeHint;
+
+ /// No description provided for @afterEnterFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Once it\'s entered, {both} show the same two lines of security fingerprints. Confirm only if they match.'**
+ String afterEnterFootnote(String both);
+
+ /// No description provided for @codeInvalid.
+ ///
+ /// In en, this message translates to:
+ /// **'A pairing code is 6 letters or digits'**
+ String get codeInvalid;
+
+ /// No description provided for @enterCodeShown.
+ ///
+ /// In en, this message translates to:
+ /// **'Enter the code shown on your other device'**
+ String get enterCodeShown;
+
+ /// No description provided for @pairingDone.
+ ///
+ /// In en, this message translates to:
+ /// **'Paired'**
+ String get pairingDone;
+
+ /// No description provided for @pairingRejected.
+ ///
+ /// In en, this message translates to:
+ /// **'Pairing declined'**
+ String get pairingRejected;
+
+ /// No description provided for @verifyTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Check the security fingerprints'**
+ String get verifyTitle;
+
+ /// No description provided for @pairingWith.
+ ///
+ /// In en, this message translates to:
+ /// **'Pairing with “{name}”'**
+ String pairingWith(String name);
+
+ /// No description provided for @verifyBody.
+ ///
+ /// In en, this message translates to:
+ /// **'The two lines on {both} must be identical. If even one character differs, someone may be tampering with the connection, so decline.'**
+ String verifyBody(String both);
+
+ /// No description provided for @rejectMismatch.
+ ///
+ /// In en, this message translates to:
+ /// **'Mismatch, decline'**
+ String get rejectMismatch;
+
+ /// No description provided for @confirmMatch.
+ ///
+ /// In en, this message translates to:
+ /// **'They match, pair'**
+ String get confirmMatch;
+
+ /// No description provided for @server.
+ ///
+ /// In en, this message translates to:
+ /// **'Server'**
+ String get server;
+
+ /// No description provided for @serverFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'The server only helps devices find each other and set up a direct connection. It can\'t see what they send.'**
+ String get serverFootnote;
+
+ /// No description provided for @signalingUrl.
+ ///
+ /// In en, this message translates to:
+ /// **'Signaling server'**
+ String get signalingUrl;
+
+ /// No description provided for @signalingUrlDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Press Return to save; it reconnects right away'**
+ String get signalingUrlDesc;
+
+ /// No description provided for @signalingUrlPlaceholder.
+ ///
+ /// In en, this message translates to:
+ /// **'ws://server-address:8787/signal'**
+ String get signalingUrlPlaceholder;
+
+ /// No description provided for @publicStun.
+ ///
+ /// In en, this message translates to:
+ /// **'Probe with public servers'**
+ String get publicStun;
+
+ /// No description provided for @publicStunDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.'**
+ String get publicStunDesc;
+
+ /// No description provided for @connectionStatus.
+ ///
+ /// In en, this message translates to:
+ /// **'Connection'**
+ String get connectionStatus;
+
+ /// No description provided for @connectedDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Connected to the signaling server'**
+ String get connectedDesc;
+
+ /// No description provided for @disconnectedDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t reach the server. Check the address and that the server is running.'**
+ String get disconnectedDesc;
+
+ /// No description provided for @connected.
+ ///
+ /// In en, this message translates to:
+ /// **'Connected'**
+ String get connected;
+
+ /// No description provided for @notConnected.
+ ///
+ /// In en, this message translates to:
+ /// **'Not connected'**
+ String get notConnected;
+
+ /// No description provided for @deviceName.
+ ///
+ /// In en, this message translates to:
+ /// **'Device name'**
+ String get deviceName;
+
+ /// No description provided for @deviceNameDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Shown in the list on your other devices'**
+ String get deviceNameDesc;
+
+ /// No description provided for @language.
+ ///
+ /// In en, this message translates to:
+ /// **'Language'**
+ String get language;
+
+ /// No description provided for @languageSystem.
+ ///
+ /// In en, this message translates to:
+ /// **'System'**
+ String get languageSystem;
+
+ /// No description provided for @sync.
+ ///
+ /// In en, this message translates to:
+ /// **'Sync'**
+ String get sync;
+
+ /// No description provided for @syncFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Items under the limit are pushed to your other devices as you copy. Larger ones sync as a record; pull them from History when you need them, so big files don\'t waste bandwidth or disk space.'**
+ String get syncFootnote;
+
+ /// No description provided for @autoSyncLimit.
+ ///
+ /// In en, this message translates to:
+ /// **'Auto-sync limit'**
+ String get autoSyncLimit;
+
+ /// No description provided for @autoSyncLimitDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Larger files are pulled by hand'**
+ String get autoSyncLimitDesc;
+
+ /// No description provided for @autoApply.
+ ///
+ /// In en, this message translates to:
+ /// **'Put received items on the clipboard'**
+ String get autoApply;
+
+ /// No description provided for @autoApplyDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'When off, put them on the clipboard from History yourself'**
+ String get autoApplyDesc;
+
+ /// No description provided for @whatToSync.
+ ///
+ /// In en, this message translates to:
+ /// **'What to sync'**
+ String get whatToSync;
+
+ /// No description provided for @syncFiles.
+ ///
+ /// In en, this message translates to:
+ /// **'Files and folders'**
+ String get syncFiles;
+
+ /// No description provided for @syncText.
+ ///
+ /// In en, this message translates to:
+ /// **'Plain text'**
+ String get syncText;
+
+ /// No description provided for @syncRich.
+ ///
+ /// In en, this message translates to:
+ /// **'Rich text'**
+ String get syncRich;
+
+ /// No description provided for @syncImages.
+ ///
+ /// In en, this message translates to:
+ /// **'Images and screenshots'**
+ String get syncImages;
+
+ /// No description provided for @storage.
+ ///
+ /// In en, this message translates to:
+ /// **'Storage'**
+ String get storage;
+
+ /// No description provided for @storageFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'Expired items and cached files are cleaned up automatically.'**
+ String get storageFootnote;
+
+ /// No description provided for @keepHistory.
+ ///
+ /// In en, this message translates to:
+ /// **'Keep history for'**
+ String get keepHistory;
+
+ /// No description provided for @keepCache.
+ ///
+ /// In en, this message translates to:
+ /// **'Keep cached files for'**
+ String get keepCache;
+
+ /// No description provided for @keepCacheDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Never longer than the history'**
+ String get keepCacheDesc;
+
+ /// No description provided for @cacheUsage.
+ ///
+ /// In en, this message translates to:
+ /// **'Cache size'**
+ String get cacheUsage;
+
+ /// No description provided for @backgroundSync.
+ ///
+ /// In en, this message translates to:
+ /// **'Background sync'**
+ String get backgroundSync;
+
+ /// No description provided for @backgroundFootnote.
+ ///
+ /// In en, this message translates to:
+ /// **'When off, nothing syncs and CopySync doesn\'t start at login. History and pairings are kept; open the app to turn it back on.'**
+ String get backgroundFootnote;
+
+ /// No description provided for @backgroundService.
+ ///
+ /// In en, this message translates to:
+ /// **'Background service'**
+ String get backgroundService;
+
+ /// No description provided for @backgroundServiceDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Starts at login and keeps syncing with the window closed'**
+ String get backgroundServiceDesc;
+
+ /// No description provided for @restart.
+ ///
+ /// In en, this message translates to:
+ /// **'Restart'**
+ String get restart;
+
+ /// No description provided for @restarted.
+ ///
+ /// In en, this message translates to:
+ /// **'Background service restarted'**
+ String get restarted;
+
+ /// No description provided for @disableEllipsis.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn off…'**
+ String get disableEllipsis;
+
+ /// No description provided for @about.
+ ///
+ /// In en, this message translates to:
+ /// **'About'**
+ String get about;
+
+ /// No description provided for @aboutDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Open source, MIT License'**
+ String get aboutDesc;
+
+ /// No description provided for @homepage.
+ ///
+ /// In en, this message translates to:
+ /// **'Website'**
+ String get homepage;
+
+ /// No description provided for @feedback.
+ ///
+ /// In en, this message translates to:
+ /// **'Report a problem'**
+ String get feedback;
+
+ /// No description provided for @disableTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn off background sync?'**
+ String get disableTitle;
+
+ /// No description provided for @disableBody.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync on {device} will stop syncing and won\'t start at login. History and pairings are kept.'**
+ String disableBody(String device);
+
+ /// No description provided for @disable.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn off'**
+ String get disable;
+
+ /// No description provided for @disabled.
+ ///
+ /// In en, this message translates to:
+ /// **'Background sync is off'**
+ String get disabled;
+
+ /// No description provided for @urlMustBeWs.
+ ///
+ /// In en, this message translates to:
+ /// **'The address must start with ws:// or wss://'**
+ String get urlMustBeWs;
+
+ /// No description provided for @serverUpdated.
+ ///
+ /// In en, this message translates to:
+ /// **'Server updated. Reconnecting…'**
+ String get serverUpdated;
+
+ /// No description provided for @deviceNameUpdated.
+ ///
+ /// In en, this message translates to:
+ /// **'Device name updated'**
+ String get deviceNameUpdated;
+
+ /// No description provided for @svcExtractTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Install or extract CopySync first'**
+ String get svcExtractTitle;
+
+ /// No description provided for @svcExtractBody.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.'**
+ String get svcExtractBody;
+
+ /// No description provided for @svcMoveTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Move CopySync to Applications first'**
+ String get svcMoveTitle;
+
+ /// No description provided for @svcMoveBody.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync is running straight from the disk image. Drag it into Applications, eject the disk image, and open it from Applications to turn on background sync.'**
+ String get svcMoveBody;
+
+ /// No description provided for @svcStartTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Get started with CopySync'**
+ String get svcStartTitle;
+
+ /// No description provided for @svcStartBody.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync runs a small background process that notices clipboard changes and stays connected to your other devices. Once on, it starts at login and keeps syncing even with this window closed.'**
+ String get svcStartBody;
+
+ /// No description provided for @svcEnable.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on background sync'**
+ String get svcEnable;
+
+ /// No description provided for @svcStaleTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn background sync on again'**
+ String get svcStaleTitle;
+
+ /// No description provided for @svcStaleBodyWin.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync has moved, but starting at login still points to the old place. Turn it on again so the background process uses this copy. History and pairings are kept.'**
+ String get svcStaleBodyWin;
+
+ /// No description provided for @svcStaleBodyMac.
+ ///
+ /// In en, this message translates to:
+ /// **'CopySync has moved, or was installed with an old script. Turn it on again so the background process uses this app. History and pairings are kept.'**
+ String get svcStaleBodyMac;
+
+ /// No description provided for @svcReenable.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on again'**
+ String get svcReenable;
+
+ /// No description provided for @svcStoppedTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'The background service isn\'t running'**
+ String get svcStoppedTitle;
+
+ /// No description provided for @svcStoppedBody.
+ ///
+ /// In en, this message translates to:
+ /// **'It may have just quit; the system usually restarts it within seconds. If you stay on this page, restart it with the button below.'**
+ String get svcStoppedBody;
+
+ /// No description provided for @svcDevBodyWin.
+ ///
+ /// In en, this message translates to:
+ /// **'This is a development build with no copysyncd.exe next to it. Run scripts\\build-windows.ps1 in the source folder to build a complete version.'**
+ String get svcDevBodyWin;
+
+ /// No description provided for @svcDevBodyMac.
+ ///
+ /// In en, this message translates to:
+ /// **'This is a development build without the background service. Run ./scripts/install-macos.sh in the source folder to install it.'**
+ String get svcDevBodyMac;
+
+ /// No description provided for @svcLogPath.
+ ///
+ /// In en, this message translates to:
+ /// **'Log: {path}'**
+ String svcLogPath(String path);
+
+ /// No description provided for @svcCanDisable.
+ ///
+ /// In en, this message translates to:
+ /// **'You can turn background sync off anytime in Settings.'**
+ String get svcCanDisable;
+}
+
+class _AppLocalizationsDelegate
+ extends LocalizationsDelegate<AppLocalizations> {
+ const _AppLocalizationsDelegate();
+
+ @override
+ Future<AppLocalizations> load(Locale locale) {
+ return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
+ }
+
+ @override
+ bool isSupported(Locale locale) =>
+ <String>['en', 'ja', 'zh'].contains(locale.languageCode);
+
+ @override
+ bool shouldReload(_AppLocalizationsDelegate old) => false;
+}
+
+AppLocalizations lookupAppLocalizations(Locale locale) {
+ // Lookup logic when only language code is specified.
+ switch (locale.languageCode) {
+ case 'en':
+ return AppLocalizationsEn();
+ case 'ja':
+ return AppLocalizationsJa();
+ case 'zh':
+ return AppLocalizationsZh();
+ }
+
+ throw FlutterError(
+ 'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
+ 'an issue with the localizations generation tool. Please file an issue '
+ 'on GitHub with a reproducible sample app and the gen-l10n configuration '
+ 'that was used.',
+ );
+}
diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dart
new file mode 100644
index 0000000..9841182
--- /dev/null
+++ b/ui/lib/l10n/app_localizations_en.dart
@@ -0,0 +1,707 @@
+// ignore: unused_import
+import 'package:intl/intl.dart' as intl;
+import 'app_localizations.dart';
+
+// ignore_for_file: type=lint
+
+/// The translations for English (`en`).
+class AppLocalizationsEn extends AppLocalizations {
+ AppLocalizationsEn([String locale = 'en']) : super(locale);
+
+ @override
+ String get navHistory => 'History';
+
+ @override
+ String get navDevices => 'Devices';
+
+ @override
+ String get navSettings => 'Settings';
+
+ @override
+ String get linkConnecting => 'Connecting…';
+
+ @override
+ String get linkServiceNotRunning => 'Service not running';
+
+ @override
+ String get linkNoServer => 'No server connection';
+
+ @override
+ String linkOnlinePeers(int count) {
+ String _temp0 = intl.Intl.pluralLogic(
+ count,
+ locale: localeName,
+ other: '$count devices online',
+ one: '1 device online',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String get linkServerConnected => 'Connected to the server';
+
+ @override
+ String linkConnectionLost(String detail) {
+ return 'Connection lost: $detail';
+ }
+
+ @override
+ String get linkServiceDisconnected => 'Service disconnected';
+
+ @override
+ String get linkServiceDisabled => 'Background sync is off';
+
+ @override
+ String get errServiceNotConnected =>
+ 'Not connected to the background service';
+
+ @override
+ String get errUnimplemented => 'This isn\'t available yet';
+
+ @override
+ String get errUnavailable => 'Can\'t reach the background service';
+
+ @override
+ String errServiceStart(String detail) {
+ return 'Couldn\'t start the background service: $detail';
+ }
+
+ @override
+ String errServiceRestart(String detail) {
+ return 'Couldn\'t restart the background service: $detail';
+ }
+
+ @override
+ String errAutostart(String detail) {
+ return 'Couldn\'t set CopySync to start at login: $detail';
+ }
+
+ @override
+ String get thisMacTitle => 'This Mac';
+
+ @override
+ String get thisPcTitle => 'This computer';
+
+ @override
+ String get thisMacInText => 'this Mac';
+
+ @override
+ String get thisPcInText => 'this computer';
+
+ @override
+ String get bothMacs => 'both Macs';
+
+ @override
+ String get bothDevices => 'both devices';
+
+ @override
+ String get thisDeviceShort => 'This device';
+
+ @override
+ String fromDevice(String name) {
+ return 'From $name';
+ }
+
+ @override
+ String get cancel => 'Cancel';
+
+ @override
+ String get close => 'Close';
+
+ @override
+ String get save => 'Save';
+
+ @override
+ String get retry => 'Try again';
+
+ @override
+ String get continueAction => 'Continue';
+
+ @override
+ String get justNow => 'Just now';
+
+ @override
+ String secondsAgo(int n) {
+ return '${n}s ago';
+ }
+
+ @override
+ String minutesAgo(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: '$n minutes ago',
+ one: '1 minute ago',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String hoursAgo(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: '$n hours ago',
+ one: '1 hour ago',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String daysAgo(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: '$n days ago',
+ one: 'Yesterday',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String monthDay(int month, int day) {
+ return '$month/$day';
+ }
+
+ @override
+ String durationHours(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: '$n hours',
+ one: '1 hour',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String durationDays(int n) {
+ String _temp0 = intl.Intl.pluralLogic(
+ n,
+ locale: localeName,
+ other: '$n days',
+ one: '1 day',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String get historyEmptySubtitle =>
+ 'Copy on any of your devices and it shows up here';
+
+ @override
+ String historyCount(int count) {
+ String _temp0 = intl.Intl.pluralLogic(
+ count,
+ locale: localeName,
+ other: '$count items',
+ one: '1 item',
+ );
+ return '$_temp0';
+ }
+
+ @override
+ String historyCountKept(int count, String ttl) {
+ String _temp0 = intl.Intl.pluralLogic(
+ count,
+ locale: localeName,
+ other: '$count items',
+ one: '1 item',
+ );
+ return '$_temp0, kept for $ttl';
+ }
+
+ @override
+ String get filterAll => 'All';
+
+ @override
+ String get filterText => 'Text';
+
+ @override
+ String get filterImage => 'Images';
+
+ @override
+ String get filterFile => 'Files';
+
+ @override
+ String get historyClearTooltip => 'Clear history';
+
+ @override
+ String get historyEmptyTitle => 'Nothing here yet';
+
+ @override
+ String get historyEmptyFilteredTitle => 'Nothing of this kind';
+
+ @override
+ String get historyEmptyBody =>
+ 'Copy text, an image or a file on any paired device and it appears here.';
+
+ @override
+ String get clearConfirmTitle => 'Clear the whole history?';
+
+ @override
+ String clearConfirmBody(String device) {
+ return 'Everything synced from your devices, and the cached files, will be removed from $device. The original files aren\'t affected.';
+ }
+
+ @override
+ String get clear => 'Clear';
+
+ @override
+ String get historyCleared => 'History cleared';
+
+ @override
+ String get permDeniedTitle => 'CopySync can\'t read the clipboard';
+
+ @override
+ String get permAskTitle => 'Allow CopySync to read the clipboard';
+
+ @override
+ String get permDeniedBody =>
+ 'What you copy on this Mac won\'t be synced. In System Settings, set CopySync Daemon to Allow.';
+
+ @override
+ String get permAskBody =>
+ 'Otherwise macOS asks every time. In System Settings, set CopySync Daemon to Allow.';
+
+ @override
+ String get openSystemSettings => 'Open System Settings';
+
+ @override
+ String get fetch => 'Pull to this device';
+
+ @override
+ String get fetchStarted => 'Pulling…';
+
+ @override
+ String get transferFailed => 'Transfer failed';
+
+ @override
+ String get expired => 'Expired';
+
+ @override
+ String get preview => 'Preview';
+
+ @override
+ String get putOnClipboard => 'Copy to clipboard';
+
+ @override
+ String get putOnClipboardDone => 'On the clipboard';
+
+ @override
+ String get deleteRecord => 'Delete this item';
+
+ @override
+ String get deleted => 'Deleted';
+
+ @override
+ String get emptyRecord => '(empty)';
+
+ @override
+ String get imageRecord => 'Image';
+
+ @override
+ String itemsSummary(String name, int others, int count) {
+ String _temp0 = intl.Intl.pluralLogic(
+ others,
+ locale: localeName,
+ other: '$others more',
+ one: '1 more',
+ );
+ return '$name and $_temp0';
+ }
+
+ @override
+ String get imagePreviewTitle => 'Image preview';
+
+ @override
+ String get closePreview => 'Close preview';
+
+ @override
+ String get previewHint => 'Scroll or pinch to zoom, drag to move around';
+
+ @override
+ String get fitWindow => 'Fit to window';
+
+ @override
+ String get previewDeleted => 'This image has been deleted from the history';
+
+ @override
+ String get previewExpired => 'This image has expired and can\'t be previewed';
+
+ @override
+ String get previewDownloading => 'Downloading the image…';
+
+ @override
+ String get previewDownloadFailed => 'The download failed. Try again.';
+
+ @override
+ String get previewNotDownloaded => 'This image isn\'t on this computer yet';
+
+ @override
+ String get downloadAndPreview => 'Download and preview';
+
+ @override
+ String get previewUnavailable => 'This image can\'t be previewed right now';
+
+ @override
+ String get imageSemantic => 'Image from the history';
+
+ @override
+ String get previewUnreadable =>
+ 'Can\'t read the image. The file may have been cleaned up or damaged.';
+
+ @override
+ String get devicesSubtitleEmpty =>
+ 'Once paired, your devices share one clipboard';
+
+ @override
+ String devicesSubtitle(int paired, int online) {
+ return '$paired paired, $online online';
+ }
+
+ @override
+ String get addDevice => 'Add device';
+
+ @override
+ String thisDeviceFootnote(String both) {
+ return 'When pairing, $both show the same two lines of security fingerprints, one for each device. Confirm only if they match character for character.';
+ }
+
+ @override
+ String get noDevicesTitle => 'No paired devices yet';
+
+ @override
+ String get noDevicesBody =>
+ 'Open CopySync on your other computer and link the two with a 6-character pairing code.';
+
+ @override
+ String get noDevicesNeedServer =>
+ 'Connect to a signaling server in Settings before pairing.';
+
+ @override
+ String get pairedDevices => 'Paired devices';
+
+ @override
+ String get pairedFootnote =>
+ 'Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.';
+
+ @override
+ String get offline => 'Offline';
+
+ @override
+ String get direct => 'Direct';
+
+ @override
+ String get relay => 'Relay';
+
+ @override
+ String get online => 'Online';
+
+ @override
+ String get moreActions => 'More';
+
+ @override
+ String get copyFingerprint => 'Copy fingerprint';
+
+ @override
+ String get unpairEllipsis => 'Unpair…';
+
+ @override
+ String get fingerprintCopied => 'Fingerprint copied';
+
+ @override
+ String unpairTitle(String name) {
+ return 'Unpair “$name”?';
+ }
+
+ @override
+ String get unpairBody =>
+ 'The two devices will stop syncing. To sync again, you\'ll need to pair them and check the fingerprints again.';
+
+ @override
+ String get unpair => 'Unpair';
+
+ @override
+ String get unpaired => 'Unpaired';
+
+ @override
+ String get generateCode => 'Show a code';
+
+ @override
+ String get enterCode => 'Enter a code';
+
+ @override
+ String get codeFailedTitle => 'Couldn\'t create a pairing code';
+
+ @override
+ String get enterOnOther => 'Enter this code on your other device';
+
+ @override
+ String get codeCopied => 'Code copied';
+
+ @override
+ String get codeHint => 'Click to copy. Valid for 5 minutes.';
+
+ @override
+ String afterEnterFootnote(String both) {
+ return 'Once it\'s entered, $both show the same two lines of security fingerprints. Confirm only if they match.';
+ }
+
+ @override
+ String get codeInvalid => 'A pairing code is 6 letters or digits';
+
+ @override
+ String get enterCodeShown => 'Enter the code shown on your other device';
+
+ @override
+ String get pairingDone => 'Paired';
+
+ @override
+ String get pairingRejected => 'Pairing declined';
+
+ @override
+ String get verifyTitle => 'Check the security fingerprints';
+
+ @override
+ String pairingWith(String name) {
+ return 'Pairing with “$name”';
+ }
+
+ @override
+ String verifyBody(String both) {
+ return 'The two lines on $both must be identical. If even one character differs, someone may be tampering with the connection, so decline.';
+ }
+
+ @override
+ String get rejectMismatch => 'Mismatch, decline';
+
+ @override
+ String get confirmMatch => 'They match, pair';
+
+ @override
+ String get server => 'Server';
+
+ @override
+ String get serverFootnote =>
+ 'The server only helps devices find each other and set up a direct connection. It can\'t see what they send.';
+
+ @override
+ String get signalingUrl => 'Signaling server';
+
+ @override
+ String get signalingUrlDesc =>
+ 'Press Return to save; it reconnects right away';
+
+ @override
+ String get signalingUrlPlaceholder => 'ws://server-address:8787/signal';
+
+ @override
+ String get publicStun => 'Probe with public servers';
+
+ @override
+ String get publicStunDesc =>
+ 'On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.';
+
+ @override
+ String get connectionStatus => 'Connection';
+
+ @override
+ String get connectedDesc => 'Connected to the signaling server';
+
+ @override
+ String get disconnectedDesc =>
+ 'Can\'t reach the server. Check the address and that the server is running.';
+
+ @override
+ String get connected => 'Connected';
+
+ @override
+ String get notConnected => 'Not connected';
+
+ @override
+ String get deviceName => 'Device name';
+
+ @override
+ String get deviceNameDesc => 'Shown in the list on your other devices';
+
+ @override
+ String get language => 'Language';
+
+ @override
+ String get languageSystem => 'System';
+
+ @override
+ String get sync => 'Sync';
+
+ @override
+ String get syncFootnote =>
+ 'Items under the limit are pushed to your other devices as you copy. Larger ones sync as a record; pull them from History when you need them, so big files don\'t waste bandwidth or disk space.';
+
+ @override
+ String get autoSyncLimit => 'Auto-sync limit';
+
+ @override
+ String get autoSyncLimitDesc => 'Larger files are pulled by hand';
+
+ @override
+ String get autoApply => 'Put received items on the clipboard';
+
+ @override
+ String get autoApplyDesc =>
+ 'When off, put them on the clipboard from History yourself';
+
+ @override
+ String get whatToSync => 'What to sync';
+
+ @override
+ String get syncFiles => 'Files and folders';
+
+ @override
+ String get syncText => 'Plain text';
+
+ @override
+ String get syncRich => 'Rich text';
+
+ @override
+ String get syncImages => 'Images and screenshots';
+
+ @override
+ String get storage => 'Storage';
+
+ @override
+ String get storageFootnote =>
+ 'Expired items and cached files are cleaned up automatically.';
+
+ @override
+ String get keepHistory => 'Keep history for';
+
+ @override
+ String get keepCache => 'Keep cached files for';
+
+ @override
+ String get keepCacheDesc => 'Never longer than the history';
+
+ @override
+ String get cacheUsage => 'Cache size';
+
+ @override
+ String get backgroundSync => 'Background sync';
+
+ @override
+ String get backgroundFootnote =>
+ 'When off, nothing syncs and CopySync doesn\'t start at login. History and pairings are kept; open the app to turn it back on.';
+
+ @override
+ String get backgroundService => 'Background service';
+
+ @override
+ String get backgroundServiceDesc =>
+ 'Starts at login and keeps syncing with the window closed';
+
+ @override
+ String get restart => 'Restart';
+
+ @override
+ String get restarted => 'Background service restarted';
+
+ @override
+ String get disableEllipsis => 'Turn off…';
+
+ @override
+ String get about => 'About';
+
+ @override
+ String get aboutDesc => 'Open source, MIT License';
+
+ @override
+ String get homepage => 'Website';
+
+ @override
+ String get feedback => 'Report a problem';
+
+ @override
+ String get disableTitle => 'Turn off background sync?';
+
+ @override
+ String disableBody(String device) {
+ return 'CopySync on $device will stop syncing and won\'t start at login. History and pairings are kept.';
+ }
+
+ @override
+ String get disable => 'Turn off';
+
+ @override
+ String get disabled => 'Background sync is off';
+
+ @override
+ String get urlMustBeWs => 'The address must start with ws:// or wss://';
+
+ @override
+ String get serverUpdated => 'Server updated. Reconnecting…';
+
+ @override
+ String get deviceNameUpdated => 'Device name updated';
+
+ @override
+ String get svcExtractTitle => 'Install or extract CopySync first';
+
+ @override
+ String get svcExtractBody =>
+ 'CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.';
+
+ @override
+ String get svcMoveTitle => 'Move CopySync to Applications first';
+
+ @override
+ String get svcMoveBody =>
+ 'CopySync is running straight from the disk image. Drag it into Applications, eject the disk image, and open it from Applications to turn on background sync.';
+
+ @override
+ String get svcStartTitle => 'Get started with CopySync';
+
+ @override
+ String get svcStartBody =>
+ 'CopySync runs a small background process that notices clipboard changes and stays connected to your other devices. Once on, it starts at login and keeps syncing even with this window closed.';
+
+ @override
+ String get svcEnable => 'Turn on background sync';
+
+ @override
+ String get svcStaleTitle => 'Turn background sync on again';
+
+ @override
+ String get svcStaleBodyWin =>
+ 'CopySync has moved, but starting at login still points to the old place. Turn it on again so the background process uses this copy. History and pairings are kept.';
+
+ @override
+ String get svcStaleBodyMac =>
+ 'CopySync has moved, or was installed with an old script. Turn it on again so the background process uses this app. History and pairings are kept.';
+
+ @override
+ String get svcReenable => 'Turn on again';
+
+ @override
+ String get svcStoppedTitle => 'The background service isn\'t running';
+
+ @override
+ String get svcStoppedBody =>
+ 'It may have just quit; the system usually restarts it within seconds. If you stay on this page, restart it with the button below.';
+
+ @override
+ String get svcDevBodyWin =>
+ 'This is a development build with no copysyncd.exe next to it. Run scripts\\build-windows.ps1 in the source folder to build a complete version.';
+
+ @override
+ String get svcDevBodyMac =>
+ 'This is a development build without the background service. Run ./scripts/install-macos.sh in the source folder to install it.';
+
+ @override
+ String svcLogPath(String path) {
+ return 'Log: $path';
+ }
+
+ @override
+ String get svcCanDisable =>
+ 'You can turn background sync off anytime in Settings.';
+}
diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dart
new file mode 100644
index 0000000..24bf7a2
--- /dev/null
+++ b/ui/lib/l10n/app_localizations_ja.dart
@@ -0,0 +1,639 @@
+// ignore: unused_import
+import 'package:intl/intl.dart' as intl;
+import 'app_localizations.dart';
+
+// ignore_for_file: type=lint
+
+/// The translations for Japanese (`ja`).
+class AppLocalizationsJa extends AppLocalizations {
+ AppLocalizationsJa([String locale = 'ja']) : super(locale);
+
+ @override
+ String get navHistory => '履歴';
+
+ @override
+ String get navDevices => 'デバイス';
+
+ @override
+ String get navSettings => '設定';
+
+ @override
+ String get linkConnecting => '接続中…';
+
+ @override
+ String get linkServiceNotRunning => 'サービス停止中';
+
+ @override
+ String get linkNoServer => 'サーバーに未接続';
+
+ @override
+ String linkOnlinePeers(int count) {
+ return '$count 台がオンライン';
+ }
+
+ @override
+ String get linkServerConnected => 'サーバーに接続済み';
+
+ @override
+ String linkConnectionLost(String detail) {
+ return '接続が切れました:$detail';
+ }
+
+ @override
+ String get linkServiceDisconnected => 'サービスとの接続が切れました';
+
+ @override
+ String get linkServiceDisabled => '同期はオフです';
+
+ @override
+ String get errServiceNotConnected => 'バックグラウンドサービスに接続していません';
+
+ @override
+ String get errUnimplemented => 'この機能はまだ使えません';
+
+ @override
+ String get errUnavailable => 'バックグラウンドサービスに接続できません';
+
+ @override
+ String errServiceStart(String detail) {
+ return 'バックグラウンドサービスを起動できませんでした:$detail';
+ }
+
+ @override
+ String errServiceRestart(String detail) {
+ return 'バックグラウンドサービスを再起動できませんでした:$detail';
+ }
+
+ @override
+ String errAutostart(String detail) {
+ return 'ログイン時の自動起動を設定できませんでした:$detail';
+ }
+
+ @override
+ String get thisMacTitle => 'この Mac';
+
+ @override
+ String get thisPcTitle => 'このコンピューター';
+
+ @override
+ String get thisMacInText => 'この Mac ';
+
+ @override
+ String get thisPcInText => 'このコンピューター';
+
+ @override
+ String get bothMacs => '両方の Mac ';
+
+ @override
+ String get bothDevices => '両方のデバイス';
+
+ @override
+ String get thisDeviceShort => 'このデバイス';
+
+ @override
+ String fromDevice(String name) {
+ return '$name から';
+ }
+
+ @override
+ String get cancel => 'キャンセル';
+
+ @override
+ String get close => '閉じる';
+
+ @override
+ String get save => '保存';
+
+ @override
+ String get retry => '再試行';
+
+ @override
+ String get continueAction => '続ける';
+
+ @override
+ String get justNow => 'たった今';
+
+ @override
+ String secondsAgo(int n) {
+ return '$n 秒前';
+ }
+
+ @override
+ String minutesAgo(int n) {
+ return '$n 分前';
+ }
+
+ @override
+ String hoursAgo(int n) {
+ return '$n 時間前';
+ }
+
+ @override
+ String daysAgo(int n) {
+ return '$n 日前';
+ }
+
+ @override
+ String monthDay(int month, int day) {
+ return '$month月$day日';
+ }
+
+ @override
+ String durationHours(int n) {
+ return '$n 時間';
+ }
+
+ @override
+ String durationDays(int n) {
+ return '$n 日';
+ }
+
+ @override
+ String get historyEmptySubtitle => 'どのデバイスでコピーしても、ここに表示されます';
+
+ @override
+ String historyCount(int count) {
+ return '$count 件';
+ }
+
+ @override
+ String historyCountKept(int count, String ttl) {
+ return '$count 件、$ttl保存';
+ }
+
+ @override
+ String get filterAll => 'すべて';
+
+ @override
+ String get filterText => 'テキスト';
+
+ @override
+ String get filterImage => '画像';
+
+ @override
+ String get filterFile => 'ファイル';
+
+ @override
+ String get historyClearTooltip => '履歴を消去';
+
+ @override
+ String get historyEmptyTitle => 'まだ履歴がありません';
+
+ @override
+ String get historyEmptyFilteredTitle => 'この種類の履歴はありません';
+
+ @override
+ String get historyEmptyBody => 'ペアリングしたどのデバイスでテキスト、画像、ファイルをコピーしても、ここに表示されます。';
+
+ @override
+ String get clearConfirmTitle => '履歴をすべて消去しますか?';
+
+ @override
+ String clearConfirmBody(String device) {
+ return '同期した履歴とキャッシュしたファイルが$deviceから削除されます。元のファイルには影響しません。';
+ }
+
+ @override
+ String get clear => '消去';
+
+ @override
+ String get historyCleared => '履歴を消去しました';
+
+ @override
+ String get permDeniedTitle => 'CopySync はクリップボードを読み取れません';
+
+ @override
+ String get permAskTitle => 'CopySync にクリップボードの読み取りを許可してください';
+
+ @override
+ String get permDeniedBody =>
+ 'この Mac でコピーした内容は同期されません。システム設定で CopySync Daemon を「許可」にしてください。';
+
+ @override
+ String get permAskBody =>
+ '許可しないと macOS が毎回確認します。システム設定で CopySync Daemon を「許可」にしてください。';
+
+ @override
+ String get openSystemSettings => 'システム設定を開く';
+
+ @override
+ String get fetch => 'このデバイスに取り込む';
+
+ @override
+ String get fetchStarted => '取り込みを開始しました';
+
+ @override
+ String get transferFailed => '転送に失敗しました';
+
+ @override
+ String get expired => '期限切れ';
+
+ @override
+ String get preview => 'プレビュー';
+
+ @override
+ String get putOnClipboard => 'クリップボードに入れる';
+
+ @override
+ String get putOnClipboardDone => 'クリップボードに入れました';
+
+ @override
+ String get deleteRecord => 'この履歴を削除';
+
+ @override
+ String get deleted => '削除しました';
+
+ @override
+ String get emptyRecord => '(空)';
+
+ @override
+ String get imageRecord => '画像';
+
+ @override
+ String itemsSummary(String name, int others, int count) {
+ return '$name ほか $others 件';
+ }
+
+ @override
+ String get imagePreviewTitle => '画像プレビュー';
+
+ @override
+ String get closePreview => 'プレビューを閉じる';
+
+ @override
+ String get previewHint => 'ホイールやトラックパッドで拡大縮小、ドラッグで移動';
+
+ @override
+ String get fitWindow => 'ウィンドウに合わせる';
+
+ @override
+ String get previewDeleted => 'この画像は履歴から削除されました';
+
+ @override
+ String get previewExpired => 'この画像は期限切れのためプレビューできません';
+
+ @override
+ String get previewDownloading => '画像をダウンロード中…';
+
+ @override
+ String get previewDownloadFailed => 'ダウンロードに失敗しました。もう一度お試しください。';
+
+ @override
+ String get previewNotDownloaded => 'この画像はまだこのコンピューターにありません';
+
+ @override
+ String get downloadAndPreview => 'ダウンロードしてプレビュー';
+
+ @override
+ String get previewUnavailable => '現在この画像はプレビューできません';
+
+ @override
+ String get imageSemantic => '履歴の画像';
+
+ @override
+ String get previewUnreadable => '画像を読み込めません。ファイルが削除されたか破損している可能性があります。';
+
+ @override
+ String get devicesSubtitleEmpty => 'ペアリングすると、デバイス間でクリップボードが同期されます';
+
+ @override
+ String devicesSubtitle(int paired, int online) {
+ return 'ペアリング済み $paired 台、オンライン $online 台';
+ }
+
+ @override
+ String get addDevice => 'デバイスを追加';
+
+ @override
+ String thisDeviceFootnote(String both) {
+ return 'ペアリング時、$bothに同じ 2 行のセキュリティ指紋(このデバイスと相手のもの)が表示されます。1 文字ずつ一致を確かめてから確定してください。';
+ }
+
+ @override
+ String get noDevicesTitle => 'ペアリングしたデバイスはまだありません';
+
+ @override
+ String get noDevicesBody => 'もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。';
+
+ @override
+ String get noDevicesNeedServer => 'ペアリングの前に、「設定」でシグナリングサーバーに接続してください。';
+
+ @override
+ String get pairedDevices => 'ペアリング済みのデバイス';
+
+ @override
+ String get pairedFootnote =>
+ '直接接続:データは 2 台のデバイス間で直接やり取りされます。中継:直接つながらないネットワークでは、あなたのサーバーを経由します。内容はエンドツーエンドで暗号化されたままです。';
+
+ @override
+ String get offline => 'オフライン';
+
+ @override
+ String get direct => '直接接続';
+
+ @override
+ String get relay => '中継';
+
+ @override
+ String get online => 'オンライン';
+
+ @override
+ String get moreActions => 'その他の操作';
+
+ @override
+ String get copyFingerprint => '指紋をコピー';
+
+ @override
+ String get unpairEllipsis => 'ペアリングを解除…';
+
+ @override
+ String get fingerprintCopied => '指紋をコピーしました';
+
+ @override
+ String unpairTitle(String name) {
+ return '「$name」とのペアリングを解除しますか?';
+ }
+
+ @override
+ String get unpairBody =>
+ '2 台のデバイスは同期しなくなります。再開するには、もう一度ペアリングして指紋を確かめる必要があります。';
+
+ @override
+ String get unpair => 'ペアリングを解除';
+
+ @override
+ String get unpaired => 'ペアリングを解除しました';
+
+ @override
+ String get generateCode => 'コードを表示';
+
+ @override
+ String get enterCode => 'コードを入力';
+
+ @override
+ String get codeFailedTitle => 'ペアリングコードを作成できませんでした';
+
+ @override
+ String get enterOnOther => 'もう一台のデバイスでこのコードを入力してください';
+
+ @override
+ String get codeCopied => 'コードをコピーしました';
+
+ @override
+ String get codeHint => 'クリックでコピー。有効期間は 5 分です。';
+
+ @override
+ String afterEnterFootnote(String both) {
+ return '入力されると、$bothに同じ 2 行のセキュリティ指紋が表示されます。一致を確かめてから確定してください。';
+ }
+
+ @override
+ String get codeInvalid => 'ペアリングコードは 6 桁の英数字です';
+
+ @override
+ String get enterCodeShown => 'もう一台のデバイスに表示されたコードを入力してください';
+
+ @override
+ String get pairingDone => 'ペアリングしました';
+
+ @override
+ String get pairingRejected => 'ペアリングを拒否しました';
+
+ @override
+ String get verifyTitle => 'セキュリティ指紋を確認';
+
+ @override
+ String pairingWith(String name) {
+ return '「$name」とペアリング中';
+ }
+
+ @override
+ String verifyBody(String both) {
+ return '$bothに表示された 2 行は完全に同じはずです。1 文字でも違う場合は、第三者が通信を改ざんしている可能性があるため、拒否してください。';
+ }
+
+ @override
+ String get rejectMismatch => '不一致、拒否';
+
+ @override
+ String get confirmMatch => '一致、ペアリング';
+
+ @override
+ String get server => 'サーバー';
+
+ @override
+ String get serverFootnote => 'サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。';
+
+ @override
+ String get signalingUrl => 'シグナリングサーバー';
+
+ @override
+ String get signalingUrlDesc => 'Enter で保存し、すぐに再接続します';
+
+ @override
+ String get signalingUrlPlaceholder => 'ws://サーバーアドレス:8787/signal';
+
+ @override
+ String get publicStun => '公開サーバーで出口を調べる';
+
+ @override
+ String get publicStunDesc =>
+ '複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。';
+
+ @override
+ String get connectionStatus => '接続状態';
+
+ @override
+ String get connectedDesc => 'シグナリングサーバーに接続しています';
+
+ @override
+ String get disconnectedDesc => 'サーバーに接続できません。アドレスとサーバーの稼働を確認してください。';
+
+ @override
+ String get connected => '接続済み';
+
+ @override
+ String get notConnected => '未接続';
+
+ @override
+ String get deviceName => 'デバイス名';
+
+ @override
+ String get deviceNameDesc => '他のデバイスの一覧に表示されます';
+
+ @override
+ String get language => '言語';
+
+ @override
+ String get languageSystem => 'システムに合わせる';
+
+ @override
+ String get sync => '同期';
+
+ @override
+ String get syncFootnote =>
+ '上限より小さい内容はコピーした時点で他のデバイスに送られます。大きいものは記録だけを同期し、必要なときに「履歴」から取り込むので、帯域やディスクを無駄に使いません。';
+
+ @override
+ String get autoSyncLimit => '自動同期の上限';
+
+ @override
+ String get autoSyncLimitDesc => 'これより大きいファイルは手動で取り込みます';
+
+ @override
+ String get autoApply => '受け取った内容をクリップボードに入れる';
+
+ @override
+ String get autoApplyDesc => 'オフの場合は「履歴」から手動でクリップボードに入れます';
+
+ @override
+ String get whatToSync => '同期する内容';
+
+ @override
+ String get syncFiles => 'ファイルとフォルダ';
+
+ @override
+ String get syncText => 'プレーンテキスト';
+
+ @override
+ String get syncRich => '書式付きテキスト';
+
+ @override
+ String get syncImages => '画像とスクリーンショット';
+
+ @override
+ String get storage => 'ストレージ';
+
+ @override
+ String get storageFootnote => '期限切れの履歴とキャッシュは自動で削除されます。';
+
+ @override
+ String get keepHistory => '履歴の保存期間';
+
+ @override
+ String get keepCache => 'キャッシュの保存期間';
+
+ @override
+ String get keepCacheDesc => '履歴の保存期間を超えません';
+
+ @override
+ String get cacheUsage => 'キャッシュ容量';
+
+ @override
+ String get backgroundSync => 'バックグラウンド同期';
+
+ @override
+ String get backgroundFootnote =>
+ 'オフにすると同期せず、ログイン時にも起動しません。履歴とペアリングは残り、アプリを開けば再び有効にできます。';
+
+ @override
+ String get backgroundService => 'バックグラウンドサービス';
+
+ @override
+ String get backgroundServiceDesc => 'ログイン時に起動し、ウィンドウを閉じても同期を続けます';
+
+ @override
+ String get restart => '再起動';
+
+ @override
+ String get restarted => 'バックグラウンドサービスを再起動しました';
+
+ @override
+ String get disableEllipsis => 'オフにする…';
+
+ @override
+ String get about => 'このアプリについて';
+
+ @override
+ String get aboutDesc => 'オープンソース(MIT ライセンス)';
+
+ @override
+ String get homepage => 'ウェブサイト';
+
+ @override
+ String get feedback => '問題を報告';
+
+ @override
+ String get disableTitle => 'バックグラウンド同期をオフにしますか?';
+
+ @override
+ String disableBody(String device) {
+ return '$deviceは同期を停止し、ログイン時にも起動しなくなります。履歴とペアリングは残ります。';
+ }
+
+ @override
+ String get disable => 'オフにする';
+
+ @override
+ String get disabled => 'バックグラウンド同期をオフにしました';
+
+ @override
+ String get urlMustBeWs => 'アドレスは ws:// または wss:// で始めてください';
+
+ @override
+ String get serverUpdated => 'サーバーを更新しました。再接続しています…';
+
+ @override
+ String get deviceNameUpdated => 'デバイス名を更新しました';
+
+ @override
+ String get svcExtractTitle => '先に CopySync をインストールまたは展開してください';
+
+ @override
+ String get svcExtractBody =>
+ 'CopySync は zip から直接開かれていて、閉じると一時フォルダごと消えます。インストーラーを実行するか、フォルダ全体を展開してから開くと、バックグラウンド同期を有効にできます。';
+
+ @override
+ String get svcMoveTitle => '先に CopySync を「アプリケーション」に移動してください';
+
+ @override
+ String get svcMoveBody =>
+ 'CopySync はディスクイメージから直接開かれています。「アプリケーション」にドラッグしてディスクイメージを取り出し、「アプリケーション」から開くと、バックグラウンド同期を有効にできます。';
+
+ @override
+ String get svcStartTitle => 'CopySync を始める';
+
+ @override
+ String get svcStartBody =>
+ 'CopySync は小さなバックグラウンドプロセスを動かし、クリップボードの変化を検知して他のデバイスとつながり続けます。有効にするとログイン時に起動し、このウィンドウを閉じても同期を続けます。';
+
+ @override
+ String get svcEnable => 'バックグラウンド同期を有効にする';
+
+ @override
+ String get svcStaleTitle => 'バックグラウンド同期をもう一度有効にする';
+
+ @override
+ String get svcStaleBodyWin =>
+ 'CopySync の場所が変わりましたが、自動起動は以前の場所を指しています。もう一度有効にすると、このコピーを使うようになります。履歴とペアリングは残ります。';
+
+ @override
+ String get svcStaleBodyMac =>
+ 'CopySync の場所が変わったか、古いスクリプトでインストールされています。もう一度有効にすると、このアプリを使うようになります。履歴とペアリングは残ります。';
+
+ @override
+ String get svcReenable => 'もう一度有効にする';
+
+ @override
+ String get svcStoppedTitle => 'バックグラウンドサービスが動いていません';
+
+ @override
+ String get svcStoppedBody =>
+ '終了した直後かもしれません。通常は数秒で再起動されます。この画面のままなら、下のボタンで再起動してください。';
+
+ @override
+ String get svcDevBodyWin =>
+ '開発ビルドのため copysyncd.exe がありません。ソースフォルダで scripts\\build-windows.ps1 を実行して完全版をビルドしてください。';
+
+ @override
+ String get svcDevBodyMac =>
+ '開発ビルドのためバックグラウンドサービスが含まれていません。ソースフォルダで ./scripts/install-macos.sh を実行してインストールしてください。';
+
+ @override
+ String svcLogPath(String path) {
+ return 'ログ:$path';
+ }
+
+ @override
+ String get svcCanDisable => 'バックグラウンド同期は「設定」でいつでもオフにできます。';
+}
diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dart
new file mode 100644
index 0000000..1505bc6
--- /dev/null
+++ b/ui/lib/l10n/app_localizations_zh.dart
@@ -0,0 +1,635 @@
+// ignore: unused_import
+import 'package:intl/intl.dart' as intl;
+import 'app_localizations.dart';
+
+// ignore_for_file: type=lint
+
+/// The translations for Chinese (`zh`).
+class AppLocalizationsZh extends AppLocalizations {
+ AppLocalizationsZh([String locale = 'zh']) : super(locale);
+
+ @override
+ String get navHistory => '复制记录';
+
+ @override
+ String get navDevices => '设备';
+
+ @override
+ String get navSettings => '设置';
+
+ @override
+ String get linkConnecting => '正在连接…';
+
+ @override
+ String get linkServiceNotRunning => '后台服务未运行';
+
+ @override
+ String get linkNoServer => '未连接服务器';
+
+ @override
+ String linkOnlinePeers(int count) {
+ return '$count 台设备在线';
+ }
+
+ @override
+ String get linkServerConnected => '已连接服务器';
+
+ @override
+ String linkConnectionLost(String detail) {
+ return '连接中断:$detail';
+ }
+
+ @override
+ String get linkServiceDisconnected => '后台服务已断开';
+
+ @override
+ String get linkServiceDisabled => '后台服务已停用';
+
+ @override
+ String get errServiceNotConnected => '后台服务未连接';
+
+ @override
+ String get errUnimplemented => '该功能尚未接入';
+
+ @override
+ String get errUnavailable => '无法连接后台服务';
+
+ @override
+ String errServiceStart(String detail) {
+ return '启动后台服务失败:$detail';
+ }
+
+ @override
+ String errServiceRestart(String detail) {
+ return '重启后台服务失败:$detail';
+ }
+
+ @override
+ String errAutostart(String detail) {
+ return '登记开机自启失败:$detail';
+ }
+
+ @override
+ String get thisMacTitle => '这台 Mac';
+
+ @override
+ String get thisPcTitle => '这台电脑';
+
+ @override
+ String get thisMacInText => '这台 Mac ';
+
+ @override
+ String get thisPcInText => '这台电脑';
+
+ @override
+ String get bothMacs => '两台 Mac ';
+
+ @override
+ String get bothDevices => '两台设备';
+
+ @override
+ String get thisDeviceShort => '本机';
+
+ @override
+ String fromDevice(String name) {
+ return '来自 $name';
+ }
+
+ @override
+ String get cancel => '取消';
+
+ @override
+ String get close => '关闭';
+
+ @override
+ String get save => '保存';
+
+ @override
+ String get retry => '重试';
+
+ @override
+ String get continueAction => '继续';
+
+ @override
+ String get justNow => '刚刚';
+
+ @override
+ String secondsAgo(int n) {
+ return '$n 秒前';
+ }
+
+ @override
+ String minutesAgo(int n) {
+ return '$n 分钟前';
+ }
+
+ @override
+ String hoursAgo(int n) {
+ return '$n 小时前';
+ }
+
+ @override
+ String daysAgo(int n) {
+ return '$n 天前';
+ }
+
+ @override
+ String monthDay(int month, int day) {
+ return '$month月$day日';
+ }
+
+ @override
+ String durationHours(int n) {
+ return '$n 小时';
+ }
+
+ @override
+ String durationDays(int n) {
+ return '$n 天';
+ }
+
+ @override
+ String get historyEmptySubtitle => '在任意一台设备上复制,内容会出现在这里';
+
+ @override
+ String historyCount(int count) {
+ return '共 $count 条';
+ }
+
+ @override
+ String historyCountKept(int count, String ttl) {
+ return '共 $count 条,保留 $ttl';
+ }
+
+ @override
+ String get filterAll => '全部';
+
+ @override
+ String get filterText => '文本';
+
+ @override
+ String get filterImage => '图片';
+
+ @override
+ String get filterFile => '文件';
+
+ @override
+ String get historyClearTooltip => '清空记录';
+
+ @override
+ String get historyEmptyTitle => '还没有记录';
+
+ @override
+ String get historyEmptyFilteredTitle => '没有这一类的记录';
+
+ @override
+ String get historyEmptyBody => '在任意一台已配对的设备上复制文本、图片或文件,记录会出现在这里。';
+
+ @override
+ String get clearConfirmTitle => '清空全部记录?';
+
+ @override
+ String clearConfirmBody(String device) {
+ return '所有设备上同步来的记录和已缓存的文件都会从$device上删除。原始文件不受影响。';
+ }
+
+ @override
+ String get clear => '清空';
+
+ @override
+ String get historyCleared => '记录已清空';
+
+ @override
+ String get permDeniedTitle => '已禁止 CopySync 读取剪贴板';
+
+ @override
+ String get permAskTitle => '允许 CopySync 读取剪贴板';
+
+ @override
+ String get permDeniedBody =>
+ '在这台 Mac 上复制的内容不会同步出去。到系统设置里把 CopySync Daemon 改为「允许」。';
+
+ @override
+ String get permAskBody => '否则 macOS 每次都会弹窗询问。到系统设置里把 CopySync Daemon 改为「允许」。';
+
+ @override
+ String get openSystemSettings => '打开系统设置';
+
+ @override
+ String get fetch => '拉取到本机';
+
+ @override
+ String get fetchStarted => '开始拉取';
+
+ @override
+ String get transferFailed => '传输失败';
+
+ @override
+ String get expired => '已过期';
+
+ @override
+ String get preview => '预览';
+
+ @override
+ String get putOnClipboard => '放入剪贴板';
+
+ @override
+ String get putOnClipboardDone => '已放入剪贴板';
+
+ @override
+ String get deleteRecord => '删除这条记录';
+
+ @override
+ String get deleted => '已删除';
+
+ @override
+ String get emptyRecord => '(空)';
+
+ @override
+ String get imageRecord => '图片';
+
+ @override
+ String itemsSummary(String name, int others, int count) {
+ return '$name 等 $count 项';
+ }
+
+ @override
+ String get imagePreviewTitle => '图片预览';
+
+ @override
+ String get closePreview => '关闭预览';
+
+ @override
+ String get previewHint => '滚轮或触控板缩放,拖动查看';
+
+ @override
+ String get fitWindow => '适应窗口';
+
+ @override
+ String get previewDeleted => '这条图片记录已被删除';
+
+ @override
+ String get previewExpired => '图片已过期,无法预览';
+
+ @override
+ String get previewDownloading => '正在下载图片…';
+
+ @override
+ String get previewDownloadFailed => '图片下载失败,请重试';
+
+ @override
+ String get previewNotDownloaded => '图片尚未下载到这台电脑';
+
+ @override
+ String get downloadAndPreview => '下载并预览';
+
+ @override
+ String get previewUnavailable => '图片暂时无法预览';
+
+ @override
+ String get imageSemantic => '复制记录中的图片';
+
+ @override
+ String get previewUnreadable => '无法读取图片,文件可能已被清理或损坏';
+
+ @override
+ String get devicesSubtitleEmpty => '配对之后,设备之间就会同步剪贴板';
+
+ @override
+ String devicesSubtitle(int paired, int online) {
+ return '已配对 $paired 台,$online 台在线';
+ }
+
+ @override
+ String get addDevice => '添加设备';
+
+ @override
+ String thisDeviceFootnote(String both) {
+ return '配对时,$both会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。';
+ }
+
+ @override
+ String get noDevicesTitle => '还没有配对的设备';
+
+ @override
+ String get noDevicesBody => '在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。';
+
+ @override
+ String get noDevicesNeedServer => '先在「设置」里连接信令服务器,才能配对设备。';
+
+ @override
+ String get pairedDevices => '已配对的设备';
+
+ @override
+ String get pairedFootnote =>
+ '直连:数据在两台设备之间直接传输。中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。';
+
+ @override
+ String get offline => '离线';
+
+ @override
+ String get direct => '直连';
+
+ @override
+ String get relay => '中转';
+
+ @override
+ String get online => '在线';
+
+ @override
+ String get moreActions => '更多操作';
+
+ @override
+ String get copyFingerprint => '拷贝安全指纹';
+
+ @override
+ String get unpairEllipsis => '解除配对…';
+
+ @override
+ String get fingerprintCopied => '安全指纹已拷贝';
+
+ @override
+ String unpairTitle(String name) {
+ return '解除与「$name」的配对?';
+ }
+
+ @override
+ String get unpairBody => '两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。';
+
+ @override
+ String get unpair => '解除配对';
+
+ @override
+ String get unpaired => '已解除配对';
+
+ @override
+ String get generateCode => '生成配对码';
+
+ @override
+ String get enterCode => '输入配对码';
+
+ @override
+ String get codeFailedTitle => '没能生成配对码';
+
+ @override
+ String get enterOnOther => '在另一台设备上输入这个配对码';
+
+ @override
+ String get codeCopied => '配对码已拷贝';
+
+ @override
+ String get codeHint => '点击可拷贝,5 分钟内有效';
+
+ @override
+ String afterEnterFootnote(String both) {
+ return '对方输入后,$both会显示同样的两行安全指纹,核对一致再确认。';
+ }
+
+ @override
+ String get codeInvalid => '配对码是 6 位字母或数字';
+
+ @override
+ String get enterCodeShown => '输入另一台设备上显示的配对码';
+
+ @override
+ String get pairingDone => '配对完成';
+
+ @override
+ String get pairingRejected => '已拒绝配对';
+
+ @override
+ String get verifyTitle => '核对安全指纹';
+
+ @override
+ String pairingWith(String name) {
+ return '正在与「$name」配对';
+ }
+
+ @override
+ String verifyBody(String both) {
+ return '$both上显示的这两行应当完全相同。有任何一个字符不同,说明连接可能被第三方篡改,请拒绝。';
+ }
+
+ @override
+ String get rejectMismatch => '不一致,拒绝';
+
+ @override
+ String get confirmMatch => '一致,确认配对';
+
+ @override
+ String get server => '服务器';
+
+ @override
+ String get serverFootnote => '服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。';
+
+ @override
+ String get signalingUrl => '信令服务器地址';
+
+ @override
+ String get signalingUrlDesc => '按回车保存,保存后立即重新连接';
+
+ @override
+ String get signalingUrlPlaceholder => 'ws://服务器地址:8787/signal';
+
+ @override
+ String get publicStun => '用公共服务器探测网络出口';
+
+ @override
+ String get publicStunDesc => '公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP';
+
+ @override
+ String get connectionStatus => '连接状态';
+
+ @override
+ String get connectedDesc => '已连接到信令服务器';
+
+ @override
+ String get disconnectedDesc => '连不上服务器。检查地址是否正确、服务器是否在运行。';
+
+ @override
+ String get connected => '已连接';
+
+ @override
+ String get notConnected => '未连接';
+
+ @override
+ String get deviceName => '设备名称';
+
+ @override
+ String get deviceNameDesc => '显示在其他设备的列表里';
+
+ @override
+ String get language => '语言';
+
+ @override
+ String get languageSystem => '跟随系统';
+
+ @override
+ String get sync => '同步';
+
+ @override
+ String get syncFootnote =>
+ '小于阈值的内容在复制时直接推送到其他设备;超过阈值的只同步一条记录,需要时在「复制记录」里点「拉取到本机」,避免大文件无谓地占用带宽和磁盘。';
+
+ @override
+ String get autoSyncLimit => '自动同步上限';
+
+ @override
+ String get autoSyncLimitDesc => '超过这个大小的文件改为手动拉取';
+
+ @override
+ String get autoApply => '收到后直接写入剪贴板';
+
+ @override
+ String get autoApplyDesc => '关闭后,需要在「复制记录」里手动放入剪贴板';
+
+ @override
+ String get whatToSync => '同步哪些内容';
+
+ @override
+ String get syncFiles => '文件与文件夹';
+
+ @override
+ String get syncText => '纯文本';
+
+ @override
+ String get syncRich => '带格式的文本';
+
+ @override
+ String get syncImages => '图片与截图';
+
+ @override
+ String get storage => '存储';
+
+ @override
+ String get storageFootnote => '到期的记录与缓存文件会被自动清理。';
+
+ @override
+ String get keepHistory => '记录保留';
+
+ @override
+ String get keepCache => '缓存文件保留';
+
+ @override
+ String get keepCacheDesc => '不会超过记录的保留时长';
+
+ @override
+ String get cacheUsage => '缓存占用';
+
+ @override
+ String get backgroundSync => '后台同步';
+
+ @override
+ String get backgroundFootnote =>
+ '停用后不再同步,也不会开机启动。历史记录与配对关系会保留,重新打开 App 即可再次启用。';
+
+ @override
+ String get backgroundService => '后台服务';
+
+ @override
+ String get backgroundServiceDesc => '随系统登录自动启动,关掉窗口也照常同步';
+
+ @override
+ String get restart => '重新启动';
+
+ @override
+ String get restarted => '后台服务已重新启动';
+
+ @override
+ String get disableEllipsis => '停用…';
+
+ @override
+ String get about => '关于';
+
+ @override
+ String get aboutDesc => '开源软件,MIT 许可';
+
+ @override
+ String get homepage => '项目主页';
+
+ @override
+ String get feedback => '反馈问题';
+
+ @override
+ String get disableTitle => '停用后台同步?';
+
+ @override
+ String disableBody(String device) {
+ return '$device将停止同步,也不再开机启动。历史记录和配对关系会保留。';
+ }
+
+ @override
+ String get disable => '停用';
+
+ @override
+ String get disabled => '后台同步已停用';
+
+ @override
+ String get urlMustBeWs => '地址需以 ws:// 或 wss:// 开头';
+
+ @override
+ String get serverUpdated => '服务器地址已更新,正在重连';
+
+ @override
+ String get deviceNameUpdated => '设备名称已更新';
+
+ @override
+ String get svcExtractTitle => '先解压或安装 CopySync';
+
+ @override
+ String get svcExtractBody =>
+ 'CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。';
+
+ @override
+ String get svcMoveTitle => '先把 CopySync 移到「应用程序」';
+
+ @override
+ String get svcMoveBody =>
+ 'CopySync 现在是直接从安装盘里打开的。把它拖进「应用程序」文件夹,推出安装盘,再从「应用程序」里打开,就可以启用后台同步。';
+
+ @override
+ String get svcStartTitle => '开始使用 CopySync';
+
+ @override
+ String get svcStartBody =>
+ 'CopySync 会在后台运行一个小进程,用来感知剪贴板的变化,并与你的其他设备保持连接。启用后它随系统登录自动启动,关掉这个窗口也会照常同步。';
+
+ @override
+ String get svcEnable => '启用后台同步';
+
+ @override
+ String get svcStaleTitle => '重新启用后台同步';
+
+ @override
+ String get svcStaleBodyWin =>
+ 'CopySync 换了位置,开机自启还指向原来的地方。重新启用一次,让后台进程指向当前这份 CopySync。历史记录与配对关系都会保留。';
+
+ @override
+ String get svcStaleBodyMac =>
+ 'CopySync 换了位置,或者之前用旧版安装脚本装过。重新启用一次,让后台进程指向当前这个 App。历史记录与配对关系都会保留。';
+
+ @override
+ String get svcReenable => '重新启用';
+
+ @override
+ String get svcStoppedTitle => '后台服务没有运行';
+
+ @override
+ String get svcStoppedBody => '它可能刚刚退出,系统通常会在几秒内把它重新拉起。如果一直停在这一页,点下面的按钮重新启动。';
+
+ @override
+ String get svcDevBodyWin =>
+ '这是开发构建,旁边没有 copysyncd.exe。在源码目录运行 scripts\\build-windows.ps1 构建完整的版本。';
+
+ @override
+ String get svcDevBodyMac =>
+ '这是开发构建,App 里没有内置后台服务。在源码目录运行 ./scripts/install-macos.sh 安装它。';
+
+ @override
+ String svcLogPath(String path) {
+ return '运行日志:$path';
+ }
+
+ @override
+ String get svcCanDisable => '随时可以在「设置」中停用后台同步。';
+}
diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arb
new file mode 100644
index 0000000..23d4cad
--- /dev/null
+++ b/ui/lib/l10n/app_zh.arb
@@ -0,0 +1,191 @@
+{
+ "@@locale": "zh",
+ "navHistory": "复制记录",
+ "navDevices": "设备",
+ "navSettings": "设置",
+ "linkConnecting": "正在连接…",
+ "linkServiceNotRunning": "后台服务未运行",
+ "linkNoServer": "未连接服务器",
+ "linkOnlinePeers": "{count} 台设备在线",
+ "linkServerConnected": "已连接服务器",
+ "linkConnectionLost": "连接中断:{detail}",
+ "linkServiceDisconnected": "后台服务已断开",
+ "linkServiceDisabled": "后台服务已停用",
+ "errServiceNotConnected": "后台服务未连接",
+ "errUnimplemented": "该功能尚未接入",
+ "errUnavailable": "无法连接后台服务",
+ "errServiceStart": "启动后台服务失败:{detail}",
+ "errServiceRestart": "重启后台服务失败:{detail}",
+ "errAutostart": "登记开机自启失败:{detail}",
+ "thisMacTitle": "这台 Mac",
+ "thisPcTitle": "这台电脑",
+ "thisMacInText": "这台 Mac ",
+ "thisPcInText": "这台电脑",
+ "bothMacs": "两台 Mac ",
+ "bothDevices": "两台设备",
+ "thisDeviceShort": "本机",
+ "fromDevice": "来自 {name}",
+ "cancel": "取消",
+ "close": "关闭",
+ "save": "保存",
+ "retry": "重试",
+ "continueAction": "继续",
+ "justNow": "刚刚",
+ "secondsAgo": "{n} 秒前",
+ "minutesAgo": "{n} 分钟前",
+ "hoursAgo": "{n} 小时前",
+ "daysAgo": "{n} 天前",
+ "monthDay": "{month}月{day}日",
+ "durationHours": "{n} 小时",
+ "durationDays": "{n} 天",
+ "historyEmptySubtitle": "在任意一台设备上复制,内容会出现在这里",
+ "historyCount": "共 {count} 条",
+ "historyCountKept": "共 {count} 条,保留 {ttl}",
+ "filterAll": "全部",
+ "filterText": "文本",
+ "filterImage": "图片",
+ "filterFile": "文件",
+ "historyClearTooltip": "清空记录",
+ "historyEmptyTitle": "还没有记录",
+ "historyEmptyFilteredTitle": "没有这一类的记录",
+ "historyEmptyBody": "在任意一台已配对的设备上复制文本、图片或文件,记录会出现在这里。",
+ "clearConfirmTitle": "清空全部记录?",
+ "clearConfirmBody": "所有设备上同步来的记录和已缓存的文件都会从{device}上删除。原始文件不受影响。",
+ "clear": "清空",
+ "historyCleared": "记录已清空",
+ "permDeniedTitle": "已禁止 CopySync 读取剪贴板",
+ "permAskTitle": "允许 CopySync 读取剪贴板",
+ "permDeniedBody": "在这台 Mac 上复制的内容不会同步出去。到系统设置里把 CopySync Daemon 改为「允许」。",
+ "permAskBody": "否则 macOS 每次都会弹窗询问。到系统设置里把 CopySync Daemon 改为「允许」。",
+ "openSystemSettings": "打开系统设置",
+ "fetch": "拉取到本机",
+ "fetchStarted": "开始拉取",
+ "transferFailed": "传输失败",
+ "expired": "已过期",
+ "preview": "预览",
+ "putOnClipboard": "放入剪贴板",
+ "putOnClipboardDone": "已放入剪贴板",
+ "deleteRecord": "删除这条记录",
+ "deleted": "已删除",
+ "emptyRecord": "(空)",
+ "imageRecord": "图片",
+ "itemsSummary": "{name} 等 {count} 项",
+ "imagePreviewTitle": "图片预览",
+ "closePreview": "关闭预览",
+ "previewHint": "滚轮或触控板缩放,拖动查看",
+ "fitWindow": "适应窗口",
+ "previewDeleted": "这条图片记录已被删除",
+ "previewExpired": "图片已过期,无法预览",
+ "previewDownloading": "正在下载图片…",
+ "previewDownloadFailed": "图片下载失败,请重试",
+ "previewNotDownloaded": "图片尚未下载到这台电脑",
+ "downloadAndPreview": "下载并预览",
+ "previewUnavailable": "图片暂时无法预览",
+ "imageSemantic": "复制记录中的图片",
+ "previewUnreadable": "无法读取图片,文件可能已被清理或损坏",
+ "devicesSubtitleEmpty": "配对之后,设备之间就会同步剪贴板",
+ "devicesSubtitle": "已配对 {paired} 台,{online} 台在线",
+ "addDevice": "添加设备",
+ "thisDeviceFootnote": "配对时,{both}会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。",
+ "noDevicesTitle": "还没有配对的设备",
+ "noDevicesBody": "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。",
+ "noDevicesNeedServer": "先在「设置」里连接信令服务器,才能配对设备。",
+ "pairedDevices": "已配对的设备",
+ "pairedFootnote": "直连:数据在两台设备之间直接传输。中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。",
+ "offline": "离线",
+ "direct": "直连",
+ "relay": "中转",
+ "online": "在线",
+ "moreActions": "更多操作",
+ "copyFingerprint": "拷贝安全指纹",
+ "unpairEllipsis": "解除配对…",
+ "fingerprintCopied": "安全指纹已拷贝",
+ "unpairTitle": "解除与「{name}」的配对?",
+ "unpairBody": "两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。",
+ "unpair": "解除配对",
+ "unpaired": "已解除配对",
+ "generateCode": "生成配对码",
+ "enterCode": "输入配对码",
+ "codeFailedTitle": "没能生成配对码",
+ "enterOnOther": "在另一台设备上输入这个配对码",
+ "codeCopied": "配对码已拷贝",
+ "codeHint": "点击可拷贝,5 分钟内有效",
+ "afterEnterFootnote": "对方输入后,{both}会显示同样的两行安全指纹,核对一致再确认。",
+ "codeInvalid": "配对码是 6 位字母或数字",
+ "enterCodeShown": "输入另一台设备上显示的配对码",
+ "pairingDone": "配对完成",
+ "pairingRejected": "已拒绝配对",
+ "verifyTitle": "核对安全指纹",
+ "pairingWith": "正在与「{name}」配对",
+ "verifyBody": "{both}上显示的这两行应当完全相同。有任何一个字符不同,说明连接可能被第三方篡改,请拒绝。",
+ "rejectMismatch": "不一致,拒绝",
+ "confirmMatch": "一致,确认配对",
+ "server": "服务器",
+ "serverFootnote": "服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。",
+ "signalingUrl": "信令服务器地址",
+ "signalingUrlDesc": "按回车保存,保存后立即重新连接",
+ "signalingUrlPlaceholder": "ws://服务器地址:8787/signal",
+ "publicStun": "用公共服务器探测网络出口",
+ "publicStunDesc": "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP",
+ "connectionStatus": "连接状态",
+ "connectedDesc": "已连接到信令服务器",
+ "disconnectedDesc": "连不上服务器。检查地址是否正确、服务器是否在运行。",
+ "connected": "已连接",
+ "notConnected": "未连接",
+ "deviceName": "设备名称",
+ "deviceNameDesc": "显示在其他设备的列表里",
+ "language": "语言",
+ "languageSystem": "跟随系统",
+ "sync": "同步",
+ "syncFootnote": "小于阈值的内容在复制时直接推送到其他设备;超过阈值的只同步一条记录,需要时在「复制记录」里点「拉取到本机」,避免大文件无谓地占用带宽和磁盘。",
+ "autoSyncLimit": "自动同步上限",
+ "autoSyncLimitDesc": "超过这个大小的文件改为手动拉取",
+ "autoApply": "收到后直接写入剪贴板",
+ "autoApplyDesc": "关闭后,需要在「复制记录」里手动放入剪贴板",
+ "whatToSync": "同步哪些内容",
+ "syncFiles": "文件与文件夹",
+ "syncText": "纯文本",
+ "syncRich": "带格式的文本",
+ "syncImages": "图片与截图",
+ "storage": "存储",
+ "storageFootnote": "到期的记录与缓存文件会被自动清理。",
+ "keepHistory": "记录保留",
+ "keepCache": "缓存文件保留",
+ "keepCacheDesc": "不会超过记录的保留时长",
+ "cacheUsage": "缓存占用",
+ "backgroundSync": "后台同步",
+ "backgroundFootnote": "停用后不再同步,也不会开机启动。历史记录与配对关系会保留,重新打开 App 即可再次启用。",
+ "backgroundService": "后台服务",
+ "backgroundServiceDesc": "随系统登录自动启动,关掉窗口也照常同步",
+ "restart": "重新启动",
+ "restarted": "后台服务已重新启动",
+ "disableEllipsis": "停用…",
+ "about": "关于",
+ "aboutDesc": "开源软件,MIT 许可",
+ "homepage": "项目主页",
+ "feedback": "反馈问题",
+ "disableTitle": "停用后台同步?",
+ "disableBody": "{device}将停止同步,也不再开机启动。历史记录和配对关系会保留。",
+ "disable": "停用",
+ "disabled": "后台同步已停用",
+ "urlMustBeWs": "地址需以 ws:// 或 wss:// 开头",
+ "serverUpdated": "服务器地址已更新,正在重连",
+ "deviceNameUpdated": "设备名称已更新",
+ "svcExtractTitle": "先解压或安装 CopySync",
+ "svcExtractBody": "CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。",
+ "svcMoveTitle": "先把 CopySync 移到「应用程序」",
+ "svcMoveBody": "CopySync 现在是直接从安装盘里打开的。把它拖进「应用程序」文件夹,推出安装盘,再从「应用程序」里打开,就可以启用后台同步。",
+ "svcStartTitle": "开始使用 CopySync",
+ "svcStartBody": "CopySync 会在后台运行一个小进程,用来感知剪贴板的变化,并与你的其他设备保持连接。启用后它随系统登录自动启动,关掉这个窗口也会照常同步。",
+ "svcEnable": "启用后台同步",
+ "svcStaleTitle": "重新启用后台同步",
+ "svcStaleBodyWin": "CopySync 换了位置,开机自启还指向原来的地方。重新启用一次,让后台进程指向当前这份 CopySync。历史记录与配对关系都会保留。",
+ "svcStaleBodyMac": "CopySync 换了位置,或者之前用旧版安装脚本装过。重新启用一次,让后台进程指向当前这个 App。历史记录与配对关系都会保留。",
+ "svcReenable": "重新启用",
+ "svcStoppedTitle": "后台服务没有运行",
+ "svcStoppedBody": "它可能刚刚退出,系统通常会在几秒内把它重新拉起。如果一直停在这一页,点下面的按钮重新启动。",
+ "svcDevBodyWin": "这是开发构建,旁边没有 copysyncd.exe。在源码目录运行 scripts\\build-windows.ps1 构建完整的版本。",
+ "svcDevBodyMac": "这是开发构建,App 里没有内置后台服务。在源码目录运行 ./scripts/install-macos.sh 安装它。",
+ "svcLogPath": "运行日志:{path}",
+ "svcCanDisable": "随时可以在「设置」中停用后台同步。"
+}
diff --git a/ui/lib/main.dart b/ui/lib/main.dart
index c936fc9..f8c3cca 100644
--- a/ui/lib/main.dart
+++ b/ui/lib/main.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'app_state.dart';
import 'background_service.dart';
+import 'i18n.dart';
import 'pages/devices_page.dart';
import 'pages/history_page.dart';
import 'pages/service_page.dart';
@@ -27,6 +28,8 @@ class CopySyncApp extends StatefulWidget {
class _CopySyncAppState extends State<CopySyncApp> {
late final AppState _state;
+ final _light = buildTheme(Brightness.light);
+ final _dark = buildTheme(Brightness.dark);
@override
void initState() {
@@ -46,12 +49,24 @@ class _CopySyncAppState extends State<CopySyncApp> {
// 与 home 是兄弟而非后代,放在 home 里的话对话框里就取不到 AppState。
return AppScope(
state: _state,
- child: MaterialApp(
- title: 'CopySync',
- debugShowCheckedModeBanner: false,
- theme: buildTheme(Brightness.light),
- darkTheme: buildTheme(Brightness.dark),
- home: const Shell(),
+ // 语言设置存在后台服务的配置里,配置变了要重建 MaterialApp 才会换语言
+ child: ListenableBuilder(
+ listenable: _state,
+ builder: (context, _) => MaterialApp(
+ title: 'CopySync',
+ debugShowCheckedModeBanner: false,
+ theme: _light,
+ darkTheme: _dark,
+ locale: localeFromSetting(_state.config?.language ?? ''),
+ supportedLocales: supportedLocales,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
+ localeListResolutionCallback: (preferred, _) => resolveLocale(preferred),
+ builder: (context, child) {
+ appL10n = context.l10n;
+ return child!;
+ },
+ home: const Shell(),
+ ),
),
);
}
@@ -143,6 +158,7 @@ class _Sidebar extends StatelessWidget {
Widget build(BuildContext context) {
final state = AppScope.of(context);
final p = context.palette;
+ final l = context.l10n;
return Container(
width: 200,
@@ -168,20 +184,20 @@ class _Sidebar extends StatelessWidget {
),
_NavItem(
icon: AppIcons.clock,
- label: '复制记录',
+ label: l.navHistory,
selected: current == Section.history,
trailing: state.records.isEmpty ? null : '${state.records.length}',
onTap: () => onSelect(Section.history),
),
_NavItem(
icon: AppIcons.deviceLaptop,
- label: '设备',
+ label: l.navDevices,
selected: current == Section.devices,
onTap: () => onSelect(Section.devices),
),
_NavItem(
icon: AppIcons.gear,
- label: '设置',
+ label: l.navSettings,
selected: current == Section.settings,
onTap: () => onSelect(Section.settings),
),
@@ -268,13 +284,14 @@ class _ConnectionFooter extends StatelessWidget {
final p = context.palette;
final signaling = state.status?.signalingConnected ?? false;
final online = state.onlinePeerCount;
+ final l = context.l10n;
final (color, label) = switch (state.link) {
- LinkState.connecting => (p.textFaint, '正在连接…'),
- LinkState.offline => (p.danger, state.error ?? '后台服务未运行'),
- LinkState.online when !signaling => (p.warning, '未连接服务器'),
- LinkState.online when online > 0 => (p.online, '$online 台设备在线'),
- LinkState.online => (p.online, '已连接服务器'),
+ LinkState.connecting => (p.textFaint, l.linkConnecting),
+ LinkState.offline => (p.danger, state.error ?? l.linkServiceNotRunning),
+ LinkState.online when !signaling => (p.warning, l.linkNoServer),
+ LinkState.online when online > 0 => (p.online, l.linkOnlinePeers(online)),
+ LinkState.online => (p.online, l.linkServerConnected),
};
return Container(
diff --git a/ui/lib/pages/devices_page.dart b/ui/lib/pages/devices_page.dart
index 271fdee..f1e94c8 100644
--- a/ui/lib/pages/devices_page.dart
+++ b/ui/lib/pages/devices_page.dart
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
+import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
@@ -17,20 +18,21 @@ class DevicesPage extends StatelessWidget {
Widget build(BuildContext context) {
final state = AppScope.of(context);
final canPair = state.isOnline && (state.status?.signalingConnected ?? false);
+ final l = context.l10n;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PageHeader(
- title: '设备',
+ title: l.navDevices,
subtitle: state.peers.isEmpty
- ? '配对之后,设备之间就会同步剪贴板'
- : '已配对 ${state.peers.length} 台,${state.onlinePeerCount} 台在线',
+ ? l.devicesSubtitleEmpty
+ : l.devicesSubtitle(state.peers.length, state.onlinePeerCount),
actions: [
FilledButton.icon(
onPressed: canPair ? () => _startPairing(context) : null,
icon: Icon(AppIcons.plus, size: 14),
- label: const Text('添加设备'),
+ label: Text(l.addDevice),
),
],
),
@@ -41,7 +43,7 @@ class DevicesPage extends StatelessWidget {
if (state.self != null)
GroupSection(
title: Wording.thisDevice,
- footnote: '配对时,${Wording.bothDevicesInText}会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。',
+ footnote: l.thisDeviceFootnote(Wording.bothDevicesInText),
child: GroupBox(children: [_DeviceRow(device: state.self!, isSelf: true)]),
),
if (state.peers.isEmpty)
@@ -49,23 +51,20 @@ class DevicesPage extends StatelessWidget {
padding: const EdgeInsets.only(top: Insets.xl),
child: EmptyState(
icon: AppIcons.deviceLaptop,
- title: '还没有配对的设备',
- description: canPair
- ? '在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。'
- : '先在「设置」里连接信令服务器,才能配对设备。',
+ title: l.noDevicesTitle,
+ description: canPair ? l.noDevicesBody : l.noDevicesNeedServer,
action: canPair
? FilledButton(
onPressed: () => _startPairing(context),
- child: const Text('添加设备'),
+ child: Text(l.addDevice),
)
: null,
),
)
else
GroupSection(
- title: '已配对的设备',
- footnote: '直连:数据在两台设备之间直接传输。'
- '中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。',
+ title: l.pairedDevices,
+ footnote: l.pairedFootnote,
child: GroupBox(
dividerIndent: 52,
children: [for (final d in state.peers) _DeviceRow(device: d)],
@@ -113,12 +112,12 @@ class _DeviceRow extends StatelessWidget {
if (isSelf)
Padding(
padding: const EdgeInsets.only(right: Insets.sm),
- child: Text('本机', style: context.text.bodySmall),
+ child: Text(context.l10n.thisDeviceShort, style: context.text.bodySmall),
)
else ...[
StatusDot(
color: device.online ? p.online : p.textFaint,
- label: device.online ? connectionLabel(device) : '离线',
+ label: device.online ? connectionLabel(device) : context.l10n.offline,
),
const SizedBox(width: Insets.sm),
_DeviceMenu(device: device),
@@ -130,9 +129,9 @@ class _DeviceRow extends StatelessWidget {
}
String connectionLabel(Device d) => switch (d.connection) {
- ConnectionKind.CONNECTION_KIND_DIRECT => '直连',
- ConnectionKind.CONNECTION_KIND_RELAY => '中转',
- _ => '在线',
+ ConnectionKind.CONNECTION_KIND_DIRECT => appL10n.direct,
+ ConnectionKind.CONNECTION_KIND_RELAY => appL10n.relay,
+ _ => appL10n.online,
};
IconData platformIcon(String platform) => switch (platform) {
@@ -147,16 +146,17 @@ class _DeviceMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
+ final l = context.l10n;
return PopupMenuButton<String>(
- tooltip: '更多操作',
+ tooltip: l.moreActions,
padding: EdgeInsets.zero,
position: PopupMenuPosition.under,
itemBuilder: (ctx) => [
- const PopupMenuItem(value: 'copy', height: 34, child: Text('拷贝安全指纹')),
+ PopupMenuItem(value: 'copy', height: 34, child: Text(l.copyFingerprint)),
PopupMenuItem(
value: 'unpair',
height: 34,
- child: Text('解除配对…', style: TextStyle(color: ctx.palette.danger)),
+ child: Text(l.unpairEllipsis, style: TextStyle(color: ctx.palette.danger)),
),
],
onSelected: (v) => v == 'copy' ? _copy(context) : _unpair(context),
@@ -168,22 +168,23 @@ class _DeviceMenu extends StatelessWidget {
Future<void> _copy(BuildContext context) async {
await Clipboard.setData(ClipboardData(text: device.publicKeyFingerprint));
- if (context.mounted) showToast(context, '安全指纹已拷贝');
+ if (context.mounted) showToast(context, context.l10n.fingerprintCopied);
}
Future<void> _unpair(BuildContext context) async {
final state = AppScope.read(context);
+ final l = context.l10n;
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
- title: Text('解除与「${device.name}」的配对?'),
- content: const Text('两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。'),
+ title: Text(l.unpairTitle(device.name)),
+ content: Text(l.unpairBody),
actions: [
- OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
+ OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),
FilledButton(
onPressed: () => Navigator.pop(ctx, true),
style: FilledButton.styleFrom(backgroundColor: ctx.palette.danger),
- child: const Text('解除配对'),
+ child: Text(l.unpair),
),
],
),
@@ -191,7 +192,7 @@ class _DeviceMenu extends StatelessWidget {
if (ok != true) return;
try {
await state.unpair(device.id);
- if (context.mounted) showToast(context, '已解除配对');
+ if (context.mounted) showToast(context, l.unpaired);
} catch (e) {
if (context.mounted) showToast(context, AppState.describeError(e), error: true);
}
diff --git a/ui/lib/pages/history_page.dart b/ui/lib/pages/history_page.dart
index eed6978..ff67d04 100644
--- a/ui/lib/pages/history_page.dart
+++ b/ui/lib/pages/history_page.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
+import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
@@ -35,30 +36,34 @@ class _HistoryPageState extends State<HistoryPage> {
final state = AppScope.of(context);
final records = state.records.where(_matches).toList();
final ttl = state.config?.historyTtlSeconds.toInt();
+ final l = context.l10n;
+ final count = state.records.length;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
PageHeader(
- title: '复制记录',
+ title: l.navHistory,
subtitle: state.records.isEmpty
- ? '在任意一台设备上复制,内容会出现在这里'
- : '共 ${state.records.length} 条${ttl == null ? '' : ',保留 ${_ttlLabel(ttl)}'}',
+ ? l.historyEmptySubtitle
+ : ttl == null
+ ? l.historyCount(count)
+ : l.historyCountKept(count, durationLabel(l, ttl)),
actions: [
if (state.records.isNotEmpty) ...[
Segmented<_Filter>(
value: _filter,
- segments: const [
- (_Filter.all, '全部'),
- (_Filter.text, '文本'),
- (_Filter.image, '图片'),
- (_Filter.file, '文件'),
+ segments: [
+ (_Filter.all, l.filterAll),
+ (_Filter.text, l.filterText),
+ (_Filter.image, l.filterImage),
+ (_Filter.file, l.filterFile),
],
onChanged: (f) => setState(() => _filter = f),
),
IconAction(
icon: AppIcons.trash,
- tooltip: '清空记录',
+ tooltip: l.historyClearTooltip,
onTap: () => _confirmClear(context, state),
),
],
@@ -75,9 +80,9 @@ class _HistoryPageState extends State<HistoryPage> {
icon: _filter == _Filter.all
? AppIcons.docOnClipboard
: AppIcons.filter,
- title: _filter == _Filter.all ? '还没有记录' : '没有这一类的记录',
+ title: _filter == _Filter.all ? l.historyEmptyTitle : l.historyEmptyFilteredTitle,
description: _filter == _Filter.all
- ? '在任意一台已配对的设备上复制文本、图片或文件,记录会出现在这里。'
+ ? l.historyEmptyBody
: null,
)
: CustomScrollView(
@@ -112,21 +117,19 @@ class _HistoryPageState extends State<HistoryPage> {
p == ClipboardPermission.CLIPBOARD_PERMISSION_ASK ||
p == ClipboardPermission.CLIPBOARD_PERMISSION_ALWAYS_DENY;
- static String _ttlLabel(int seconds) =>
- seconds % 86400 == 0 ? '${seconds ~/ 86400} 天' : '${(seconds / 3600).round()} 小时';
-
Future<void> _confirmClear(BuildContext context, AppState state) async {
+ final l = context.l10n;
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
- title: const Text('清空全部记录?'),
- content: Text('所有设备上同步来的记录和已缓存的文件都会从${Wording.thisDeviceInText}上删除。原始文件不受影响。'),
+ title: Text(l.clearConfirmTitle),
+ content: Text(l.clearConfirmBody(Wording.thisDeviceInText)),
actions: [
- OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
+ OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),
FilledButton(
onPressed: () => Navigator.pop(ctx, true),
style: FilledButton.styleFrom(backgroundColor: ctx.palette.danger),
- child: const Text('清空'),
+ child: Text(l.clear),
),
],
),
@@ -134,7 +137,7 @@ class _HistoryPageState extends State<HistoryPage> {
if (ok != true || !context.mounted) return;
try {
await state.deleteRecords(all: true);
- if (context.mounted) showToast(context, '记录已清空');
+ if (context.mounted) showToast(context, l.historyCleared);
} catch (e) {
if (context.mounted) showToast(context, AppState.describeError(e), error: true);
}
@@ -150,11 +153,10 @@ class _PermissionNotice extends StatelessWidget {
@override
Widget build(BuildContext context) {
final denied = permission == ClipboardPermission.CLIPBOARD_PERMISSION_ALWAYS_DENY;
+ final l = context.l10n;
return Notice(
- title: denied ? '已禁止 CopySync 读取剪贴板' : '允许 CopySync 读取剪贴板',
- message: denied
- ? '在这台 Mac 上复制的内容不会同步出去。到系统设置里把 CopySync Daemon 改为「允许」。'
- : '否则 macOS 每次都会弹窗询问。到系统设置里把 CopySync Daemon 改为「允许」。',
+ title: denied ? l.permDeniedTitle : l.permAskTitle,
+ message: denied ? l.permDeniedBody : l.permAskBody,
action: OutlinedButton(
onPressed: () async {
try {
@@ -163,7 +165,7 @@ class _PermissionNotice extends StatelessWidget {
if (context.mounted) showToast(context, AppState.describeError(e), error: true);
}
},
- child: const Text('打开系统设置'),
+ child: Text(l.openSystemSettings),
),
);
}
@@ -219,7 +221,7 @@ class _RecordRowState extends State<_RecordRow> {
const SizedBox(height: 2),
Text(
[
- r.outgoing ? '本机' : '来自 ${r.originDeviceName}',
+ r.outgoing ? context.l10n.thisDeviceShort : context.l10n.fromDevice(r.originDeviceName),
if (r.totalSize > 0) humanBytes(r.totalSize.toInt()),
relativeTime(DateTime.fromMillisecondsSinceEpoch(r.createdAtUnix.toInt() * 1000)),
].join(' · '),
@@ -241,6 +243,7 @@ class _RecordRowState extends State<_RecordRow> {
Widget _trailing(BuildContext context, ClipRecord r) {
final p = context.palette;
+ final l = context.l10n;
if (_busy) {
return const SizedBox(
width: 16,
@@ -252,8 +255,8 @@ class _RecordRowState extends State<_RecordRow> {
case ClipStatus.CLIP_STATUS_REMOTE_ONLY:
// 超过自动同步阈值的大文件:只有元数据,需要时再拉
return OutlinedButton(
- onPressed: () => _run(() => AppScope.read(context).fetch(r.id), '开始拉取'),
- child: const Text('拉取到本机'),
+ onPressed: () => _run(() => AppScope.read(context).fetch(r.id), l.fetchStarted),
+ child: Text(l.fetch),
);
case ClipStatus.CLIP_STATUS_FETCHING:
// 知道总量时显示真实进度,否则显示不确定进度
@@ -266,11 +269,11 @@ class _RecordRowState extends State<_RecordRow> {
);
case ClipStatus.CLIP_STATUS_FAILED:
return Tooltip(
- message: r.error.isEmpty ? '传输失败' : r.error,
- child: Text('传输失败', style: context.text.bodySmall?.copyWith(color: p.danger)),
+ message: r.error.isEmpty ? l.transferFailed : r.error,
+ child: Text(l.transferFailed, style: context.text.bodySmall?.copyWith(color: p.danger)),
);
case ClipStatus.CLIP_STATUS_EXPIRED:
- return Text('已过期', style: context.text.bodySmall?.copyWith(color: p.textFaint));
+ return Text(l.expired, style: context.text.bodySmall?.copyWith(color: p.textFaint));
default:
// 悬停时才显示「放入剪贴板」与删除,静态时列表保持干净。
// 不悬停时它们只是看不见,位置照样留着:鼠标移上来时「预览」不会被挤开,不容易点错
@@ -285,16 +288,16 @@ class _RecordRowState extends State<_RecordRow> {
mainAxisSize: MainAxisSize.min,
children: [
if (r.kind == ClipKind.CLIP_KIND_IMAGE)
- TextButton(onPressed: () => _preview(r), child: const Text('预览')),
+ TextButton(onPressed: () => _preview(r), child: Text(l.preview)),
hoverOnly(TextButton(
onPressed: () =>
- _run(() => AppScope.read(context).applyToClipboard(r.id), '已放入剪贴板'),
- child: const Text('放入剪贴板'),
+ _run(() => AppScope.read(context).applyToClipboard(r.id), l.putOnClipboardDone),
+ child: Text(l.putOnClipboard),
)),
hoverOnly(IconAction(
icon: AppIcons.trash,
- tooltip: '删除这条记录',
- onTap: () => _run(() => AppScope.read(context).deleteRecords(ids: [r.id]), '已删除'),
+ tooltip: l.deleteRecord,
+ onTap: () => _run(() => AppScope.read(context).deleteRecords(ids: [r.id]), l.deleted),
)),
],
);
@@ -329,8 +332,12 @@ IconData kindIcon(ClipRecord r) => switch (r.kind) {
};
String recordTitle(ClipRecord r) {
- if (r.textPreview.isNotEmpty) return r.textPreview.replaceAll('\n', ' ').trim();
- if (r.items.isEmpty) return '(空)';
+ // 图片和文件的标题按当前界面语言拼:后台服务存下的摘要是写入时的中文,不会跟着换语言
+ if (r.kind == ClipKind.CLIP_KIND_IMAGE) return appL10n.imageRecord;
+ if (r.kind != ClipKind.CLIP_KIND_FILE && r.textPreview.isNotEmpty) {
+ return r.textPreview.replaceAll('\n', ' ').trim();
+ }
+ if (r.items.isEmpty) return appL10n.emptyRecord;
if (r.items.length == 1) return r.items.first.name;
- return '${r.items.first.name} 等 ${r.items.length} 项';
+ return appL10n.itemsSummary(r.items.first.name, r.items.length - 1, r.items.length);
}
diff --git a/ui/lib/pages/service_page.dart b/ui/lib/pages/service_page.dart
index 6123fd7..d2af325 100644
--- a/ui/lib/pages/service_page.dart
+++ b/ui/lib/pages/service_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../app_state.dart';
import '../background_service.dart';
+import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
@@ -41,49 +42,18 @@ class _ServicePageState extends State<ServicePage> {
Widget build(BuildContext context) {
final state = AppScope.of(context);
final windows = Platform.isWindows;
+ final l = context.l10n;
final (title, body, button) = switch (state.serviceState) {
- ServiceState.mustMove when windows => (
- '先解压或安装 CopySync',
- 'CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。'
- '运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。',
- null,
- ),
- ServiceState.mustMove => (
- '先把 CopySync 移到「应用程序」',
- 'CopySync 现在是直接从安装盘里打开的。把它拖进「应用程序」文件夹,'
- '推出安装盘,再从「应用程序」里打开,就可以启用后台同步。',
- null,
- ),
- ServiceState.notInstalled => (
- '开始使用 CopySync',
- 'CopySync 会在后台运行一个小进程,用来感知剪贴板的变化,并与你的其他设备保持连接。'
- '启用后它随系统登录自动启动,关掉这个窗口也会照常同步。',
- '启用后台同步',
- ),
+ ServiceState.mustMove when windows => (l.svcExtractTitle, l.svcExtractBody, null),
+ ServiceState.mustMove => (l.svcMoveTitle, l.svcMoveBody, null),
+ ServiceState.notInstalled => (l.svcStartTitle, l.svcStartBody, l.svcEnable),
ServiceState.stale => (
- '重新启用后台同步',
- windows
- ? 'CopySync 换了位置,开机自启还指向原来的地方。重新启用一次,'
- '让后台进程指向当前这份 CopySync。历史记录与配对关系都会保留。'
- : 'CopySync 换了位置,或者之前用旧版安装脚本装过。重新启用一次,'
- '让后台进程指向当前这个 App。历史记录与配对关系都会保留。',
- '重新启用',
- ),
- ServiceState.stopped => (
- '后台服务没有运行',
- '它可能刚刚退出,系统通常会在几秒内把它重新拉起。'
- '如果一直停在这一页,点下面的按钮重新启动。',
- '重新启动',
- ),
- _ => (
- '后台服务没有运行',
- windows
- ? '这是开发构建,旁边没有 copysyncd.exe。'
- '在源码目录运行 scripts\\build-windows.ps1 构建完整的版本。'
- : '这是开发构建,App 里没有内置后台服务。'
- '在源码目录运行 ./scripts/install-macos.sh 安装它。',
- null,
+ l.svcStaleTitle,
+ windows ? l.svcStaleBodyWin : l.svcStaleBodyMac,
+ l.svcReenable,
),
+ ServiceState.stopped => (l.svcStoppedTitle, l.svcStoppedBody, l.restart),
+ _ => (l.svcStoppedTitle, windows ? l.svcDevBodyWin : l.svcDevBodyMac, null),
};
return Center(
@@ -118,8 +88,8 @@ class _ServicePageState extends State<ServicePage> {
const SizedBox(height: Insets.xl),
Text(
state.serviceState == ServiceState.stopped
- ? '运行日志:${state.service.displayLogPath}'
- : '随时可以在「设置」中停用后台同步。',
+ ? l.svcLogPath(state.service.displayLogPath)
+ : l.svcCanDisable,
style: context.text.bodySmall,
),
],
diff --git a/ui/lib/pages/settings_page.dart b/ui/lib/pages/settings_page.dart
index 0c13212..77b9b1a 100644
--- a/ui/lib/pages/settings_page.dart
+++ b/ui/lib/pages/settings_page.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
+import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import '../widgets/common.dart';
@@ -56,33 +57,34 @@ class _SettingsPageState extends State<SettingsPage> {
_syncControllers(cfg);
final p = context.palette;
+ final l = context.l10n;
final connected = state.status?.signalingConnected == true;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- const PageHeader(title: '设置'),
+ PageHeader(title: l.navSettings),
Expanded(
child: ListView(
padding: const EdgeInsets.fromLTRB(Insets.xl, 0, Insets.xl, Insets.xxl),
children: [
GroupSection(
- title: '服务器',
- footnote: '服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。',
+ title: l.server,
+ footnote: l.serverFootnote,
child: GroupBox(children: [
SettingRow(
- title: '信令服务器地址',
- description: '按回车保存,保存后立即重新连接',
+ title: l.signalingUrl,
+ description: l.signalingUrlDesc,
child: SizedBox(
width: 290,
child: TextField(
controller: _serverController,
style: context.text.bodyMedium?.copyWith(fontFamily: monoFamily, fontSize: 12),
decoration: InputDecoration(
- hintText: 'ws://服务器地址:8787/signal',
+ hintText: l.signalingUrlPlaceholder,
suffixIcon: _serverDirty
? IconButton(
- tooltip: '保存',
+ tooltip: l.save,
icon: Icon(AppIcons.checkmark, size: 14, color: p.accent),
onPressed: () => _saveServer(state, cfg),
)
@@ -94,19 +96,19 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
SettingRow(
- title: '用公共服务器探测网络出口',
- description: '公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP',
+ title: l.publicStun,
+ description: l.publicStunDesc,
child: SmallSwitch(
value: !cfg.onlyOwnStun,
onChanged: (v) => _update(state, cfg..onlyOwnStun = !v),
),
),
SettingRow(
- title: '连接状态',
- description: connected ? '已连接到信令服务器' : '连不上服务器。检查地址是否正确、服务器是否在运行。',
+ title: l.connectionStatus,
+ description: connected ? l.connectedDesc : l.disconnectedDesc,
child: StatusDot(
color: connected ? p.online : p.danger,
- label: connected ? '已连接' : '未连接',
+ label: connected ? l.connected : l.notConnected,
),
),
]),
@@ -115,8 +117,8 @@ class _SettingsPageState extends State<SettingsPage> {
title: Wording.thisDevice,
child: GroupBox(children: [
SettingRow(
- title: '设备名称',
- description: '显示在其他设备的列表里',
+ title: l.deviceName,
+ description: l.deviceNameDesc,
child: SizedBox(
width: 220,
child: TextField(
@@ -124,7 +126,7 @@ class _SettingsPageState extends State<SettingsPage> {
decoration: InputDecoration(
suffixIcon: _nameDirty
? IconButton(
- tooltip: '保存',
+ tooltip: l.save,
icon: Icon(AppIcons.checkmark, size: 14, color: p.accent),
onPressed: () => _saveName(state, cfg),
)
@@ -135,24 +137,37 @@ class _SettingsPageState extends State<SettingsPage> {
),
),
),
+ SettingRow(
+ title: l.language,
+ child: _Dropdown<String>(
+ value: cfg.language,
+ // 语言名用各自的写法,选错了语言的人也认得出自己的
+ items: [
+ MapEntry('', l.languageSystem),
+ const MapEntry('zh-Hans', '简体中文'),
+ const MapEntry('en', 'English'),
+ const MapEntry('ja', '日本語'),
+ ],
+ onChanged: (v) => _update(state, cfg..language = v),
+ ),
+ ),
]),
),
GroupSection(
- title: '同步',
- footnote: '小于阈值的内容在复制时直接推送到其他设备;超过阈值的只同步一条记录,'
- '需要时在「复制记录」里点「拉取到本机」,避免大文件无谓地占用带宽和磁盘。',
+ title: l.sync,
+ footnote: l.syncFootnote,
child: GroupBox(children: [
SettingRow(
- title: '自动同步上限',
- description: '超过这个大小的文件改为手动拉取',
+ title: l.autoSyncLimit,
+ description: l.autoSyncLimitDesc,
child: _ThresholdSelector(
value: cfg.autoSyncThresholdBytes.toInt(),
onChanged: (v) => _update(state, cfg..autoSyncThresholdBytes = Int64(v)),
),
),
SettingRow(
- title: '收到后直接写入剪贴板',
- description: '关闭后,需要在「复制记录」里手动放入剪贴板',
+ title: l.autoApply,
+ description: l.autoApplyDesc,
child: SmallSwitch(
value: cfg.autoApplyToClipboard,
onChanged: (v) => _update(state, cfg..autoApplyToClipboard = v),
@@ -161,51 +176,51 @@ class _SettingsPageState extends State<SettingsPage> {
]),
),
GroupSection(
- title: '同步哪些内容',
+ title: l.whatToSync,
child: GroupBox(children: [
_ToggleRow(
- title: '文件与文件夹',
+ title: l.syncFiles,
value: cfg.syncFile,
onChanged: (v) => _update(state, cfg..syncFile = v),
),
_ToggleRow(
- title: '纯文本',
+ title: l.syncText,
value: cfg.syncText,
onChanged: (v) => _update(state, cfg..syncText = v),
),
_ToggleRow(
- title: '带格式的文本',
+ title: l.syncRich,
value: cfg.syncHtml,
onChanged: (v) => _update(state, cfg..syncHtml = v),
),
_ToggleRow(
- title: '图片与截图',
+ title: l.syncImages,
value: cfg.syncImage,
onChanged: (v) => _update(state, cfg..syncImage = v),
),
]),
),
GroupSection(
- title: '存储',
- footnote: '到期的记录与缓存文件会被自动清理。',
+ title: l.storage,
+ footnote: l.storageFootnote,
child: GroupBox(children: [
SettingRow(
- title: '记录保留',
+ title: l.keepHistory,
child: _DurationSelector(
seconds: cfg.historyTtlSeconds.toInt(),
onChanged: (v) => _update(state, cfg..historyTtlSeconds = Int64(v)),
),
),
SettingRow(
- title: '缓存文件保留',
- description: '不会超过记录的保留时长',
+ title: l.keepCache,
+ description: l.keepCacheDesc,
child: _DurationSelector(
seconds: cfg.cacheTtlSeconds.toInt(),
onChanged: (v) => _update(state, cfg..cacheTtlSeconds = Int64(v)),
),
),
SettingRow(
- title: '缓存占用',
+ title: l.cacheUsage,
child: Text(
humanBytes(state.status?.cacheBytesUsed.toInt() ?? 0),
style: context.text.bodyMedium?.copyWith(color: p.textDim),
@@ -215,23 +230,23 @@ class _SettingsPageState extends State<SettingsPage> {
),
if (state.service.available)
GroupSection(
- title: '后台同步',
- footnote: '停用后不再同步,也不会开机启动。历史记录与配对关系会保留,重新打开 App 即可再次启用。',
+ title: l.backgroundSync,
+ footnote: l.backgroundFootnote,
child: GroupBox(children: [
SettingRow(
- title: '后台服务',
- description: '随系统登录自动启动,关掉窗口也照常同步',
+ title: l.backgroundService,
+ description: l.backgroundServiceDesc,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
OutlinedButton(
- onPressed: () => _serviceAction(state.restartService, '后台服务已重新启动'),
- child: const Text('重新启动'),
+ onPressed: () => _serviceAction(state.restartService, l.restarted),
+ child: Text(l.restart),
),
const SizedBox(width: Insets.sm),
OutlinedButton(
onPressed: () => _confirmDisable(state),
- child: const Text('停用…'),
+ child: Text(l.disableEllipsis),
),
],
),
@@ -239,21 +254,21 @@ class _SettingsPageState extends State<SettingsPage> {
]),
),
GroupSection(
- title: '关于',
+ title: l.about,
child: GroupBox(children: [
SettingRow(
title: 'CopySync ${state.status?.version ?? ''}',
- description: '开源软件,MIT 许可',
+ description: l.aboutDesc,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
onPressed: () => _open('https://baiyuze.github.io/copysync/'),
- child: const Text('项目主页'),
+ child: Text(l.homepage),
),
TextButton(
onPressed: () => _open('https://github.com/baiyuze/copysync/issues'),
- child: const Text('反馈问题'),
+ child: Text(l.feedback),
),
],
),
@@ -279,29 +294,30 @@ class _SettingsPageState extends State<SettingsPage> {
}
Future<void> _confirmDisable(AppState state) async {
+ final l = context.l10n;
final ok = await showDialog<bool>(
context: context,
builder: (ctx) => AlertDialog(
- title: const Text('停用后台同步?'),
- content: Text('${Wording.thisDeviceInText}将停止同步,也不再开机启动。历史记录和配对关系会保留。'),
+ title: Text(l.disableTitle),
+ content: Text(l.disableBody(Wording.thisDeviceInText)),
actions: [
- OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
- FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('停用')),
+ OutlinedButton(onPressed: () => Navigator.pop(ctx, false), child: Text(l.cancel)),
+ FilledButton(onPressed: () => Navigator.pop(ctx, true), child: Text(l.disable)),
],
),
);
- if (ok == true) await _serviceAction(state.disableService, '后台同步已停用');
+ if (ok == true) await _serviceAction(state.disableService, l.disabled);
}
Future<void> _saveServer(AppState state, Config cfg) async {
final url = _serverController.text.trim();
if (!url.startsWith('ws://') && !url.startsWith('wss://')) {
- showToast(context, '地址需以 ws:// 或 wss:// 开头', error: true);
+ showToast(context, context.l10n.urlMustBeWs, error: true);
return;
}
setState(() => _serverDirty = false);
_lastLoadedServer = url;
- await _update(state, cfg..signalingUrl = url, message: '服务器地址已更新,正在重连');
+ await _update(state, cfg..signalingUrl = url, message: context.l10n.serverUpdated);
}
Future<void> _saveName(AppState state, Config cfg) async {
@@ -309,7 +325,7 @@ class _SettingsPageState extends State<SettingsPage> {
if (name.isEmpty) return;
setState(() => _nameDirty = false);
_lastLoadedName = name;
- await _update(state, cfg..deviceName = name, message: '设备名称已更新');
+ await _update(state, cfg..deviceName = name, message: context.l10n.deviceNameUpdated);
}
Future<void> _update(AppState state, Config next, {String? message}) async {
@@ -376,18 +392,13 @@ class _DurationSelector extends StatelessWidget {
final int seconds;
final ValueChanged<int> onChanged;
- static const _options = <int, String>{
- 3600: '1 小时',
- 86400: '1 天',
- 3 * 86400: '3 天',
- 7 * 86400: '7 天',
- 30 * 86400: '30 天',
- };
+ static const _options = [3600, 86400, 3 * 86400, 7 * 86400, 30 * 86400];
@override
Widget build(BuildContext context) {
- final options = Map<int, String>.from(_options);
- options.putIfAbsent(seconds, () => '${(seconds / 3600).round()} 小时');
+ final l = context.l10n;
+ final options = {for (final s in _options) s: durationLabel(l, s)};
+ options.putIfAbsent(seconds, () => durationLabel(l, seconds));
return _Dropdown<int>(
value: seconds,
diff --git a/ui/lib/platform.dart b/ui/lib/platform.dart
index f68d536..8f0f2a1 100644
--- a/ui/lib/platform.dart
+++ b/ui/lib/platform.dart
@@ -1,17 +1,19 @@
import 'dart:io';
-/// 随平台变化的叫法。Mac 上保持原来的文案。
+import 'i18n.dart';
+
+/// 随平台变化的叫法:Mac 上说「这台 Mac」,Windows 上说「这台电脑」。
abstract final class Wording {
static final bool _win = Platform.isWindows;
/// 说到本机时的叫法,用作标题
- static String get thisDevice => _win ? '这台电脑' : '这台 Mac';
+ static String get thisDevice => _win ? appL10n.thisPcTitle : appL10n.thisMacTitle;
- /// 用在句子中间:后面紧跟汉字,Mac 上要在「Mac」后留一个空格
- static String get thisDeviceInText => _win ? '这台电脑' : '这台 Mac ';
+ /// 用在句子中间。中日文里「Mac」后面紧跟汉字,文案里已带好空格
+ static String get thisDeviceInText => _win ? appL10n.thisPcInText : appL10n.thisMacInText;
/// 说到配对双方时的叫法,用在句子中间:Windows 上对方可能是 Mac,也可能是另一台电脑
- static String get bothDevicesInText => _win ? '两台设备' : '两台 Mac ';
+ static String get bothDevicesInText => _win ? appL10n.bothDevices : appL10n.bothMacs;
}
/// 用默认浏览器打开网址。
diff --git a/ui/lib/widgets/common.dart b/ui/lib/widgets/common.dart
index 6699e34..8e23602 100644
--- a/ui/lib/widgets/common.dart
+++ b/ui/lib/widgets/common.dart
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import '../theme.dart';
+import '../i18n.dart';
import '../icons.dart';
/// 页面统一的标题区。保证各页视觉节奏一致。
@@ -404,15 +405,21 @@ String humanBytes(int n) {
return '${v.toStringAsFixed(v >= 100 ? 0 : 1)} ${units[i]}';
}
+/// 时长:整天的按天说,否则按小时。
+String durationLabel(AppLocalizations l, int seconds) => seconds % 86400 == 0
+ ? l.durationDays(seconds ~/ 86400)
+ : l.durationHours((seconds / 3600).round());
+
/// 相对时间。刚刚发生的事用"刚刚"比"14:03:22"更符合直觉。
String relativeTime(DateTime t, {DateTime? now}) {
final d = (now ?? DateTime.now()).difference(t);
- if (d.inSeconds < 10) return '刚刚';
- if (d.inMinutes < 1) return '${d.inSeconds} 秒前';
- if (d.inHours < 1) return '${d.inMinutes} 分钟前';
- if (d.inDays < 1) return '${d.inHours} 小时前';
- if (d.inDays < 7) return '${d.inDays} 天前';
- return '${t.month}月${t.day}日';
+ final l = appL10n;
+ if (d.inSeconds < 10) return l.justNow;
+ if (d.inMinutes < 1) return l.secondsAgo(d.inSeconds);
+ if (d.inHours < 1) return l.minutesAgo(d.inMinutes);
+ if (d.inDays < 1) return l.hoursAgo(d.inHours);
+ if (d.inDays < 7) return l.daysAgo(d.inDays);
+ return l.monthDay(t.month, t.day);
}
void showToast(BuildContext context, String message, {bool error = false}) {
diff --git a/ui/lib/widgets/image_preview_dialog.dart b/ui/lib/widgets/image_preview_dialog.dart
index cb008ea..8580a66 100644
--- a/ui/lib/widgets/image_preview_dialog.dart
+++ b/ui/lib/widgets/image_preview_dialog.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
+import '../i18n.dart';
import '../icons.dart';
import '../main.dart';
import '../theme.dart';
@@ -76,10 +77,10 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
child: Row(
children: [
Expanded(
- child: Text('图片预览', style: context.text.titleMedium),
+ child: Text(context.l10n.imagePreviewTitle, style: context.text.titleMedium),
),
IconButton(
- tooltip: '关闭预览',
+ tooltip: context.l10n.closePreview,
onPressed: () => Navigator.pop(context),
icon: Icon(AppIcons.xmark),
),
@@ -101,11 +102,11 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
child: Row(
children: [
Expanded(
- child: Text('滚轮或触控板缩放,拖动查看', style: context.text.bodySmall),
+ child: Text(context.l10n.previewHint, style: context.text.bodySmall),
),
TextButton(
onPressed: () => _transform.value = Matrix4.identity(),
- child: const Text('适应窗口'),
+ child: Text(context.l10n.fitWindow),
),
],
),
@@ -117,9 +118,9 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
}
Widget _content(AppState state, ClipRecord? record) {
- if (record == null) return _message('这条图片记录已被删除');
+ if (record == null) return _message(context.l10n.previewDeleted);
if (record.status == ClipStatus.CLIP_STATUS_EXPIRED) {
- return _message('图片已过期,无法预览');
+ return _message(context.l10n.previewExpired);
}
if (_requesting || record.status == ClipStatus.CLIP_STATUS_FETCHING) {
return Center(
@@ -131,7 +132,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
strokeWidth: 2,
),
const SizedBox(height: Insets.lg),
- const Text('正在下载图片…'),
+ Text(context.l10n.previewDownloading),
],
),
);
@@ -141,13 +142,13 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
return _message(
_downloadError ??
(record.status == ClipStatus.CLIP_STATUS_FAILED
- ? '图片下载失败,请重试'
- : '图片尚未下载到这台电脑'),
- action: FilledButton(onPressed: _download, child: const Text('下载并预览')),
+ ? context.l10n.previewDownloadFailed
+ : context.l10n.previewNotDownloaded),
+ action: FilledButton(onPressed: _download, child: Text(context.l10n.downloadAndPreview)),
);
}
if (record.status != ClipStatus.CLIP_STATUS_READY) {
- return _message('图片暂时无法预览');
+ return _message(context.l10n.previewUnavailable);
}
_preview ??= state.imagePreviewPath(record.id);
@@ -159,7 +160,7 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
AppState.describeError(snapshot.error!),
action: OutlinedButton(
onPressed: () => setState(() => _preview = null),
- child: const Text('重试'),
+ child: Text(context.l10n.retry),
),
);
}
@@ -183,14 +184,14 @@ class _ImagePreviewDialogState extends State<ImagePreviewDialog> {
),
// 比预览框小的图片按原始大小显示,大的才缩小到放得下:小图标不会被放大成一整屏
fit: BoxFit.scaleDown,
- semanticLabel: '复制记录中的图片',
+ semanticLabel: context.l10n.imageSemantic,
frameBuilder: (_, child, frame, synchronous) =>
frame != null || synchronous
? child
: const Center(
child: CircularProgressIndicator(strokeWidth: 2),
),
- errorBuilder: (_, _, _) => _message('无法读取图片,文件可能已被清理或损坏'),
+ errorBuilder: (_, _, _) => _message(context.l10n.previewUnreadable),
),
),
);
diff --git a/ui/lib/widgets/pairing_dialog.dart b/ui/lib/widgets/pairing_dialog.dart
index 49ac06b..c57471c 100644
--- a/ui/lib/widgets/pairing_dialog.dart
+++ b/ui/lib/widgets/pairing_dialog.dart
@@ -3,6 +3,7 @@ import 'package:flutter/services.dart';
import '../app_state.dart';
import '../gen/copysync/v1/daemon.pb.dart';
+import '../i18n.dart';
import '../main.dart';
import '../theme.dart';
import 'common.dart';
@@ -43,6 +44,7 @@ class _PairingDialogState extends State<PairingDialog> {
@override
Widget build(BuildContext context) {
+ final l = context.l10n;
return Dialog(
child: SizedBox(
width: 420,
@@ -53,10 +55,10 @@ class _PairingDialogState extends State<PairingDialog> {
padding: const EdgeInsets.fromLTRB(Insets.xl, Insets.lg, Insets.md, 0),
child: Row(
children: [
- Expanded(child: Text('添加设备', style: context.text.titleMedium)),
+ Expanded(child: Text(l.addDevice, style: context.text.titleMedium)),
IconAction(
icon: AppIcons.xmark,
- tooltip: '关闭',
+ tooltip: l.close,
onTap: () => Navigator.pop(context),
),
],
@@ -65,7 +67,7 @@ class _PairingDialogState extends State<PairingDialog> {
const SizedBox(height: Insets.md),
Segmented<int>(
value: _tab,
- segments: const [(0, '生成配对码'), (1, '输入配对码')],
+ segments: [(0, l.generateCode), (1, l.enterCode)],
onChanged: (t) => setState(() => _tab = t),
),
SizedBox(
@@ -119,6 +121,7 @@ class _GenerateTabState extends State<_GenerateTab> {
@override
Widget build(BuildContext context) {
final p = context.palette;
+ final l = context.l10n;
if (_loading) {
return const Center(child: CircularProgressIndicator(strokeWidth: 2));
}
@@ -127,65 +130,67 @@ class _GenerateTabState extends State<_GenerateTab> {
padding: const EdgeInsets.all(Insets.xl),
child: EmptyState(
icon: AppIcons.exclamationmarkCircle,
- title: '没能生成配对码',
+ title: l.codeFailedTitle,
description: _error,
- action: OutlinedButton(onPressed: _generate, child: const Text('重试')),
+ action: OutlinedButton(onPressed: _generate, child: Text(l.retry)),
),
);
}
- return Padding(
- padding: const EdgeInsets.all(Insets.xl),
- child: Column(
- children: [
- Text('在另一台设备上输入这个配对码', style: context.text.bodySmall),
- const SizedBox(height: Insets.lg),
- // 配对码是本页的主角:放大、等宽、字距拉开,方便照着念
- MouseRegion(
- cursor: SystemMouseCursors.click,
- child: GestureDetector(
- onTap: () async {
- await Clipboard.setData(ClipboardData(text: _code ?? ''));
- if (context.mounted) showToast(context, '配对码已拷贝');
- },
- child: Container(
- width: double.infinity,
- padding: const EdgeInsets.symmetric(vertical: Insets.lg),
- decoration: BoxDecoration(
- color: p.fill,
- borderRadius: BorderRadius.circular(Radii.md),
- ),
- child: Text(
- _code ?? '',
- textAlign: TextAlign.center,
- style: TextStyle(
- fontSize: 34,
- fontWeight: FontWeight.w600,
- fontFamily: monoFamily,
- letterSpacing: 10,
- color: p.text,
+ return _FillOrScroll(
+ child: Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ child: Column(
+ children: [
+ Text(l.enterOnOther, style: context.text.bodySmall),
+ const SizedBox(height: Insets.lg),
+ // 配对码是本页的主角:放大、等宽、字距拉开,方便照着念
+ MouseRegion(
+ cursor: SystemMouseCursors.click,
+ child: GestureDetector(
+ onTap: () async {
+ await Clipboard.setData(ClipboardData(text: _code ?? ''));
+ if (context.mounted) showToast(context, l.codeCopied);
+ },
+ child: Container(
+ width: double.infinity,
+ padding: const EdgeInsets.symmetric(vertical: Insets.lg),
+ decoration: BoxDecoration(
+ color: p.fill,
+ borderRadius: BorderRadius.circular(Radii.md),
+ ),
+ child: Text(
+ _code ?? '',
+ textAlign: TextAlign.center,
+ style: TextStyle(
+ fontSize: 34,
+ fontWeight: FontWeight.w600,
+ fontFamily: monoFamily,
+ letterSpacing: 10,
+ color: p.text,
+ ),
),
),
),
),
- ),
- const SizedBox(height: Insets.sm),
- Text('点击可拷贝,5 分钟内有效', style: context.text.labelSmall),
- const Spacer(),
- Row(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Icon(AppIcons.lockShield, size: 15, color: p.textDim),
- const SizedBox(width: Insets.sm),
- Expanded(
- child: Text(
- '对方输入后,${Wording.bothDevicesInText}会显示同样的两行安全指纹,核对一致再确认。',
- style: context.text.bodySmall,
+ const SizedBox(height: Insets.sm),
+ Text(l.codeHint, style: context.text.labelSmall),
+ const Spacer(),
+ Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Icon(AppIcons.lockShield, size: 15, color: p.textDim),
+ const SizedBox(width: Insets.sm),
+ Expanded(
+ child: Text(
+ l.afterEnterFootnote(Wording.bothDevicesInText),
+ style: context.text.bodySmall,
+ ),
),
- ),
- ],
- ),
- ],
+ ],
+ ),
+ ],
+ ),
),
);
}
@@ -213,7 +218,7 @@ class _JoinTabState extends State<_JoinTab> {
if (_busy) return;
final code = _controller.text.trim();
if (code.length != 6) {
- setState(() => _error = '配对码是 6 位字母或数字');
+ setState(() => _error = context.l10n.codeInvalid);
return;
}
setState(() {
@@ -234,65 +239,85 @@ class _JoinTabState extends State<_JoinTab> {
@override
Widget build(BuildContext context) {
final p = context.palette;
- return Padding(
- padding: const EdgeInsets.all(Insets.xl),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.stretch,
- children: [
- Text('输入另一台设备上显示的配对码',
- style: context.text.bodySmall, textAlign: TextAlign.center),
- const SizedBox(height: Insets.lg),
- TextField(
- controller: _controller,
- maxLength: 6,
- textCapitalization: TextCapitalization.characters,
- textAlign: TextAlign.center,
- style: const TextStyle(
- fontSize: 28,
- fontWeight: FontWeight.w600,
- fontFamily: monoFamily,
- letterSpacing: 10,
+ final l = context.l10n;
+ return _FillOrScroll(
+ child: Padding(
+ padding: const EdgeInsets.all(Insets.xl),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: [
+ Text(l.enterCodeShown, style: context.text.bodySmall, textAlign: TextAlign.center),
+ const SizedBox(height: Insets.lg),
+ TextField(
+ controller: _controller,
+ maxLength: 6,
+ textCapitalization: TextCapitalization.characters,
+ textAlign: TextAlign.center,
+ style: const TextStyle(
+ fontSize: 28,
+ fontWeight: FontWeight.w600,
+ fontFamily: monoFamily,
+ letterSpacing: 10,
+ ),
+ inputFormatters: [
+ // 配对码字符集不含易混字符,这里统一转大写并过滤
+ FilteringTextInputFormatter.allow(RegExp('[a-zA-Z0-9]')),
+ TextInputFormatter.withFunction(
+ (_, next) => next.copyWith(text: next.text.toUpperCase()),
+ ),
+ ],
+ decoration: InputDecoration(
+ counterText: '',
+ hintText: '······',
+ hintStyle: TextStyle(letterSpacing: 10, fontSize: 28, color: p.textFaint),
+ contentPadding: const EdgeInsets.symmetric(vertical: Insets.md),
+ ),
+ onSubmitted: (_) => _submit(),
),
- inputFormatters: [
- // 配对码字符集不含易混字符,这里统一转大写并过滤
- FilteringTextInputFormatter.allow(RegExp('[a-zA-Z0-9]')),
- TextInputFormatter.withFunction(
- (_, next) => next.copyWith(text: next.text.toUpperCase()),
+ if (_error != null) ...[
+ const SizedBox(height: Insets.sm),
+ Text(
+ _error!,
+ style: context.text.bodySmall?.copyWith(color: p.danger),
+ textAlign: TextAlign.center,
),
],
- decoration: InputDecoration(
- counterText: '',
- hintText: '······',
- hintStyle: TextStyle(letterSpacing: 10, fontSize: 28, color: p.textFaint),
- contentPadding: const EdgeInsets.symmetric(vertical: Insets.md),
- ),
- onSubmitted: (_) => _submit(),
- ),
- if (_error != null) ...[
- const SizedBox(height: Insets.sm),
- Text(
- _error!,
- style: context.text.bodySmall?.copyWith(color: p.danger),
- textAlign: TextAlign.center,
+ const Spacer(),
+ FilledButton(
+ onPressed: _busy ? null : _submit,
+ child: _busy
+ ? const SizedBox(
+ width: 14,
+ height: 14,
+ child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
+ )
+ : Text(l.continueAction),
),
],
- const Spacer(),
- FilledButton(
- onPressed: _busy ? null : _submit,
- child: _busy
- ? const SizedBox(
- width: 14,
- height: 14,
- child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
- )
- : const Text('继续'),
- ),
- ],
+ ),
),
);
}
}
+/// 内容放得下时铺满页签的高度,Spacer 照样把脚注推到底部;
+/// 放不下时(换成更长的语言、或系统字号调大)改为滚动,而不是溢出。
+class _FillOrScroll extends StatelessWidget {
+ const _FillOrScroll({required this.child});
+
+ final Widget child;
+
+ @override
+ Widget build(BuildContext context) => LayoutBuilder(
+ builder: (context, box) => SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(minHeight: box.maxHeight),
+ child: IntrinsicHeight(child: child),
+ ),
+ ),
+ );
+}
+
/// 指纹核对对话框。
///
/// 这是整个安全模型里唯一依赖人的环节:信令服务器能替换转发中的公钥,
@@ -332,7 +357,7 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
await state.confirmPairing(widget.peer.pairingSession, accept);
if (!mounted) return;
Navigator.pop(context);
- showToast(context, accept ? '配对完成' : '已拒绝配对');
+ showToast(context, accept ? context.l10n.pairingDone : context.l10n.pairingRejected);
} catch (e) {
state.dismissPendingPairing(widget.peer.pairingSession);
if (!mounted) return;
@@ -344,6 +369,7 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
@override
Widget build(BuildContext context) {
final p = context.palette;
+ final l = context.l10n;
final peer = widget.peer;
final self = AppScope.of(context).self;
final rows = pairingFingerprintRows(self, peer);
@@ -356,9 +382,9 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- Text('核对安全指纹', style: context.text.titleMedium),
+ Text(l.verifyTitle, style: context.text.titleMedium),
const SizedBox(height: 2),
- Text('正在与「${peer.name}」配对', style: context.text.bodySmall),
+ Text(l.pairingWith(peer.name), style: context.text.bodySmall),
const SizedBox(height: Insets.xl),
Container(
padding: const EdgeInsets.symmetric(horizontal: Insets.lg, vertical: Insets.md),
@@ -400,18 +426,14 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
),
),
const SizedBox(height: Insets.lg),
- Text(
- '${Wording.bothDevicesInText}上显示的这两行应当完全相同。'
- '有任何一个字符不同,说明连接可能被第三方篡改,请拒绝。',
- style: context.text.bodySmall,
- ),
+ Text(l.verifyBody(Wording.bothDevicesInText), style: context.text.bodySmall),
const SizedBox(height: Insets.xl),
Row(
children: [
Expanded(
child: OutlinedButton(
onPressed: _busy ? null : () => _respond(false),
- child: const Text('不一致,拒绝'),
+ child: Text(l.rejectMismatch),
),
),
const SizedBox(width: Insets.md),
@@ -424,7 +446,7 @@ class _PairingConfirmDialogState extends State<PairingConfirmDialog> {
height: 14,
child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white),
)
- : const Text('一致,确认配对'),
+ : Text(l.confirmMatch),
),
),
],
diff --git a/ui/macos/Runner/Info.plist b/ui/macos/Runner/Info.plist
index f90097e..9b7ef27 100644
--- a/ui/macos/Runner/Info.plist
+++ b/ui/macos/Runner/Info.plist
@@ -4,6 +4,12 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleLocalizations</key>
+ <array>
+ <string>en</string>
+ <string>zh-Hans</string>
+ <string>ja</string>
+ </array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
diff --git a/ui/pubspec.lock b/ui/pubspec.lock
index e3dcf38..2284de3 100644
--- a/ui/pubspec.lock
+++ b/ui/pubspec.lock
@@ -94,6 +94,11 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.0"
+ flutter_localizations:
+ dependency: "direct main"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -155,6 +160,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.1.2"
+ intl:
+ dependency: "direct main"
+ description:
+ name: intl
+ sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.20.2"
leak_tracker:
dependency: transitive
description:
diff --git a/ui/pubspec.yaml b/ui/pubspec.yaml
index 7c4885b..8d63227 100644
--- a/ui/pubspec.yaml
+++ b/ui/pubspec.yaml
@@ -30,6 +30,9 @@ environment:
dependencies:
flutter:
sdk: flutter
+ flutter_localizations:
+ sdk: flutter
+ intl: any
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@@ -55,6 +58,8 @@ dev_dependencies:
# The following section is specific to Flutter packages.
flutter:
+ # 由 lib/l10n/*.arb 生成界面文案(中文、英文、日文),见 l10n.yaml
+ generate: true
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
diff --git a/ui/test/flutter_test_config.dart b/ui/test/flutter_test_config.dart
new file mode 100644
index 0000000..7c269ce
--- /dev/null
+++ b/ui/test/flutter_test_config.dart
@@ -0,0 +1,12 @@
+import 'dart:async';
+
+import 'package:copysync_ui/i18n.dart';
+import 'package:flutter/widgets.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+/// 测试默认按简体中文跑:断言里写的都是中文文案。其他语言在 i18n_test.dart 里单独测。
+Future<void> testExecutable(FutureOr<void> Function() testMain) async {
+ TestWidgetsFlutterBinding.ensureInitialized().platformDispatcher.localesTestValue = const [Locale('zh')];
+ appL10n = lookupAppLocalizations(const Locale('zh'));
+ await testMain();
+}
diff --git a/ui/test/i18n_test.dart b/ui/test/i18n_test.dart
new file mode 100644
index 0000000..4a44ad6
--- /dev/null
+++ b/ui/test/i18n_test.dart
@@ -0,0 +1,166 @@
+import 'package:fixnum/fixnum.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+
+import 'package:copysync_ui/app_state.dart';
+import 'package:copysync_ui/background_service.dart';
+import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
+import 'package:copysync_ui/i18n.dart';
+import 'package:copysync_ui/main.dart';
+import 'package:copysync_ui/widgets/pairing_dialog.dart';
+
+class _DemoState extends AppState {
+ @override
+ Future<String> createPairingCode() async => 'K7MP2X';
+}
+
+AppState _demo(String language, {LinkState link = LinkState.online, ServiceState? service}) =>
+ _DemoState()
+ ..debugSeed(
+ link: link,
+ serviceState: service,
+ status: Status(signalingConnected: true, version: '1.3.0'),
+ config: Config(
+ language: language,
+ signalingUrl: 'wss://sync.example.com/signal',
+ deviceName: 'MacBook Pro',
+ autoSyncThresholdBytes: Int64(50 << 20),
+ historyTtlSeconds: Int64(3 * 86400),
+ cacheTtlSeconds: Int64(86400),
+ ),
+ self: Device(id: 'self', name: 'MacBook Pro', publicKeyFingerprint: 'H3QD-7KXA-M2PV'),
+ peers: [
+ Device(
+ id: 'air',
+ name: 'MacBook Air',
+ online: true,
+ connection: ConnectionKind.CONNECTION_KIND_RELAY,
+ publicKeyFingerprint: 'R8NF-2WTC-QL5J',
+ ),
+ ],
+ records: [
+ ClipRecord(
+ id: '1',
+ kind: ClipKind.CLIP_KIND_IMAGE,
+ originDeviceName: 'MacBook Air',
+ textPreview: '图片 2.4 MB',
+ totalSize: Int64(2 << 20),
+ ),
+ ClipRecord(
+ id: '2',
+ kind: ClipKind.CLIP_KIND_FILE,
+ status: ClipStatus.CLIP_STATUS_REMOTE_ONLY,
+ originDeviceName: 'MacBook Air',
+ textPreview: 'report.key 等 2 项',
+ totalSize: Int64(900 << 20),
+ items: [ClipItem(name: 'report.key'), ClipItem(name: 'notes.txt')],
+ ),
+ ],
+ );
+
+void main() {
+ test('按系统的语言偏好取第一个支持的,都不支持时用英文', () {
+ expect(resolveLocale(const [Locale('ja', 'JP')]), const Locale('ja'));
+ expect(
+ resolveLocale(const [Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant', countryCode: 'TW')]),
+ const Locale('zh'),
+ );
+ expect(resolveLocale(const [Locale('fr'), Locale('ja')]), const Locale('ja'));
+ expect(resolveLocale(const [Locale('fr')]), const Locale('en'));
+ expect(resolveLocale(null), const Locale('en'));
+ });
+
+ test('设置里的空字符串表示跟随系统', () {
+ expect(localeFromSetting(''), isNull);
+ expect(localeFromSetting('zh-Hans'), const Locale('zh'));
+ expect(localeFromSetting('en'), const Locale('en'));
+ expect(localeFromSetting('ja'), const Locale('ja'));
+ });
+
+ testWidgets('设置里选的语言优先于系统语言', (tester) async {
+ await tester.pumpWidget(CopySyncApp(state: _demo('en')));
+ expect(find.text('History'), findsWidgets);
+ expect(find.text('复制记录'), findsNothing);
+ });
+
+ testWidgets('跟随系统时用系统语言', (tester) async {
+ await tester.pumpWidget(CopySyncApp(state: _demo('')));
+ expect(find.text('复制记录'), findsWidgets);
+ });
+
+ testWidgets('配置里的语言一变,界面立即换过来', (tester) async {
+ final state = _demo('');
+ await tester.pumpWidget(CopySyncApp(state: state));
+ expect(find.text('复制记录'), findsWidgets);
+
+ state.config!.language = 'ja';
+ state.notifyListeners();
+ await tester.pump();
+ expect(find.text('履歴'), findsWidgets);
+ expect(find.text('复制记录'), findsNothing);
+ });
+
+ testWidgets('图片与文件的标题按界面语言显示,不用后台服务存下的中文摘要', (tester) async {
+ await tester.pumpWidget(CopySyncApp(state: _demo('en')));
+ expect(find.text('Image'), findsOneWidget);
+ expect(find.text('report.key and 1 more'), findsOneWidget);
+ expect(find.textContaining('图片'), findsNothing);
+ });
+
+ // 英文、日文通常比中文长:在最小窗口尺寸下把每一页、每个对话框都打开一遍,确认没有文字溢出
+ for (final language in ['en', 'ja', 'zh-Hans']) {
+ group('最小窗口下的 $language 界面', () {
+ setUp(() {
+ final view = TestWidgetsFlutterBinding.instance.platformDispatcher.views.first;
+ view.physicalSize = const Size(760, 520);
+ view.devicePixelRatio = 1;
+ });
+ tearDown(() => TestWidgetsFlutterBinding.instance.platformDispatcher.views.first.reset());
+
+ Future<AppLocalizations> open(WidgetTester tester, AppState state) async {
+ await tester.pumpWidget(CopySyncApp(state: state));
+ await tester.pump();
+ return AppLocalizations.of(tester.element(find.byType(Shell)));
+ }
+
+ testWidgets('三个页面', (tester) async {
+ final l = await open(tester, _demo(language));
+ await tester.tap(find.text(l.navDevices).first);
+ await tester.pump();
+ expect(find.text(l.pairedDevices), findsOneWidget);
+ await tester.tap(find.text(l.navSettings).first);
+ await tester.pump();
+ await tester.dragUntilVisible(find.text(l.language), find.byType(ListView), const Offset(0, -100));
+ await tester.dragUntilVisible(find.text(l.about), find.byType(ListView), const Offset(0, -200));
+ });
+
+ testWidgets('配对对话框', (tester) async {
+ final l = await open(tester, _demo(language));
+ showPairingDialog(tester.element(find.byType(Shell)));
+ await tester.pumpAndSettle();
+ expect(find.text('K7MP2X'), findsOneWidget);
+ await tester.tap(find.text(l.enterCode));
+ await tester.pumpAndSettle();
+ expect(find.text(l.enterCodeShown), findsOneWidget);
+ });
+
+ testWidgets('核对指纹', (tester) async {
+ final state = _demo(language);
+ state.debugSeed(
+ status: state.status!,
+ config: state.config!,
+ self: state.self!,
+ pendingPairing: Device(name: 'MacBook Air', publicKeyFingerprint: 'R8NF-2WTC-QL5J', pairingSession: 's'),
+ );
+ final l = await open(tester, state);
+ await tester.pumpAndSettle();
+ expect(find.text(l.confirmMatch), findsOneWidget);
+ });
+
+ testWidgets('启用后台服务的引导页', (tester) async {
+ final l = await open(tester, _demo(language, link: LinkState.offline, service: ServiceState.notInstalled));
+ expect(find.text(l.svcEnable), findsOneWidget);
+ });
+ });
+ }
+}
diff --git a/ui/test/image_preview_test.dart b/ui/test/image_preview_test.dart
index 7ce826f..0315f57 100644
--- a/ui/test/image_preview_test.dart
+++ b/ui/test/image_preview_test.dart
@@ -63,7 +63,7 @@ Future<void> openPreview(
}) async {
await tester.pumpWidget(CopySyncApp(state: state));
await tester.pump();
- await tester.tap(find.text(button ? '预览' : '测试图片'));
+ await tester.tap(button ? find.text('预览') : find.textContaining('来自 测试电脑'));
await tester.pump(const Duration(milliseconds: 250));
expect(find.byType(ImagePreviewDialog), findsOneWidget);
}
@@ -243,7 +243,7 @@ void main() {
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
addTearDown(mouse.removePointer);
await mouse.addPointer(location: Offset.zero);
- await mouse.moveTo(tester.getCenter(find.text('测试图片')));
+ await mouse.moveTo(tester.getCenter(find.textContaining('来自 测试电脑')));
await tester.pump();
expect(find.text('放入剪贴板').hitTestable(), findsOneWidget);
diff --git a/ui/test/widget_test.dart b/ui/test/widget_test.dart
index f6fe4d5..e7f85c5 100644
--- a/ui/test/widget_test.dart
+++ b/ui/test/widget_test.dart
@@ -5,6 +5,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:copysync_ui/app_state.dart';
import 'package:copysync_ui/daemon_client.dart';
import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
+import 'package:copysync_ui/i18n.dart';
import 'package:copysync_ui/main.dart';
import 'package:copysync_ui/theme.dart';
import 'package:copysync_ui/widgets/common.dart';
@@ -78,6 +79,9 @@ void main() {
state: state,
child: MaterialApp(
theme: buildTheme(Brightness.light),
+ locale: const Locale('zh'),
+ supportedLocales: supportedLocales,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
home: Scaffold(body: PairingConfirmDialog(peer: b)),
),
));
diff --git a/ui/tool/l10n/strings.py b/ui/tool/l10n/strings.py
new file mode 100644
index 0000000..01a455b
--- /dev/null
+++ b/ui/tool/l10n/strings.py
@@ -0,0 +1,272 @@
+"""界面文案的唯一来源:每条是 (键, 英文, 简体中文, 日文)。
+
+ python3 ui/tool/l10n/strings.py
+
+生成 ui/lib/l10n/app_en.arb、app_zh.arb、app_ja.arb,再由 flutter gen-l10n 生成 Dart 代码。
+三种语言放在同一行里,改一条时不会漏掉另外两种。
+
+占位符写成 {name};英文里的复数用 ICU 写法,例如 {count, plural, =1{…} other{…}}。
+"""
+
+import json
+import re
+from pathlib import Path
+
+S = [
+ # ── 侧边栏与连接状态 ──
+ ("navHistory", "History", "复制记录", "履歴"),
+ ("navDevices", "Devices", "设备", "デバイス"),
+ ("navSettings", "Settings", "设置", "設定"),
+ ("linkConnecting", "Connecting…", "正在连接…", "接続中…"),
+ ("linkServiceNotRunning", "Service not running", "后台服务未运行", "サービス停止中"),
+ ("linkNoServer", "No server connection", "未连接服务器", "サーバーに未接続"),
+ ("linkOnlinePeers", "{count, plural, =1{1 device online} other{{count} devices online}}", "{count} 台设备在线", "{count} 台がオンライン"),
+ ("linkServerConnected", "Connected to the server", "已连接服务器", "サーバーに接続済み"),
+ ("linkConnectionLost", "Connection lost: {detail}", "连接中断:{detail}", "接続が切れました:{detail}"),
+ ("linkServiceDisconnected", "Service disconnected", "后台服务已断开", "サービスとの接続が切れました"),
+ ("linkServiceDisabled", "Background sync is off", "后台服务已停用", "同期はオフです"),
+ ("errServiceNotConnected", "Not connected to the background service", "后台服务未连接", "バックグラウンドサービスに接続していません"),
+ ("errUnimplemented", "This isn't available yet", "该功能尚未接入", "この機能はまだ使えません"),
+ ("errUnavailable", "Can't reach the background service", "无法连接后台服务", "バックグラウンドサービスに接続できません"),
+ ("errServiceStart", "Couldn't start the background service: {detail}", "启动后台服务失败:{detail}", "バックグラウンドサービスを起動できませんでした:{detail}"),
+ ("errServiceRestart", "Couldn't restart the background service: {detail}", "重启后台服务失败:{detail}", "バックグラウンドサービスを再起動できませんでした:{detail}"),
+ ("errAutostart", "Couldn't set CopySync to start at login: {detail}", "登记开机自启失败:{detail}", "ログイン時の自動起動を設定できませんでした:{detail}"),
+
+ # ── 对设备的叫法:Mac 上说「这台 Mac」,Windows 上说「这台电脑」。
+ # InText 用在句子中间,中日文里「Mac」后面紧跟汉字或假名,所以带一个空格 ──
+ ("thisMacTitle", "This Mac", "这台 Mac", "この Mac"),
+ ("thisPcTitle", "This computer", "这台电脑", "このコンピューター"),
+ ("thisMacInText", "this Mac", "这台 Mac ", "この Mac "),
+ ("thisPcInText", "this computer", "这台电脑", "このコンピューター"),
+ ("bothMacs", "both Macs", "两台 Mac ", "両方の Mac "),
+ ("bothDevices", "both devices", "两台设备", "両方のデバイス"),
+ ("thisDeviceShort", "This device", "本机", "このデバイス"),
+ ("fromDevice", "From {name}", "来自 {name}", "{name} から"),
+
+ # ── 通用动作 ──
+ ("cancel", "Cancel", "取消", "キャンセル"),
+ ("close", "Close", "关闭", "閉じる"),
+ ("save", "Save", "保存", "保存"),
+ ("retry", "Try again", "重试", "再試行"),
+ ("continueAction", "Continue", "继续", "続ける"),
+
+ # ── 时间与时长 ──
+ ("justNow", "Just now", "刚刚", "たった今"),
+ ("secondsAgo", "{n}s ago", "{n} 秒前", "{n} 秒前"),
+ ("minutesAgo", "{n, plural, =1{1 minute ago} other{{n} minutes ago}}", "{n} 分钟前", "{n} 分前"),
+ ("hoursAgo", "{n, plural, =1{1 hour ago} other{{n} hours ago}}", "{n} 小时前", "{n} 時間前"),
+ ("daysAgo", "{n, plural, =1{Yesterday} other{{n} days ago}}", "{n} 天前", "{n} 日前"),
+ ("monthDay", "{month}/{day}", "{month}月{day}日", "{month}月{day}日"),
+ ("durationHours", "{n, plural, =1{1 hour} other{{n} hours}}", "{n} 小时", "{n} 時間"),
+ ("durationDays", "{n, plural, =1{1 day} other{{n} days}}", "{n} 天", "{n} 日"),
+
+ # ── 复制记录 ──
+ ("historyEmptySubtitle", "Copy on any of your devices and it shows up here", "在任意一台设备上复制,内容会出现在这里", "どのデバイスでコピーしても、ここに表示されます"),
+ ("historyCount", "{count, plural, =1{1 item} other{{count} items}}", "共 {count} 条", "{count} 件"),
+ ("historyCountKept", "{count, plural, =1{1 item} other{{count} items}}, kept for {ttl}", "共 {count} 条,保留 {ttl}", "{count} 件、{ttl}保存"),
+ ("filterAll", "All", "全部", "すべて"),
+ ("filterText", "Text", "文本", "テキスト"),
+ ("filterImage", "Images", "图片", "画像"),
+ ("filterFile", "Files", "文件", "ファイル"),
+ ("historyClearTooltip", "Clear history", "清空记录", "履歴を消去"),
+ ("historyEmptyTitle", "Nothing here yet", "还没有记录", "まだ履歴がありません"),
+ ("historyEmptyFilteredTitle", "Nothing of this kind", "没有这一类的记录", "この種類の履歴はありません"),
+ ("historyEmptyBody", "Copy text, an image or a file on any paired device and it appears here.", "在任意一台已配对的设备上复制文本、图片或文件,记录会出现在这里。", "ペアリングしたどのデバイスでテキスト、画像、ファイルをコピーしても、ここに表示されます。"),
+ ("clearConfirmTitle", "Clear the whole history?", "清空全部记录?", "履歴をすべて消去しますか?"),
+ ("clearConfirmBody", "Everything synced from your devices, and the cached files, will be removed from {device}. The original files aren't affected.", "所有设备上同步来的记录和已缓存的文件都会从{device}上删除。原始文件不受影响。", "同期した履歴とキャッシュしたファイルが{device}から削除されます。元のファイルには影響しません。"),
+ ("clear", "Clear", "清空", "消去"),
+ ("historyCleared", "History cleared", "记录已清空", "履歴を消去しました"),
+ ("permDeniedTitle", "CopySync can't read the clipboard", "已禁止 CopySync 读取剪贴板", "CopySync はクリップボードを読み取れません"),
+ ("permAskTitle", "Allow CopySync to read the clipboard", "允许 CopySync 读取剪贴板", "CopySync にクリップボードの読み取りを許可してください"),
+ ("permDeniedBody", "What you copy on this Mac won't be synced. In System Settings, set CopySync Daemon to Allow.", "在这台 Mac 上复制的内容不会同步出去。到系统设置里把 CopySync Daemon 改为「允许」。", "この Mac でコピーした内容は同期されません。システム設定で CopySync Daemon を「許可」にしてください。"),
+ ("permAskBody", "Otherwise macOS asks every time. In System Settings, set CopySync Daemon to Allow.", "否则 macOS 每次都会弹窗询问。到系统设置里把 CopySync Daemon 改为「允许」。", "許可しないと macOS が毎回確認します。システム設定で CopySync Daemon を「許可」にしてください。"),
+ ("openSystemSettings", "Open System Settings", "打开系统设置", "システム設定を開く"),
+ ("fetch", "Pull to this device", "拉取到本机", "このデバイスに取り込む"),
+ ("fetchStarted", "Pulling…", "开始拉取", "取り込みを開始しました"),
+ ("transferFailed", "Transfer failed", "传输失败", "転送に失敗しました"),
+ ("expired", "Expired", "已过期", "期限切れ"),
+ ("preview", "Preview", "预览", "プレビュー"),
+ ("putOnClipboard", "Copy to clipboard", "放入剪贴板", "クリップボードに入れる"),
+ ("putOnClipboardDone", "On the clipboard", "已放入剪贴板", "クリップボードに入れました"),
+ ("deleteRecord", "Delete this item", "删除这条记录", "この履歴を削除"),
+ ("deleted", "Deleted", "已删除", "削除しました"),
+ ("emptyRecord", "(empty)", "(空)", "(空)"),
+ ("imageRecord", "Image", "图片", "画像"),
+ ("itemsSummary", "{name} and {others, plural, =1{1 more} other{{others} more}}", "{name} 等 {count} 项", "{name} ほか {others} 件"),
+
+ # ── 图片预览 ──
+ ("imagePreviewTitle", "Image preview", "图片预览", "画像プレビュー"),
+ ("closePreview", "Close preview", "关闭预览", "プレビューを閉じる"),
+ ("previewHint", "Scroll or pinch to zoom, drag to move around", "滚轮或触控板缩放,拖动查看", "ホイールやトラックパッドで拡大縮小、ドラッグで移動"),
+ ("fitWindow", "Fit to window", "适应窗口", "ウィンドウに合わせる"),
+ ("previewDeleted", "This image has been deleted from the history", "这条图片记录已被删除", "この画像は履歴から削除されました"),
+ ("previewExpired", "This image has expired and can't be previewed", "图片已过期,无法预览", "この画像は期限切れのためプレビューできません"),
+ ("previewDownloading", "Downloading the image…", "正在下载图片…", "画像をダウンロード中…"),
+ ("previewDownloadFailed", "The download failed. Try again.", "图片下载失败,请重试", "ダウンロードに失敗しました。もう一度お試しください。"),
+ ("previewNotDownloaded", "This image isn't on this computer yet", "图片尚未下载到这台电脑", "この画像はまだこのコンピューターにありません"),
+ ("downloadAndPreview", "Download and preview", "下载并预览", "ダウンロードしてプレビュー"),
+ ("previewUnavailable", "This image can't be previewed right now", "图片暂时无法预览", "現在この画像はプレビューできません"),
+ ("imageSemantic", "Image from the history", "复制记录中的图片", "履歴の画像"),
+ ("previewUnreadable", "Can't read the image. The file may have been cleaned up or damaged.", "无法读取图片,文件可能已被清理或损坏", "画像を読み込めません。ファイルが削除されたか破損している可能性があります。"),
+
+ # ── 设备 ──
+ ("devicesSubtitleEmpty", "Once paired, your devices share one clipboard", "配对之后,设备之间就会同步剪贴板", "ペアリングすると、デバイス間でクリップボードが同期されます"),
+ ("devicesSubtitle", "{paired} paired, {online} online", "已配对 {paired} 台,{online} 台在线", "ペアリング済み {paired} 台、オンライン {online} 台"),
+ ("addDevice", "Add device", "添加设备", "デバイスを追加"),
+ ("thisDeviceFootnote", "When pairing, {both} show the same two lines of security fingerprints, one for each device. Confirm only if they match character for character.", "配对时,{both}会显示同样的两行安全指纹:这台的和对方的。逐字核对一致才能确认。", "ペアリング時、{both}に同じ 2 行のセキュリティ指紋(このデバイスと相手のもの)が表示されます。1 文字ずつ一致を確かめてから確定してください。"),
+ ("noDevicesTitle", "No paired devices yet", "还没有配对的设备", "ペアリングしたデバイスはまだありません"),
+ ("noDevicesBody", "Open CopySync on your other computer and link the two with a 6-character pairing code.", "在另一台电脑上打开 CopySync,用 6 位配对码把两台连起来。", "もう一台のコンピューターで CopySync を開き、6 桁のペアリングコードでつなげます。"),
+ ("noDevicesNeedServer", "Connect to a signaling server in Settings before pairing.", "先在「设置」里连接信令服务器,才能配对设备。", "ペアリングの前に、「設定」でシグナリングサーバーに接続してください。"),
+ ("pairedDevices", "Paired devices", "已配对的设备", "ペアリング済みのデバイス"),
+ ("pairedFootnote", "Direct: data goes straight between the two devices. Relay: when the network blocks a direct path, data goes through your server and stays end-to-end encrypted.", "直连:数据在两台设备之间直接传输。中转:网络环境打不通直连时,经你的服务器转发,内容依然是端到端加密的。", "直接接続:データは 2 台のデバイス間で直接やり取りされます。中継:直接つながらないネットワークでは、あなたのサーバーを経由します。内容はエンドツーエンドで暗号化されたままです。"),
+ ("offline", "Offline", "离线", "オフライン"),
+ ("direct", "Direct", "直连", "直接接続"),
+ ("relay", "Relay", "中转", "中継"),
+ ("online", "Online", "在线", "オンライン"),
+ ("moreActions", "More", "更多操作", "その他の操作"),
+ ("copyFingerprint", "Copy fingerprint", "拷贝安全指纹", "指紋をコピー"),
+ ("unpairEllipsis", "Unpair…", "解除配对…", "ペアリングを解除…"),
+ ("fingerprintCopied", "Fingerprint copied", "安全指纹已拷贝", "指紋をコピーしました"),
+ ("unpairTitle", "Unpair “{name}”?", "解除与「{name}」的配对?", "「{name}」とのペアリングを解除しますか?"),
+ ("unpairBody", "The two devices will stop syncing. To sync again, you'll need to pair them and check the fingerprints again.", "两台设备将不再同步。以后想恢复,需要重新配对并核对指纹。", "2 台のデバイスは同期しなくなります。再開するには、もう一度ペアリングして指紋を確かめる必要があります。"),
+ ("unpair", "Unpair", "解除配对", "ペアリングを解除"),
+ ("unpaired", "Unpaired", "已解除配对", "ペアリングを解除しました"),
+
+ # ── 配对 ──
+ ("generateCode", "Show a code", "生成配对码", "コードを表示"),
+ ("enterCode", "Enter a code", "输入配对码", "コードを入力"),
+ ("codeFailedTitle", "Couldn't create a pairing code", "没能生成配对码", "ペアリングコードを作成できませんでした"),
+ ("enterOnOther", "Enter this code on your other device", "在另一台设备上输入这个配对码", "もう一台のデバイスでこのコードを入力してください"),
+ ("codeCopied", "Code copied", "配对码已拷贝", "コードをコピーしました"),
+ ("codeHint", "Click to copy. Valid for 5 minutes.", "点击可拷贝,5 分钟内有效", "クリックでコピー。有効期間は 5 分です。"),
+ ("afterEnterFootnote", "Once it's entered, {both} show the same two lines of security fingerprints. Confirm only if they match.", "对方输入后,{both}会显示同样的两行安全指纹,核对一致再确认。", "入力されると、{both}に同じ 2 行のセキュリティ指紋が表示されます。一致を確かめてから確定してください。"),
+ ("codeInvalid", "A pairing code is 6 letters or digits", "配对码是 6 位字母或数字", "ペアリングコードは 6 桁の英数字です"),
+ ("enterCodeShown", "Enter the code shown on your other device", "输入另一台设备上显示的配对码", "もう一台のデバイスに表示されたコードを入力してください"),
+ ("pairingDone", "Paired", "配对完成", "ペアリングしました"),
+ ("pairingRejected", "Pairing declined", "已拒绝配对", "ペアリングを拒否しました"),
+ ("verifyTitle", "Check the security fingerprints", "核对安全指纹", "セキュリティ指紋を確認"),
+ ("pairingWith", "Pairing with “{name}”", "正在与「{name}」配对", "「{name}」とペアリング中"),
+ ("verifyBody", "The two lines on {both} must be identical. If even one character differs, someone may be tampering with the connection, so decline.", "{both}上显示的这两行应当完全相同。有任何一个字符不同,说明连接可能被第三方篡改,请拒绝。", "{both}に表示された 2 行は完全に同じはずです。1 文字でも違う場合は、第三者が通信を改ざんしている可能性があるため、拒否してください。"),
+ ("rejectMismatch", "Mismatch, decline", "不一致,拒绝", "不一致、拒否"),
+ ("confirmMatch", "They match, pair", "一致,确认配对", "一致、ペアリング"),
+
+ # ── 设置 ──
+ ("server", "Server", "服务器", "サーバー"),
+ ("serverFootnote", "The server only helps devices find each other and set up a direct connection. It can't see what they send.", "服务器只负责让设备找到彼此、协商直连。设备之间传输的内容它看不到。", "サーバーはデバイス同士を見つけ、直接接続を取り持つだけです。やり取りする内容は見えません。"),
+ ("signalingUrl", "Signaling server", "信令服务器地址", "シグナリングサーバー"),
+ ("signalingUrlDesc", "Press Return to save; it reconnects right away", "按回车保存,保存后立即重新连接", "Enter で保存し、すぐに再接続します"),
+ ("signalingUrlPlaceholder", "ws://server-address:8787/signal", "ws://服务器地址:8787/signal", "ws://サーバーアドレス:8787/signal"),
+ ("publicStun", "Probe with public servers", "用公共服务器探测网络出口", "公開サーバーで出口を調べる"),
+ ("publicStunDesc", "On networks with several uplinks, such as offices with two ISPs, this finds more direct paths. Public servers only see your public IP.", "公司双线这类多出口网络里,能找到更多可以直连的路径。公共服务器只会看到你的公网 IP", "複数の回線を持つ会社などのネットワークで、直接つながる経路を多く見つけます。公開サーバーに見えるのはグローバル IP だけです。"),
+ ("connectionStatus", "Connection", "连接状态", "接続状態"),
+ ("connectedDesc", "Connected to the signaling server", "已连接到信令服务器", "シグナリングサーバーに接続しています"),
+ ("disconnectedDesc", "Can't reach the server. Check the address and that the server is running.", "连不上服务器。检查地址是否正确、服务器是否在运行。", "サーバーに接続できません。アドレスとサーバーの稼働を確認してください。"),
+ ("connected", "Connected", "已连接", "接続済み"),
+ ("notConnected", "Not connected", "未连接", "未接続"),
+ ("deviceName", "Device name", "设备名称", "デバイス名"),
+ ("deviceNameDesc", "Shown in the list on your other devices", "显示在其他设备的列表里", "他のデバイスの一覧に表示されます"),
+ ("language", "Language", "语言", "言語"),
+ ("languageSystem", "System", "跟随系统", "システムに合わせる"),
+ ("sync", "Sync", "同步", "同期"),
+ ("syncFootnote", "Items under the limit are pushed to your other devices as you copy. Larger ones sync as a record; pull them from History when you need them, so big files don't waste bandwidth or disk space.", "小于阈值的内容在复制时直接推送到其他设备;超过阈值的只同步一条记录,需要时在「复制记录」里点「拉取到本机」,避免大文件无谓地占用带宽和磁盘。", "上限より小さい内容はコピーした時点で他のデバイスに送られます。大きいものは記録だけを同期し、必要なときに「履歴」から取り込むので、帯域やディスクを無駄に使いません。"),
+ ("autoSyncLimit", "Auto-sync limit", "自动同步上限", "自動同期の上限"),
+ ("autoSyncLimitDesc", "Larger files are pulled by hand", "超过这个大小的文件改为手动拉取", "これより大きいファイルは手動で取り込みます"),
+ ("autoApply", "Put received items on the clipboard", "收到后直接写入剪贴板", "受け取った内容をクリップボードに入れる"),
+ ("autoApplyDesc", "When off, put them on the clipboard from History yourself", "关闭后,需要在「复制记录」里手动放入剪贴板", "オフの場合は「履歴」から手動でクリップボードに入れます"),
+ ("whatToSync", "What to sync", "同步哪些内容", "同期する内容"),
+ ("syncFiles", "Files and folders", "文件与文件夹", "ファイルとフォルダ"),
+ ("syncText", "Plain text", "纯文本", "プレーンテキスト"),
+ ("syncRich", "Rich text", "带格式的文本", "書式付きテキスト"),
+ ("syncImages", "Images and screenshots", "图片与截图", "画像とスクリーンショット"),
+ ("storage", "Storage", "存储", "ストレージ"),
+ ("storageFootnote", "Expired items and cached files are cleaned up automatically.", "到期的记录与缓存文件会被自动清理。", "期限切れの履歴とキャッシュは自動で削除されます。"),
+ ("keepHistory", "Keep history for", "记录保留", "履歴の保存期間"),
+ ("keepCache", "Keep cached files for", "缓存文件保留", "キャッシュの保存期間"),
+ ("keepCacheDesc", "Never longer than the history", "不会超过记录的保留时长", "履歴の保存期間を超えません"),
+ ("cacheUsage", "Cache size", "缓存占用", "キャッシュ容量"),
+ ("backgroundSync", "Background sync", "后台同步", "バックグラウンド同期"),
+ ("backgroundFootnote", "When off, nothing syncs and CopySync doesn't start at login. History and pairings are kept; open the app to turn it back on.", "停用后不再同步,也不会开机启动。历史记录与配对关系会保留,重新打开 App 即可再次启用。", "オフにすると同期せず、ログイン時にも起動しません。履歴とペアリングは残り、アプリを開けば再び有効にできます。"),
+ ("backgroundService", "Background service", "后台服务", "バックグラウンドサービス"),
+ ("backgroundServiceDesc", "Starts at login and keeps syncing with the window closed", "随系统登录自动启动,关掉窗口也照常同步", "ログイン時に起動し、ウィンドウを閉じても同期を続けます"),
+ ("restart", "Restart", "重新启动", "再起動"),
+ ("restarted", "Background service restarted", "后台服务已重新启动", "バックグラウンドサービスを再起動しました"),
+ ("disableEllipsis", "Turn off…", "停用…", "オフにする…"),
+ ("about", "About", "关于", "このアプリについて"),
+ ("aboutDesc", "Open source, MIT License", "开源软件,MIT 许可", "オープンソース(MIT ライセンス)"),
+ ("homepage", "Website", "项目主页", "ウェブサイト"),
+ ("feedback", "Report a problem", "反馈问题", "問題を報告"),
+ ("disableTitle", "Turn off background sync?", "停用后台同步?", "バックグラウンド同期をオフにしますか?"),
+ ("disableBody", "CopySync on {device} will stop syncing and won't start at login. History and pairings are kept.", "{device}将停止同步,也不再开机启动。历史记录和配对关系会保留。", "{device}は同期を停止し、ログイン時にも起動しなくなります。履歴とペアリングは残ります。"),
+ ("disable", "Turn off", "停用", "オフにする"),
+ ("disabled", "Background sync is off", "后台同步已停用", "バックグラウンド同期をオフにしました"),
+ ("urlMustBeWs", "The address must start with ws:// or wss://", "地址需以 ws:// 或 wss:// 开头", "アドレスは ws:// または wss:// で始めてください"),
+ ("serverUpdated", "Server updated. Reconnecting…", "服务器地址已更新,正在重连", "サーバーを更新しました。再接続しています…"),
+ ("deviceNameUpdated", "Device name updated", "设备名称已更新", "デバイス名を更新しました"),
+
+ # ── 启用后台服务的引导页 ──
+ ("svcExtractTitle", "Install or extract CopySync first", "先解压或安装 CopySync", "先に CopySync をインストールまたは展開してください"),
+ ("svcExtractBody", "CopySync is running straight from the zip, and its temporary folder disappears when you close it. Run the installer, or extract the whole folder and open it from there, to turn on background sync.", "CopySync 现在是直接从压缩包里打开的,关掉之后它所在的临时文件夹就会被删除。运行安装程序,或者把整个文件夹解压出来再打开,就可以启用后台同步。", "CopySync は zip から直接開かれていて、閉じると一時フォルダごと消えます。インストーラーを実行するか、フォルダ全体を展開してから開くと、バックグラウンド同期を有効にできます。"),
+ ("svcMoveTitle", "Move CopySync to Applications first", "先把 CopySync 移到「应用程序」", "先に CopySync を「アプリケーション」に移動してください"),
+ ("svcMoveBody", "CopySync is running straight from the disk image. Drag it into Applications, eject the disk image, and open it from Applications to turn on background sync.", "CopySync 现在是直接从安装盘里打开的。把它拖进「应用程序」文件夹,推出安装盘,再从「应用程序」里打开,就可以启用后台同步。", "CopySync はディスクイメージから直接開かれています。「アプリケーション」にドラッグしてディスクイメージを取り出し、「アプリケーション」から開くと、バックグラウンド同期を有効にできます。"),
+ ("svcStartTitle", "Get started with CopySync", "开始使用 CopySync", "CopySync を始める"),
+ ("svcStartBody", "CopySync runs a small background process that notices clipboard changes and stays connected to your other devices. Once on, it starts at login and keeps syncing even with this window closed.", "CopySync 会在后台运行一个小进程,用来感知剪贴板的变化,并与你的其他设备保持连接。启用后它随系统登录自动启动,关掉这个窗口也会照常同步。", "CopySync は小さなバックグラウンドプロセスを動かし、クリップボードの変化を検知して他のデバイスとつながり続けます。有効にするとログイン時に起動し、このウィンドウを閉じても同期を続けます。"),
+ ("svcEnable", "Turn on background sync", "启用后台同步", "バックグラウンド同期を有効にする"),
+ ("svcStaleTitle", "Turn background sync on again", "重新启用后台同步", "バックグラウンド同期をもう一度有効にする"),
+ ("svcStaleBodyWin", "CopySync has moved, but starting at login still points to the old place. Turn it on again so the background process uses this copy. History and pairings are kept.", "CopySync 换了位置,开机自启还指向原来的地方。重新启用一次,让后台进程指向当前这份 CopySync。历史记录与配对关系都会保留。", "CopySync の場所が変わりましたが、自動起動は以前の場所を指しています。もう一度有効にすると、このコピーを使うようになります。履歴とペアリングは残ります。"),
+ ("svcStaleBodyMac", "CopySync has moved, or was installed with an old script. Turn it on again so the background process uses this app. History and pairings are kept.", "CopySync 换了位置,或者之前用旧版安装脚本装过。重新启用一次,让后台进程指向当前这个 App。历史记录与配对关系都会保留。", "CopySync の場所が変わったか、古いスクリプトでインストールされています。もう一度有効にすると、このアプリを使うようになります。履歴とペアリングは残ります。"),
+ ("svcReenable", "Turn on again", "重新启用", "もう一度有効にする"),
+ ("svcStoppedTitle", "The background service isn't running", "后台服务没有运行", "バックグラウンドサービスが動いていません"),
+ ("svcStoppedBody", "It may have just quit; the system usually restarts it within seconds. If you stay on this page, restart it with the button below.", "它可能刚刚退出,系统通常会在几秒内把它重新拉起。如果一直停在这一页,点下面的按钮重新启动。", "終了した直後かもしれません。通常は数秒で再起動されます。この画面のままなら、下のボタンで再起動してください。"),
+ ("svcDevBodyWin", "This is a development build with no copysyncd.exe next to it. Run scripts\\build-windows.ps1 in the source folder to build a complete version.", "这是开发构建,旁边没有 copysyncd.exe。在源码目录运行 scripts\\build-windows.ps1 构建完整的版本。", "開発ビルドのため copysyncd.exe がありません。ソースフォルダで scripts\\build-windows.ps1 を実行して完全版をビルドしてください。"),
+ ("svcDevBodyMac", "This is a development build without the background service. Run ./scripts/install-macos.sh in the source folder to install it.", "这是开发构建,App 里没有内置后台服务。在源码目录运行 ./scripts/install-macos.sh 安装它。", "開発ビルドのためバックグラウンドサービスが含まれていません。ソースフォルダで ./scripts/install-macos.sh を実行してインストールしてください。"),
+ ("svcLogPath", "Log: {path}", "运行日志:{path}", "ログ:{path}"),
+ ("svcCanDisable", "You can turn background sync off anytime in Settings.", "随时可以在「设置」中停用后台同步。", "バックグラウンド同期は「設定」でいつでもオフにできます。"),
+]
+
+# 数字类占位符的类型;其余都是字符串
+INTS = {"count", "n", "paired", "online", "others", "month", "day"}
+
+
+def placeholders(text: str) -> list[str]:
+ # 只取最外层的 {name} 与 {name, plural, …};plural 分支里的 =1{Yesterday} 不是占位符
+ names, depth = [], 0
+ for i, ch in enumerate(text):
+ if ch == "{":
+ if depth == 0:
+ m = re.match(r"\{(\w+)\s*[,}]", text[i:])
+ if m and m.group(1) not in names:
+ names.append(m.group(1))
+ depth += 1
+ elif ch == "}":
+ depth -= 1
+ return names
+
+
+def main() -> None:
+ out = Path(__file__).resolve().parents[2] / "lib" / "l10n"
+ out.mkdir(parents=True, exist_ok=True)
+ keys = [k for k, *_ in S]
+ dupes = {k for k in keys if keys.count(k) > 1}
+ assert not dupes, f"重复的键:{dupes}"
+
+ en = {"@@locale": "en"}
+ for key, text, zh, ja in S:
+ names = placeholders(text) or placeholders(zh)
+ for other in (zh, ja):
+ names += [n for n in placeholders(other) if n not in names]
+ en[key] = text
+ if names:
+ en["@" + key] = {
+ "placeholders": {n: {"type": "int" if n in INTS else "String"} for n in names}
+ }
+ for locale, index in (("zh", 2), ("ja", 3)):
+ data = {"@@locale": locale}
+ for row in S:
+ data[row[0]] = row[index]
+ (out / f"app_{locale}.arb").write_text(json.dumps(data, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
+ (out / "app_en.arb").write_text(json.dumps(en, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
+ print(f"✓ {len(S)} 条,写入 {out}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/ui/tool/screenshots/screenshots_test.dart b/ui/tool/screenshots/screenshots_test.dart
index 5a6c690..8c52389 100644
--- a/ui/tool/screenshots/screenshots_test.dart
+++ b/ui/tool/screenshots/screenshots_test.dart
@@ -11,6 +11,7 @@ import 'dart:ui' show ImageByteFormat;
import 'package:copysync_ui/app_state.dart';
import 'package:copysync_ui/background_service.dart';
import 'package:copysync_ui/gen/copysync/v1/daemon.pb.dart';
+import 'package:copysync_ui/i18n.dart';
import 'package:copysync_ui/main.dart';
import 'package:copysync_ui/theme.dart';
import 'package:copysync_ui/widgets/pairing_dialog.dart';
@@ -22,6 +23,11 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
+/// 截图的界面语言:zh 或 en,由 render.sh 设置。演示数据里的文件名、文字也跟着换。
+final _lang = Platform.environment['SCREENSHOT_LANG'] ?? 'zh';
+final _locale = Locale(_lang);
+String _t(String zh, String en) => _lang == 'en' ? en : zh;
+
/// 生成配对码不走后台服务,直接给一个固定值。
class _DemoState extends AppState {
@override
@@ -76,6 +82,7 @@ ClipRecord _clip(
);
const _mb = 1024 * 1024;
+final _quarterly = _t('季度汇报-终版.key', 'Q3 review - final.key');
AppState _demo({LinkState link = LinkState.online,
ServiceState? service, Device? pending, bool empty = false}) {
@@ -85,7 +92,7 @@ AppState _demo({LinkState link = LinkState.online,
serviceState: service,
pendingPairing: pending,
status: Status(
- version: '1.0.0',
+ version: '1.3.0',
deviceName: 'MacBook Pro',
signalingConnected: link == LinkState.online,
clipboardPermission: ClipboardPermission.CLIPBOARD_PERMISSION_ALWAYS_ALLOW,
@@ -129,17 +136,18 @@ AppState _demo({LinkState link = LinkState.online,
preview: 'git push origin release/1.0 && gh release create v1.0.0',
outgoing: true, size: 54, ago: const Duration(seconds: 4)),
_clip('2', ClipKind.CLIP_KIND_IMAGE,
- preview: '图片 2.4 MB', size: (2.4 * _mb).round(), ago: const Duration(minutes: 2),
+ preview: _t('图片 2.4 MB', 'Image 2.4 MB'), size: (2.4 * _mb).round(), ago: const Duration(minutes: 2),
items: [ClipItem(name: 'image.png', size: Int64((2.4 * _mb).round()))]),
_clip('3', ClipKind.CLIP_KIND_FILE,
size: (38.2 * _mb).round(), ago: const Duration(minutes: 9),
- items: [ClipItem(name: '季度汇报-终版.key', size: Int64((38.2 * _mb).round()))]),
+ items: [ClipItem(name: _quarterly, size: Int64((38.2 * _mb).round()))]),
_clip('4', ClipKind.CLIP_KIND_FILE,
size: (1.3 * 1024 * _mb).round(), ago: const Duration(minutes: 14),
from: 'Mac mini', status: ClipStatus.CLIP_STATUS_REMOTE_ONLY,
- items: [ClipItem(name: '发布演示录屏.mov', size: Int64((1.3 * 1024 * _mb).round()))]),
+ items: [ClipItem(name: _t('发布演示录屏.mov', 'launch-demo.mov'), size: Int64((1.3 * 1024 * _mb).round()))]),
_clip('5', ClipKind.CLIP_KIND_HTML,
- preview: '会议结论:周二灰度 10%,观察两天没问题周四全量;回滚预案见文档第 3 节',
+ preview: _t('会议结论:周二灰度 10%,观察两天没问题周四全量;回滚预案见文档第 3 节',
+ 'Decision: ship to 10% on Tuesday, everyone on Thursday if two days look clean. Rollback plan in section 3'),
from: 'Mac mini', size: 2310, ago: const Duration(minutes: 26)),
_clip('6', ClipKind.CLIP_KIND_FILE,
outgoing: true, size: 126 * _mb, ago: const Duration(minutes: 41),
@@ -147,7 +155,7 @@ AppState _demo({LinkState link = LinkState.online,
_clip('7', ClipKind.CLIP_KIND_FILE,
size: (18.6 * _mb).round(), ago: const Duration(hours: 1),
status: ClipStatus.CLIP_STATUS_FETCHING,
- items: [ClipItem(name: '合同扫描件.pdf', size: Int64((18.6 * _mb).round()))]),
+ items: [ClipItem(name: _t('合同扫描件.pdf', 'signed-contract.pdf'), size: Int64((18.6 * _mb).round()))]),
_clip('8', ClipKind.CLIP_KIND_TEXT,
preview: 'https://github.com/baiyuze/copysync/releases', outgoing: true, size: 44,
ago: const Duration(hours: 3)),
@@ -159,7 +167,7 @@ AppState _demo({LinkState link = LinkState.online,
ClipItem(name: 'IMG_2043.HEIC', size: Int64((1.4 * _mb).round())),
]),
_clip('10', ClipKind.CLIP_KIND_IMAGE,
- preview: '图片 864 KB', outgoing: true, size: 864 * 1024, ago: const Duration(days: 1),
+ preview: _t('图片 864 KB', 'Image 864 KB'), outgoing: true, size: 864 * 1024, ago: const Duration(days: 1),
items: [ClipItem(name: 'image.png', size: Int64(864 * 1024))]),
],
);
@@ -212,6 +220,9 @@ Future<void> _render(
child: MaterialApp(
debugShowCheckedModeBanner: false,
theme: theme,
+ locale: _locale,
+ supportedLocales: supportedLocales,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
home: Shell(initialSection: section),
),
),
@@ -245,6 +256,7 @@ Future<void> _capture(WidgetTester tester, String name) async {
void main() {
setUpAll(() async {
TestWidgetsFlutterBinding.ensureInitialized();
+ appL10n = lookupAppLocalizations(_locale);
await _loadFonts();
});
@@ -254,7 +266,7 @@ void main() {
final mouse = await tester.createGesture(kind: PointerDeviceKind.mouse);
await mouse.addPointer(location: Offset.zero);
addTearDown(mouse.removePointer);
- await mouse.moveTo(tester.getCenter(find.text('季度汇报-终版.key')));
+ await mouse.moveTo(tester.getCenter(find.text(_quarterly)));
await tester.pump();
});
});
@@ -313,6 +325,9 @@ void main() {
child: MaterialApp(
debugShowCheckedModeBanner: false,
theme: buildTheme(brightness, fontFamily: 'SF', fontFamilyFallback: const ['PingFang']),
+ locale: _locale,
+ supportedLocales: supportedLocales,
+ localizationsDelegates: AppLocalizations.localizationsDelegates,
home: Scaffold(
backgroundColor: Colors.transparent,
body: Center(