feat: English and Chinese, and selectable chat text
- settings → general → language picks system, Chinese or English; the choice is stored on the device and read before the first frame - our Chinese strings are translated through tr()/trArgs() and AppText, with the English in lib/l10n/en_*.dart; a missing entry falls back to Chinese and a test checks that every literal in lib has one - AppText rebuilds on a language change (it depends on the resolved locale), so const text and whole pages switch at once; the built-in date/time pickers and selection menu follow the same language - server and user data (titles, messages, prompts, paths) is never translated - the chat list sits in a SelectionArea: long-press selects message text and shows the copy/select-all menu - bump to 0.5.2
This commit is contained in:
1 parent
da4bfb6826
commit
7b5bccf28f
42 files changed
+1943
-735
No files matched your search
@@ -8,6 +8,7 @@ import 'package:xterm/xterm.dart';
|
||||
import '../api/terminal.dart';
|
||||
import '../state.dart';
|
||||
import '../terminal_state.dart';
|
||||
import '../l10n.dart';
|
||||
|
||||
/// A light palette, so the terminal does not turn into a black hole in the
|
||||
/// light theme. (xterm ships only dark ones.)
|
||||
@@ -120,19 +121,20 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
ThemeData theme, TerminalTab tab, TerminalSessionState state) {
|
||||
final scheme = theme.colorScheme;
|
||||
final (label, color) = switch (state.link) {
|
||||
TerminalLinkState.idle => ('未启动', theme.hintColor),
|
||||
TerminalLinkState.creating => ('正在创建…', theme.hintColor),
|
||||
TerminalLinkState.connecting => ('正在连接…', theme.hintColor),
|
||||
TerminalLinkState.reconnecting => ('连接中断,正在重连…', scheme.error),
|
||||
TerminalLinkState.open => ('运行中', scheme.primary),
|
||||
TerminalLinkState.exited => (state.detail ?? '已退出', theme.hintColor),
|
||||
TerminalLinkState.error => (state.detail ?? '连接失败', scheme.error),
|
||||
TerminalLinkState.idle => (tr('未启动'), theme.hintColor),
|
||||
TerminalLinkState.creating => (tr('正在创建…'), theme.hintColor),
|
||||
TerminalLinkState.connecting => (tr('正在连接…'), theme.hintColor),
|
||||
TerminalLinkState.reconnecting =>
|
||||
(tr('连接中断,正在重连…'), scheme.error),
|
||||
TerminalLinkState.open => (tr('运行中'), scheme.primary),
|
||||
TerminalLinkState.exited => (state.detail ?? tr('已退出'), theme.hintColor),
|
||||
TerminalLinkState.error => (state.detail ?? tr('连接失败'), scheme.error),
|
||||
};
|
||||
return Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: PopupMenuButton<int>(
|
||||
tooltip: '切换终端',
|
||||
tooltip: tr('切换终端'),
|
||||
position: PopupMenuPosition.under,
|
||||
onSelected: _onTabMenu,
|
||||
itemBuilder: (_) => [
|
||||
@@ -152,7 +154,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Text(
|
||||
child: AppText(
|
||||
_workspace.tabs[i].label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -168,7 +170,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
children: [
|
||||
Icon(Icons.add, size: 18),
|
||||
SizedBox(width: 10),
|
||||
Text('新建终端'),
|
||||
AppText('新建终端'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -181,7 +183,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
Icon(Icons.circle, size: 8, color: color),
|
||||
const SizedBox(width: 6),
|
||||
Flexible(
|
||||
child: Text(
|
||||
child: AppText(
|
||||
tab.label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -191,7 +193,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
),
|
||||
const SizedBox(width: 4),
|
||||
Flexible(
|
||||
child: Text(
|
||||
child: AppText(
|
||||
'· $label',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
@@ -205,13 +207,13 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '键盘',
|
||||
tooltip: tr('键盘'),
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: const Icon(Icons.keyboard_outlined, size: 18),
|
||||
onPressed: () => _focus.requestFocus(),
|
||||
),
|
||||
IconButton(
|
||||
tooltip: '重新启动',
|
||||
tooltip: tr('重新启动'),
|
||||
visualDensity: VisualDensity.compact,
|
||||
icon: const Icon(Icons.restart_alt, size: 18),
|
||||
onPressed: state.link == TerminalLinkState.exited ||
|
||||
@@ -221,7 +223,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
: null,
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
tooltip: '更多',
|
||||
tooltip: tr('更多'),
|
||||
icon: const Icon(Icons.more_vert, size: 18),
|
||||
onSelected: (value) {
|
||||
switch (value) {
|
||||
@@ -234,8 +236,8 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
}
|
||||
},
|
||||
itemBuilder: (_) => const [
|
||||
PopupMenuItem(value: 'clear', child: Text('清屏')),
|
||||
PopupMenuItem(value: 'close', child: Text('关闭此终端')),
|
||||
PopupMenuItem(value: 'clear', child: AppText('清屏')),
|
||||
PopupMenuItem(value: 'close', child: AppText('关闭此终端')),
|
||||
],
|
||||
),
|
||||
],
|
||||
@@ -334,7 +336,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
border: Border.all(
|
||||
color: active ? scheme.primary : Colors.transparent, width: 1),
|
||||
),
|
||||
child: Text(
|
||||
child: AppText(
|
||||
label,
|
||||
maxLines: 1,
|
||||
style: TextStyle(
|
||||
@@ -353,4 +355,4 @@ class _TerminalPanelState extends State<TerminalPanel> {
|
||||
|
||||
void _sendText(TerminalSessionState state, String text) =>
|
||||
state.model.textInput(text);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user