feat: write the UI in English, select only conversation content

- source strings are English again; Chinese comes from lib/l10n/zh.dart
  through tr()/trArgs() and AppText, and a language without a table
  (Spanish, ...) reads English instead of Chinese
- server and user data (titles, messages, file names, notes, task names)
  is drawn with plain Text, so it is never looked up in the table
- SelectionArea moved from the whole message list to the messages, the
  answer text, an opened tool call's details and the turn footer; status
  lines and folded tool rows no longer start a selection
- a message the transcript does not know (its start event was lost while
  the stream was down) fetches the tail once, so a turn continued from
  another client comes in with its prompt
- bump to 0.5.3
This commit is contained in:
blumia committed 2026-11-26 11:48:16 +08:00
1 parent 7b5bccf28f
commit 511c3b006b
43 files changed
+1620 -1791

No files matched your search

+167 -156
View File
@@ -203,7 +203,7 @@ class _ChatScreenState extends State<ChatScreen> {
/// What a finished command's output reads as: the report, or that the user
/// stopped it (the report itself is a `Shell.NotFoundError` then).
String _completionText(String shellId, ShellCompletionNote completion) =>
shellWasStopped(chat.msgs, shellId) ? tr('用户停止了这条命令。') : completion.output;
shellWasStopped(chat.msgs, shellId) ? tr('You stopped this command.') : completion.output;
Future<void> _stopShell(ShellTask task) async {
final shells = _shells;
@@ -213,7 +213,7 @@ class _ChatScreenState extends State<ChatScreen> {
} on ApiError catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: AppText(trArgs('停止失败:{0}', [e.message]))));
.showSnackBar(SnackBar(content: AppText(trArgs('Could not stop: {0}', [e.message]))));
}
}
@@ -258,8 +258,8 @@ class _ChatScreenState extends State<ChatScreen> {
Expanded(
child: AppText(
operator
? '此会话由 Lead 管理,接管后才能继续。'
: '无法向子智能体会话发送提示。',
? 'This session is managed by a Lead; take it over to continue.'
: 'Cannot send prompts to a subagent session.',
style: TextStyle(
fontSize: 12.5, color: scheme.onSurfaceVariant),
),
@@ -290,14 +290,14 @@ class _ChatScreenState extends State<ChatScreen> {
leading: parent != null
? IconButton(
icon: const Icon(Icons.arrow_back),
tooltip: tr('返回父会话'),
tooltip: tr('Back to parent session'),
onPressed: () => widget.app.openChat(parent),
)
: widget.onOpenSessions == null
? null
: IconButton(
icon: const Icon(Icons.menu),
tooltip: tr('会话'),
tooltip: tr('Sessions'),
onPressed: widget.onOpenSessions,
),
title: Row(
@@ -308,7 +308,7 @@ class _ChatScreenState extends State<ChatScreen> {
const SizedBox(width: 6),
],
Expanded(
child: AppText(_title(),
child: Text(_title(),
maxLines: 1, overflow: TextOverflow.ellipsis),
),
],
@@ -316,7 +316,7 @@ class _ChatScreenState extends State<ChatScreen> {
actions: [
IconButton(
icon: const Icon(Icons.view_sidebar_outlined),
tooltip: tr('文件'),
tooltip: tr('Files'),
onPressed: () => showFilesPanel(context, widget.app, chat.dir),
),
],
@@ -330,10 +330,10 @@ class _ChatScreenState extends State<ChatScreen> {
child: Row(
children: [
Expanded(
child: AppText(chat.error!,
child: Text(chat.error!,
style: TextStyle(
color: theme.colorScheme.onErrorContainer, fontSize: 13))),
TextButton(onPressed: chat.load, child: const AppText('重试')),
TextButton(onPressed: chat.load, child: const AppText('Retry')),
],
),
),
@@ -372,36 +372,35 @@ class _ChatScreenState extends State<ChatScreen> {
}
final rows = _rows();
final olderSlot = chat.hasMore || chat.loadingOlder ? 1 : 0;
// Long-press selects the conversation's text: the rendered Markdown used
// to be plain text, so only the few SelectableText widgets could be
// selected. The selection toolbar follows the UI language.
return SelectionArea(
child: ListView.builder(
controller: _scroll,
reverse: true,
itemCount: rows.length + olderSlot,
itemBuilder: (context, i) {
// i counts from the newest row up.
if (i < rows.length) return _row(rows[rows.length - 1 - i]);
if (chat.loadingOlder) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: Center(
child: SizedBox(
width: 22,
height: 22,
child: CircularProgressIndicator(strokeWidth: 2)),
),
);
}
return Center(
child: TextButton(
onPressed: _loadOlder,
child: const AppText('载入更早的消息'),
// Only the conversation itself is selectable: each message bubble, the
// answer text, an opened tool call's details and the turn's model line.
// Status lines and folded tool rows stay plain, so a long-press there does
// not start a selection.
return ListView.builder(
controller: _scroll,
reverse: true,
itemCount: rows.length + olderSlot,
itemBuilder: (context, i) {
// i counts from the newest row up.
if (i < rows.length) return _row(rows[rows.length - 1 - i]);
if (chat.loadingOlder) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 12),
child: Center(
child: SizedBox(
width: 22,
height: 22,
child: CircularProgressIndicator(strokeWidth: 2)),
),
);
},
),
}
return Center(
child: TextButton(
onPressed: _loadOlder,
child: const AppText('Load earlier messages'),
),
);
},
);
}
@@ -599,7 +598,7 @@ class _ChatScreenState extends State<ChatScreen> {
case 'thinking':
return const Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 6),
child: AppText('正在思考…', style: TextStyle(color: Colors.grey, fontSize: 13)),
child: AppText('Thinking…', style: TextStyle(color: Colors.grey, fontSize: 13)),
);
case 'text':
return _textRow(r.msgId, r.part);
@@ -618,7 +617,7 @@ class _ChatScreenState extends State<ChatScreen> {
case 'shell':
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: AppText(chat.byId[r.msgId]?.text ?? '',
child: Text(chat.byId[r.msgId]?.text ?? '',
style: const TextStyle(color: Colors.grey, fontSize: 13)),
);
default:
@@ -634,7 +633,7 @@ class _ChatScreenState extends State<ChatScreen> {
return session.title;
}
}
return widget.session.title.isEmpty ? '会话' : widget.session.title;
return widget.session.title.isEmpty ? 'Sessions' : widget.session.title;
}
/// A prompt in the server's inbox: dimmer than a sent message, with the
@@ -663,12 +662,14 @@ class _ChatScreenState extends State<ChatScreen> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (item.text.isNotEmpty)
AppText(item.text,
style: TextStyle(color: scheme.onPrimary)),
SelectionArea(
child: Text(item.text,
style: TextStyle(color: scheme.onPrimary)),
),
if (item.files.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 4),
child: AppText(trArgs('📎 {0} 个附件', [item.files.length]),
child: AppText(trArgs('📎 {0} attachments', [item.files.length]),
style: TextStyle(
color: scheme.onPrimary, fontSize: 12.5)),
),
@@ -686,17 +687,17 @@ class _ChatScreenState extends State<ChatScreen> {
const SizedBox(width: 3),
AppText(
!chat.running
? '未发送'
? 'Not sent'
: steering
? '正在转入当前回合…'
: '已排队,本轮结束后发送',
? 'Joining this turn…'
: 'Queued; sends after this turn',
style: TextStyle(fontSize: 12, color: theme.hintColor),
),
const SizedBox(width: 4),
TextButton(
onPressed: () => chat.changeInboxDelivery(
item.id, steering ? 'queue' : 'steer'),
child: AppText(steering ? '改为排队' : '转为转向',
child: AppText(steering ? 'Queue instead' : 'Steer instead',
style: const TextStyle(fontSize: 12.5)),
),
TextButton(
@@ -708,7 +709,7 @@ class _ChatScreenState extends State<ChatScreen> {
offset: _draftCtrl.text.length);
_inputFocus.requestFocus();
},
child: const AppText('撤回',
child: const AppText('Withdraw',
style: TextStyle(fontSize: 12.5)),
),
],
@@ -743,7 +744,10 @@ class _ChatScreenState extends State<ChatScreen> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (m.text.isNotEmpty)
AppText(m.text, style: TextStyle(color: theme.colorScheme.onPrimary)),
SelectionArea(
child: Text(m.text,
style: TextStyle(color: theme.colorScheme.onPrimary)),
),
for (final i in attachedImages)
Padding(
padding: const EdgeInsets.only(top: 6),
@@ -776,7 +780,7 @@ class _ChatScreenState extends State<ChatScreen> {
color: theme.colorScheme.onPrimary.withValues(alpha: 0.14),
borderRadius: BorderRadius.circular(8),
),
child: AppText('📎 ${f.name.isEmpty ? tr('附件') : f.name}',
child: AppText('📎 ${f.name.isEmpty ? tr('Attachments') : f.name}',
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -798,7 +802,7 @@ class _ChatScreenState extends State<ChatScreen> {
_userImages[key] = bytes;
} catch (_) {
return const SizedBox(
width: 200, height: 60, child: Center(child: AppText('图片无法显示')));
width: 200, height: 60, child: Center(child: AppText('Cannot display image')));
}
}
return Image.memory(bytes, width: 200, height: 150, fit: BoxFit.cover);
@@ -806,7 +810,7 @@ class _ChatScreenState extends State<ChatScreen> {
void _previewAttachment(FileAttachment f) {
_showImageDialog(
f.name.isEmpty ? '图片' : f.name,
f.name.isEmpty ? 'Image' : f.name,
source: 'data:${f.mime};base64,${f.data}',
);
}
@@ -823,18 +827,18 @@ class _ChatScreenState extends State<ChatScreen> {
if (stamp.isNotEmpty)
Padding(
padding: const EdgeInsets.only(right: 8),
child: AppText(stamp, style: const TextStyle(color: Colors.grey, fontSize: 12)),
child: Text(stamp, style: const TextStyle(color: Colors.grey, fontSize: 12)),
),
TextButton(
onPressed: () => _copyText(m.text),
child: const AppText('复制'),
child: const AppText('Copy'),
),
PopupMenuButton<String>(
onSelected: (v) => _userAction(v, m),
itemBuilder: (_) => const [
PopupMenuItem(value: 'copy', child: AppText('复制消息')),
PopupMenuItem(value: 'revert', child: AppText('撤回此消息及之后')),
PopupMenuItem(value: 'fork', child: AppText('从这里分叉')),
PopupMenuItem(value: 'copy', child: AppText('Copy message')),
PopupMenuItem(value: 'revert', child: AppText('Withdraw this and later messages')),
PopupMenuItem(value: 'fork', child: AppText('Fork from here')),
],
),
],
@@ -848,9 +852,9 @@ class _ChatScreenState extends State<ChatScreen> {
break;
case 'revert':
_confirm(
title: '撤回消息?',
message: '这条消息及其之后的内容会从会话中删除,且无法恢复。',
confirm: '撤回',
title: 'Withdraw message?',
message: 'This message and everything after it will be removed from the session and cannot be recovered.',
confirm: 'Withdraw',
onConfirm: () => chat.revert(m.id),
);
break;
@@ -865,7 +869,7 @@ class _ChatScreenState extends State<ChatScreen> {
if (part < 0 || part >= m.content.length) return const SizedBox.shrink();
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 2),
child: MarkdownView(m.content[part].text),
child: SelectionArea(child: MarkdownView(m.content[part].text)),
);
}
@@ -939,12 +943,12 @@ class _ChatScreenState extends State<ChatScreen> {
final theme = Theme.of(context);
final tools = steps.where((s) => s.part.type == 'tool').length;
final label = tools == 0
? (running ? '思考中…' : '思考过程')
? (running ? 'Thinking…' : 'Thought process')
: failed
? trArgs('有步骤失败 · {0} 次工具调用', [tools])
? trArgs('A step failed · {0} tool calls', [tools])
: running
? trArgs('执行中 · {0} 次工具调用', [tools])
: trArgs('已完成 · {0} 次工具调用', [tools]);
? trArgs('Running · {0} tool calls', [tools])
: trArgs('Done · {0} tool calls', [tools]);
return GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => _toggleGroup(id, start, collapsed),
@@ -963,7 +967,7 @@ class _ChatScreenState extends State<ChatScreen> {
color: failed ? theme.colorScheme.error : theme.hintColor),
const SizedBox(width: 8),
Expanded(
child: AppText(label,
child: Text(label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 13, color: theme.hintColor)),
@@ -1054,7 +1058,7 @@ class _ChatScreenState extends State<ChatScreen> {
: theme.colorScheme.onSurfaceVariant),
),
const SizedBox(width: 10),
AppText(label,
Text(label,
style: TextStyle(
fontSize: 13.5, color: theme.colorScheme.onSurface)),
if (summary.isEmpty)
@@ -1064,7 +1068,7 @@ class _ChatScreenState extends State<ChatScreen> {
AppText('·', style: TextStyle(fontSize: 13, color: theme.hintColor)),
const SizedBox(width: 6),
Expanded(
child: AppText(summary,
child: Text(summary,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -1093,7 +1097,7 @@ class _ChatScreenState extends State<ChatScreen> {
.withValues(alpha: 0.12),
borderRadius: BorderRadius.circular(6),
),
child: AppText('后台',
child: AppText('Background',
style: TextStyle(
fontSize: 11,
color: theme.colorScheme.primary)),
@@ -1122,7 +1126,7 @@ class _ChatScreenState extends State<ChatScreen> {
const AppText('🖼', style: TextStyle(fontSize: 12)),
const SizedBox(width: 6),
Flexible(
child: AppText(ref.label,
child: Text(ref.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -1136,7 +1140,12 @@ class _ChatScreenState extends State<ChatScreen> {
_Reveal(
open: open,
onGrow: _grow,
child: _stepDetails(p, reasoning, diffFiles, shellId, m.created),
// An opened call shows its command, arguments and output; those
// are conversation text like the answer is.
child: SelectionArea(
child:
_stepDetails(p, reasoning, diffFiles, shellId, m.created),
),
),
],
),
@@ -1181,7 +1190,7 @@ class _ChatScreenState extends State<ChatScreen> {
final ok = await widget.app.openSubagent(id);
if (ok || !mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: AppText(widget.app.lastError ?? '无法打开子代理会话')),
SnackBar(content: AppText(widget.app.lastError ?? 'Cannot open the subagent session')),
);
widget.app.clearLastError();
}
@@ -1294,23 +1303,23 @@ class _ChatScreenState extends State<ChatScreen> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (command.isNotEmpty)
SelectableText(command,
Text(command,
style: mono.copyWith(color: theme.colorScheme.onSurface)),
if (command.isNotEmpty) const SizedBox(height: 6),
for (final e in extras)
Padding(
padding: const EdgeInsets.only(bottom: 2),
child: AppText('${e.key}: ${e.value}',
child: Text('${e.key}: ${e.value}',
style: mono.copyWith(
fontSize: 11.5, color: theme.hintColor)),
),
if (extras.isNotEmpty) const SizedBox(height: 4),
SelectableText(
Text(
output.isNotEmpty
? output
: shelled
? tr('输出较大,正在载入…')
: (shell ? tr('无输出') : tr('无内容')),
? tr('Large output, loading…')
: (shell ? tr('No output') : tr('No content')),
style: mono.copyWith(
color: p.state?.error != null
? theme.colorScheme.error
@@ -1405,41 +1414,41 @@ class _ChatScreenState extends State<ChatScreen> {
}
static String _stepLabel(ContentPart p) {
if (p.type == 'reasoning') return tr('思考');
if (p.type == 'reasoning') return tr('Thinking');
switch (p.name ?? '') {
case 'bash':
case 'shell':
case 'execute':
return tr('运行');
return tr('Run');
case 'read':
return tr('读取');
return tr('Read');
case 'write':
return tr('写入');
return tr('Write');
case 'edit':
return tr('编辑');
return tr('Edit');
case 'patch':
case 'apply_patch':
return tr('补丁');
return tr('Patch');
case 'grep':
case 'glob':
case 'find':
return tr('搜索');
return tr('Search');
case 'list':
return tr('列出');
return tr('List');
case 'webfetch':
case 'web_fetch':
return tr('抓取');
return tr('Fetch');
case 'todowrite':
return tr('任务');
return tr('Task');
case 'task':
case 'subagent':
return tr('子代理');
return tr('Subagent');
case 'skill':
return tr('技能');
return tr('Skill');
case 'openchamber_image':
return tr('生成图片');
return tr('Generate image');
default:
return p.name == null || p.name!.isEmpty ? tr('工具') : p.name!;
return p.name == null || p.name!.isEmpty ? tr('Tool') : p.name!;
}
}
@@ -1505,17 +1514,19 @@ class _ChatScreenState extends State<ChatScreen> {
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: AppText(parts.join(' · '),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.grey, fontSize: 13)),
child: SelectionArea(
child: Text(parts.join(' · '),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(color: Colors.grey, fontSize: 13)),
),
),
),
PopupMenuButton<String>(
onSelected: (v) => _footerAction(v, m),
itemBuilder: (_) => const [
PopupMenuItem(value: 'copy', child: AppText('复制回答')),
PopupMenuItem(value: 'fork', child: AppText('从这里分叉')),
PopupMenuItem(value: 'copy', child: AppText('Copy answer')),
PopupMenuItem(value: 'fork', child: AppText('Fork from here')),
],
),
],
@@ -1548,27 +1559,27 @@ class _ChatScreenState extends State<ChatScreen> {
final e = m.error;
final detail = (e != null && e.message.isNotEmpty)
? e.message
: (e != null && e.type.isNotEmpty ? e.type : tr('未知错误'));
: (e != null && e.type.isNotEmpty ? e.type : tr('Unknown error'));
final type = (e?.type ?? '').toLowerCase();
final plain = detail.trim().toLowerCase().replaceFirst(RegExp(r'\.$'), '');
if (m.type == 'compaction') {
return (text: trArgs('压缩失败:{0}', [detail]), body: e?.body);
return (text: trArgs('Compaction failed: {0}', [detail]), body: e?.body);
}
if (type == 'sessionretry') {
return (text: trArgs('OpenCode 发送消息失败,正在重试:{0}', [detail]), body: e?.body);
return (text: trArgs('OpenCode could not send the message; retrying: {0}', [detail]), body: e?.body);
}
if (_isAuthError(detail)) {
return (
text: tr('模型的认证失败,请在服务端重新登录或检查 API Key。'),
text: tr('The model failed to authenticate. Sign in again on the server or check the API key.'),
body: e?.body
);
}
if (type == 'messageabortederror' ||
plain == 'aborted' ||
plain == 'step interrupted') {
return (text: tr('本轮已停止。'), body: null);
return (text: tr('This turn was stopped.'), body: null);
}
return (text: trArgs('OpenCode 发送消息失败:{0}', [detail]), body: e?.body);
return (text: trArgs('OpenCode could not send the message: {0}', [detail]), body: e?.body);
}
static String _prettyBody(String raw) {
@@ -1589,7 +1600,7 @@ class _ChatScreenState extends State<ChatScreen> {
final running = m.status == 'running';
final summary = m.summary.trim();
final open = chat.expanded.contains('compaction/$id');
final label = running ? '正在压缩对话' : '对话已压缩';
final label = running ? 'Compacting conversation' : 'Conversation compacted';
final header = GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => setState(() {
@@ -1615,7 +1626,7 @@ class _ChatScreenState extends State<ChatScreen> {
style: TextStyle(fontSize: 13, color: theme.hintColor)),
),
if (summary.isNotEmpty)
AppText(open ? '隐藏摘要' : '显示摘要',
AppText(open ? 'Hide summary' : 'Show summary',
style: TextStyle(fontSize: 12, color: scheme.primary)),
const SizedBox(width: 4),
AnimatedRotation(
@@ -1644,7 +1655,7 @@ class _ChatScreenState extends State<ChatScreen> {
borderRadius: BorderRadius.circular(8),
),
child: summary.isEmpty
? AppText(running ? '正在生成摘要…' : '(摘要为空)',
? AppText(running ? 'Generating summary…' : '(No summary)',
style: TextStyle(fontSize: 13, color: theme.hintColor))
: MarkdownView(summary, fontSize: 14),
),
@@ -1702,7 +1713,7 @@ class _ChatScreenState extends State<ChatScreen> {
onPressed: () => setState(() {
open ? chat.expanded.remove(key) : chat.expanded.add(key);
}),
child: AppText(open ? '收起详情' : '显示详情',
child: AppText(open ? 'Hide details' : 'Show details',
style: const TextStyle(fontSize: 12.5)),
),
),
@@ -1739,7 +1750,7 @@ class _ChatScreenState extends State<ChatScreen> {
/// last turn, then idle.
String _petState() {
if (chat.running) {
return _activity().title == '思考中' ? 'thinking' : 'working';
return _activity().title == 'Thinking' ? 'thinking' : 'working';
}
for (var i = chat.msgs.length - 1; i >= 0; i--) {
final m = chat.msgs[i];
@@ -1760,7 +1771,7 @@ class _ChatScreenState extends State<ChatScreen> {
final st = part.state?.status ?? '';
if (part.type == 'tool' &&
(st == 'running' || st == 'streaming' || st == 'pending')) {
return (title: trArgs('正在{0}', [_stepLabel(part)]), detail: _stepSummary(part));
return (title: trArgs('{0} in progress', [_stepLabel(part)]), detail: _stepSummary(part));
}
}
if (m.completed == 0) {
@@ -1769,12 +1780,12 @@ class _ChatScreenState extends State<ChatScreen> {
m.content.any((p) => p.type == 'text' && p.text.trim().isNotEmpty);
final reasoning = m.content
.any((p) => p.type == 'reasoning' && p.text.trim().isNotEmpty);
if (text) return (title: '正在回复', detail: '');
if (reasoning) return (title: '思考中', detail: '');
if (text) return (title: 'Replying', detail: '');
if (reasoning) return (title: 'Thinking', detail: '');
}
break;
}
return (title: '思考中', detail: '');
return (title: 'Thinking', detail: '');
}
/// The running turn started with the newest user message.
@@ -1882,7 +1893,7 @@ class _ChatScreenState extends State<ChatScreen> {
if (start <= 0) return '';
final secs = ((m.completed - start) / 1000).round();
if (secs <= 0) return '';
if (secs < 60) return trArgs('{0} 秒', [secs]);
if (secs < 60) return trArgs('{0}s', [secs]);
return '${secs ~/ 60}:${(secs % 60).toString().padLeft(2, '0')}';
}
@@ -1899,12 +1910,12 @@ class _ChatScreenState extends State<ChatScreen> {
Future<void> _copyText(String text) async {
if (text.trim().isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: AppText('没有可复制的文字')));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: AppText('Nothing to copy')));
return;
}
await Clipboard.setData(ClipboardData(text: text));
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: AppText('已复制')));
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: AppText('Copied')));
}
}
@@ -2002,7 +2013,7 @@ class _ChatScreenState extends State<ChatScreen> {
ComposerBox(
controller: _draftCtrl,
focusNode: _inputFocus,
hint: chat.running ? tr('生成中,仍可输入…') : tr('发消息…'),
hint: chat.running ? tr('Generating; you can still type…') : tr('Send a message…'),
maxLines: 5,
keyboardInset: keyboardInset,
// While the palette is up, the keyboard's action key picks the
@@ -2039,7 +2050,7 @@ class _ChatScreenState extends State<ChatScreen> {
},
leading: _roundKey(
icon: Icons.attach_file,
label: tr('添加附件'),
label: tr('Add attachment'),
onTap: _pickFiles,
busy: _attaching,
),
@@ -2080,7 +2091,7 @@ class _ChatScreenState extends State<ChatScreen> {
// something to send the key sends again, as dsh-Go's does.
trailing: _roundKey(
icon: showStop ? Icons.stop_rounded : Icons.arrow_upward_rounded,
label: showStop ? tr('停止') : tr('发送'),
label: showStop ? tr('Stop') : tr('Send'),
filled: true,
enabled: showStop || canSend,
onTap: showStop ? chat.stop : _send,
@@ -2188,13 +2199,13 @@ class _ChatScreenState extends State<ChatScreen> {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(20, 4, 20, 8),
child: AppText('发送方式',
child: AppText('Delivery',
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700)),
),
ListTile(
leading: const Icon(Icons.alt_route),
title: const AppText('转向当前回合'),
subtitle: const AppText('在下一步加入,工作继续'),
title: const AppText('Steer into this turn'),
subtitle: const AppText('Join at the next step; work continues'),
trailing: fallback == 'steer'
? Icon(Icons.check, size: 20, color: scheme.primary)
: null,
@@ -2202,8 +2213,8 @@ class _ChatScreenState extends State<ChatScreen> {
),
ListTile(
leading: const Icon(Icons.schedule),
title: const AppText('排队'),
subtitle: const AppText('等本轮结束后发送'),
title: const AppText('Queue'),
subtitle: const AppText('Send after this turn ends'),
trailing: fallback == 'queue'
? Icon(Icons.check, size: 20, color: scheme.primary)
: null,
@@ -2263,7 +2274,7 @@ class _ChatScreenState extends State<ChatScreen> {
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: AppText(trArgs('选择失败:{0}', ['$e']))));
.showSnackBar(SnackBar(content: AppText(trArgs('Could not attach: {0}', ['$e']))));
}
} finally {
if (mounted) setState(() => _attaching = false);
@@ -2296,22 +2307,22 @@ class _ChatScreenState extends State<ChatScreen> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(trArgs('请求权限: {0}', [p.action]),
AppText(trArgs('Permission requested: {0}', [p.action]),
style: const TextStyle(fontWeight: FontWeight.w600)),
AppText(p.resources.join(tr('、')),
Text(p.resources.join(', '),
style: const TextStyle(color: Colors.grey, fontSize: 13)),
const SizedBox(height: 6),
Row(
children: [
TextButton(
onPressed: () => chat.replyPermission(p.id, 'once'),
child: const AppText('允许一次')),
child: const AppText('Allow once')),
TextButton(
onPressed: () => chat.replyPermission(p.id, 'always'),
child: const AppText('总是允许')),
child: const AppText('Always allow')),
TextButton(
onPressed: () => chat.replyPermission(p.id, 'reject'),
child: const AppText('拒绝')),
child: const AppText('Deny')),
],
),
],
@@ -2331,7 +2342,7 @@ class _ChatScreenState extends State<ChatScreen> {
title: AppText(title),
content: AppText(message),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const AppText('取消')),
TextButton(onPressed: () => Navigator.pop(context), child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
@@ -2373,18 +2384,18 @@ class _ChatScreenState extends State<ChatScreen> {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const AppText('上下文占用', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
const AppText('Context usage', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)),
const SizedBox(height: 12),
_usageRow('模型', widget.app.modelName(chat.selectedModel ?? _lastModel())),
_usageRow('已用 tokens', _fmtTokens(r.$1)),
_usageRow('Model', widget.app.modelName(chat.selectedModel ?? _lastModel())),
_usageRow('Tokens used', _fmtTokens(r.$1)),
if (r.$5) ...[
_usageRow('上下文上限', _fmtTokens(r.$2)),
_usageRow('输出预留', _fmtTokens(r.$3)),
_usageRow('占用', '${r.$4.toStringAsFixed(1)}%'),
_usageRow('Context limit', _fmtTokens(r.$2)),
_usageRow('Reserved output', _fmtTokens(r.$3)),
_usageRow('Usage', '${r.$4.toStringAsFixed(1)}%'),
],
if (chat.turnCost > 0) _usageRow('本轮费用', '\$${chat.turnCost.toStringAsFixed(4)}'),
if (chat.turnCost > 0) _usageRow('Turn cost', '\$${chat.turnCost.toStringAsFixed(4)}'),
const SizedBox(height: 8),
const AppText('输出预留按最多 32K tokens 计算,与官方客户端一致。',
const AppText('Reserved output assumes at most 32K tokens, matching the official client.',
style: TextStyle(color: Colors.grey, fontSize: 12)),
],
),
@@ -2404,7 +2415,7 @@ class _ChatScreenState extends State<ChatScreen> {
child: Row(
children: [
Expanded(child: AppText(label, style: const TextStyle(color: Colors.grey))),
AppText(value),
Text(value),
],
),
);
@@ -2560,7 +2571,7 @@ List<_ImageRef> toolImages(ContentPart p, String dir) {
}
if (labels.contains(label)) return;
}
if (label.isEmpty) label = '图片';
if (label.isEmpty) label = 'Image';
seen.add(source);
labels.add(label);
out.add(_ImageRef(source, label));
@@ -2615,9 +2626,9 @@ Future<Uint8List> _imageBytesFor(
Client client, String source, String directory) async {
if (source.startsWith('data:')) {
final comma = source.indexOf(',');
if (comma < 0) throw Exception(tr('无效的 data URL'));
if (comma < 0) throw Exception(tr('Invalid data URL'));
final meta = source.substring(5, comma);
if (!meta.contains('base64')) throw Exception(tr('不支持的 data URL'));
if (!meta.contains('base64')) throw Exception(tr('Unsupported data URL'));
return base64Decode(source.substring(comma + 1));
}
final cached = _imageBytes[source];
@@ -2685,7 +2696,7 @@ class _GeneratedImageState extends State<_GeneratedImage> {
const SizedBox(width: 8),
Expanded(
child: AppText(
trArgs('图片加载失败:{0}', [pathLeaf(widget.source)]),
trArgs('Could not load image: {0}', [pathLeaf(widget.source)]),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: theme.hintColor),
@@ -2798,7 +2809,7 @@ class _ImagePreviewDialogState extends State<_ImagePreviewDialog> {
} else {
body = Padding(
padding: const EdgeInsets.all(24),
child: SelectableText(trArgs('无法预览:{0}', ['$_error']),
child: SelectableText(trArgs('Cannot preview: {0}', ['$_error']),
style: TextStyle(color: theme.colorScheme.error)),
);
}
@@ -2815,12 +2826,12 @@ class _ImagePreviewDialogState extends State<_ImagePreviewDialog> {
child: Row(
children: [
Expanded(
child: AppText(widget.title,
child: Text(widget.title,
maxLines: 2, overflow: TextOverflow.ellipsis),
),
IconButton(
icon: const Icon(Icons.close),
tooltip: tr('关闭'),
tooltip: tr('Close'),
onPressed: () => Navigator.pop(context),
),
],
@@ -2923,7 +2934,7 @@ class _FormDockState extends State<_FormDock> {
if (empty) missing.add(f.label);
}
if (missing.isNotEmpty) {
setState(() => _error = trArgs('请填写:{0}', [missing.join(tr('、'))]));
setState(() => _error = trArgs('Required: {0}', [missing.join(tr(', '))]));
return;
}
final answer = <String, Object?>{};
@@ -2966,7 +2977,7 @@ class _FormDockState extends State<_FormDock> {
const SizedBox(width: 8),
Expanded(
child: AppText(
widget.form.title.isEmpty ? '请选择' : widget.form.title,
widget.form.title.isEmpty ? 'Choose one' : widget.form.title,
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.w600),
),
@@ -2979,7 +2990,7 @@ class _FormDockState extends State<_FormDock> {
onPressed: _sending
? null
: () => widget.chat.cancelForm(widget.form),
child: const AppText('取消', style: TextStyle(fontSize: 12.5)),
child: const AppText('Cancel', style: TextStyle(fontSize: 12.5)),
),
],
),
@@ -3011,7 +3022,7 @@ class _FormDockState extends State<_FormDock> {
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('发送'),
: const AppText('Send'),
),
],
),
@@ -3026,7 +3037,7 @@ class _FormDockState extends State<_FormDock> {
final title = Row(
children: [
Flexible(
child: AppText(f.label,
child: Text(f.label,
style:
const TextStyle(fontSize: 13, fontWeight: FontWeight.w600)),
),
@@ -3038,7 +3049,7 @@ class _FormDockState extends State<_FormDock> {
? const SizedBox.shrink()
: Padding(
padding: const EdgeInsets.only(top: 2, bottom: 2),
child: AppText(f.description!,
child: Text(f.description!,
style: TextStyle(fontSize: 12, color: theme.hintColor)),
);
switch (f.type) {
@@ -3053,7 +3064,7 @@ class _FormDockState extends State<_FormDock> {
if (f.url != null && f.url!.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 2),
child: AppText(f.url!,
child: Text(f.url!,
style: TextStyle(
fontSize: 12, color: scheme.primary),
maxLines: 2,
@@ -3136,7 +3147,7 @@ class _FormDockState extends State<_FormDock> {
style: const TextStyle(fontSize: 13),
decoration: InputDecoration(
isDense: true,
hintText: tr('其他…'),
hintText: tr('Other…'),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8)),
),
@@ -3210,7 +3221,7 @@ class _FormDockState extends State<_FormDock> {
default:
return Padding(
padding: const EdgeInsets.only(top: 8),
child: AppText(trArgs('{0}({1})', [f.label, f.type]),
child: AppText(trArgs('{0} ({1})', [f.label, f.type]),
style: const TextStyle(fontSize: 13)),
);
}
+4 -4
View File
@@ -14,11 +14,11 @@ class FeaturesScreen extends StatelessWidget {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(title: const AppText('全部功能')),
appBar: AppBar(title: const AppText('All features')),
body: ListView(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 32),
children: [
AppText('服务器与智能体的工具都收在这里。',
AppText('Tools for servers and agents are collected here.',
style: TextStyle(fontSize: 12.5, color: theme.hintColor)),
const SizedBox(height: 14),
GridView.count(
@@ -31,8 +31,8 @@ class FeaturesScreen extends StatelessWidget {
children: [
_FeatureTile(
icon: Icons.schedule,
title: '计划任务',
caption: '按时间向会话发送提示词',
title: 'Scheduled tasks',
caption: 'Send prompts to sessions on a schedule',
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (_) => ScheduledTasksScreen(app: app),
)),
+49 -49
View File
@@ -21,7 +21,7 @@ Future<void> showFilesPanel(
return showGeneralDialog<void>(
context: context,
barrierDismissible: true,
barrierLabel: tr('文件'),
barrierLabel: tr('Files'),
barrierColor: Colors.black54,
transitionDuration: const Duration(milliseconds: 220),
pageBuilder: (context, _, __) {
@@ -245,7 +245,7 @@ class _FilesPanelState extends State<FilesPanel> {
setState(() {
_previewLoading = false;
_previewError = trArgs(
'文件较大({0}),请下载后查看', [_fmtSize(stat.size)]);
'File is large ({0}), download it to view', [_fmtSize(stat.size)]);
});
return;
}
@@ -285,7 +285,7 @@ class _FilesPanelState extends State<FilesPanel> {
_previewText = _editor.text;
_previewBinary = false;
});
_toast('已保存');
_toast('Saved');
} catch (e) {
if (!mounted) return;
setState(() => _saving = false);
@@ -316,9 +316,9 @@ class _FilesPanelState extends State<FilesPanel> {
fileName: _previewName,
bytes: bytes,
);
if (uri != null) _toast('已保存');
if (uri != null) _toast('Saved');
} catch (e) {
_toast(trArgs('保存失败:{0}', [e]));
_toast(trArgs('Couldn\'t save: {0}', [e]));
}
}
@@ -327,7 +327,7 @@ class _FilesPanelState extends State<FilesPanel> {
Future<void> _newEntry({required bool directory}) async {
final client = _client;
if (client == null || _path.isEmpty) return;
final name = await _askName(directory ? '新建文件夹' : '新建文件');
final name = await _askName(directory ? 'New folder' : 'New file');
if (name == null) return;
final target = '$_path/$name';
try {
@@ -356,18 +356,18 @@ class _FilesPanelState extends State<FilesPanel> {
controller: controller,
autofocus: true,
decoration: InputDecoration(
labelText: tr('名称'),
hintText: title == '新建文件夹' ? tr('例如 docs') : tr('例如 notes.md'),
labelText: tr('Name'),
hintText: title == 'New folder' ? tr('e.g. docs') : tr('e.g. notes.md'),
),
onSubmitted: (v) => Navigator.of(context).pop(v),
),
actions: [
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () => Navigator.of(context).pop(controller.text),
child: const AppText('创建')),
child: const AppText('Create')),
],
),
);
@@ -375,7 +375,7 @@ class _FilesPanelState extends State<FilesPanel> {
final trimmed = name?.trim() ?? '';
if (trimmed.isEmpty) return null;
if (trimmed.contains('/') || trimmed.contains('\\')) {
_toast(tr('名称里不能有斜杠'));
_toast(tr('Names cannot contain slashes'));
return null;
}
return trimmed;
@@ -413,7 +413,7 @@ class _FilesPanelState extends State<FilesPanel> {
/// The tab row is the panel's title now; the only global action left is
/// closing the panel. Everything else belongs to the tab's own header.
Widget _tabs(ThemeData theme) {
const labels = ['文件', '项目知识', '终端'];
const labels = ['Files', 'Project knowledge', 'Terminal'];
return Padding(
padding: const EdgeInsets.fromLTRB(12, 6, 2, 6),
child: Row(
@@ -435,7 +435,7 @@ class _FilesPanelState extends State<FilesPanel> {
),
IconButton(
icon: const Icon(Icons.close),
tooltip: tr('关闭侧栏'),
tooltip: tr('Close sidebar'),
onPressed: () => Navigator.of(context).maybePop(),
),
],
@@ -445,7 +445,7 @@ class _FilesPanelState extends State<FilesPanel> {
Widget _body(ThemeData theme) {
if (_root.isEmpty) {
return const Center(child: AppText('这个会话没有关联目录'));
return const Center(child: AppText('This session has no directory'));
}
switch (_tab) {
case 1:
@@ -487,12 +487,12 @@ class _FilesPanelState extends State<FilesPanel> {
decoration: InputDecoration(
isDense: true,
prefixIcon: const Icon(Icons.search, size: 20),
hintText: tr('搜索当前目录…'),
hintText: tr('Search this directory…'),
suffixIcon: _query.trim().isEmpty
? null
: IconButton(
icon: const Icon(Icons.travel_explore, size: 20),
tooltip: tr('搜索子目录'),
tooltip: tr('Search subdirectories'),
onPressed: _searching ? null : _deepSearch,
),
border: OutlineInputBorder(
@@ -515,7 +515,7 @@ class _FilesPanelState extends State<FilesPanel> {
height: 14,
child: CircularProgressIndicator(strokeWidth: 2)),
const SizedBox(width: 8),
AppText(trArgs('正在搜索子目录…({0})', [_deepResults.length]),
AppText(trArgs('Searching subdirectories… ({0})', [_deepResults.length]),
style: TextStyle(fontSize: 12, color: theme.hintColor)),
],
),
@@ -537,7 +537,7 @@ class _FilesPanelState extends State<FilesPanel> {
IconButton(
icon: Icon(preview ? Icons.arrow_back : Icons.arrow_upward,
size: 20),
tooltip: preview ? tr('返回') : tr('上一级'),
tooltip: preview ? tr('Back') : tr('Up one level'),
onPressed: preview
? () => setState(() => _previewPath = null)
: (_path == _root ? null : _up),
@@ -548,12 +548,12 @@ class _FilesPanelState extends State<FilesPanel> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
AppText(_previewName,
Text(_previewName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontSize: 13.5, fontWeight: FontWeight.w600)),
AppText(_previewPath!,
Text(_previewPath!,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -581,7 +581,7 @@ class _FilesPanelState extends State<FilesPanel> {
icon: Icon(_editing
? Icons.visibility_outlined
: Icons.edit_outlined),
tooltip: _editing ? tr('预览') : tr('编辑'),
tooltip: _editing ? tr('Preview') : tr('Edit'),
onPressed:
_saving ? null : () => setState(() => _editing = !_editing),
),
@@ -593,27 +593,27 @@ class _FilesPanelState extends State<FilesPanel> {
height: 18,
child: CircularProgressIndicator(strokeWidth: 2))
: const Icon(Icons.check),
tooltip: tr('保存'),
tooltip: tr('Save'),
onPressed: _saving ? null : _save,
),
IconButton(
icon: const Icon(Icons.download_outlined),
tooltip: tr('下载'),
tooltip: tr('Download'),
onPressed: _download,
),
] else if (_root.isNotEmpty) ...[
PopupMenuButton<bool>(
icon: const Icon(Icons.add),
tooltip: tr('新建'),
tooltip: tr('New'),
onSelected: (directory) => _newEntry(directory: directory),
itemBuilder: (_) => const [
PopupMenuItem(value: false, child: AppText('新建文件')),
PopupMenuItem(value: true, child: AppText('新建文件夹')),
PopupMenuItem(value: false, child: AppText('New file')),
PopupMenuItem(value: true, child: AppText('New folder')),
],
),
PopupMenuButton<String>(
icon: const Icon(Icons.more_horiz),
tooltip: tr('更多'),
tooltip: tr('More'),
onSelected: (value) {
if (value == 'ignored') {
setState(() => _showIgnored = !_showIgnored);
@@ -626,7 +626,7 @@ class _FilesPanelState extends State<FilesPanel> {
CheckedPopupMenuItem(
value: 'ignored',
checked: _showIgnored,
child: const AppText('显示被 git 忽略的文件'),
child: const AppText('Show git-ignored files'),
),
const PopupMenuItem(
value: 'refresh',
@@ -634,7 +634,7 @@ class _FilesPanelState extends State<FilesPanel> {
children: [
Icon(Icons.refresh, size: 18),
SizedBox(width: 10),
AppText('刷新'),
AppText('Refresh'),
],
),
),
@@ -653,7 +653,7 @@ class _FilesPanelState extends State<FilesPanel> {
borderRadius: BorderRadius.circular(6),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 4),
child: AppText(
child: Text(
text,
style: TextStyle(
fontSize: 13,
@@ -674,9 +674,9 @@ class _FilesPanelState extends State<FilesPanel> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_error!, textAlign: TextAlign.center),
Text(_error!, textAlign: TextAlign.center),
const SizedBox(height: 8),
TextButton(onPressed: () => _load(), child: const AppText('重试')),
TextButton(onPressed: () => _load(), child: const AppText('Retry')),
],
),
),
@@ -690,7 +690,7 @@ class _FilesPanelState extends State<FilesPanel> {
.toList();
if (filtered.isEmpty && _deepResults.isEmpty) {
return Center(
child: AppText(_query.trim().isEmpty ? '目录为空' : '没有匹配的文件',
child: AppText(_query.trim().isEmpty ? 'Directory is empty' : 'No matching files',
style: TextStyle(color: theme.hintColor)),
);
}
@@ -701,7 +701,7 @@ class _FilesPanelState extends State<FilesPanel> {
if (_query.trim().isNotEmpty && _deepResults.isNotEmpty) ...[
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 4),
child: AppText('子目录结果',
child: AppText('Subdirectory results',
style: TextStyle(fontSize: 12, color: theme.hintColor)),
),
for (final e in _deepResults) _tile(theme, e, showPath: true),
@@ -713,7 +713,7 @@ class _FilesPanelState extends State<FilesPanel> {
filtered.isNotEmpty)
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: AppText('子目录里没有匹配的文件',
child: AppText('No matching files in subdirectories',
style: TextStyle(fontSize: 12, color: theme.hintColor)),
),
],
@@ -730,10 +730,10 @@ class _FilesPanelState extends State<FilesPanel> {
color: entry.isDirectory
? theme.colorScheme.primary
: theme.colorScheme.onSurfaceVariant),
title: AppText(entry.name,
title: Text(entry.name,
maxLines: 1, overflow: TextOverflow.ellipsis, style: const TextStyle(fontSize: 14)),
subtitle: showPath
? AppText(_relative(entry.path),
? Text(_relative(entry.path),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 11, color: theme.hintColor))
@@ -770,10 +770,10 @@ class _FilesPanelState extends State<FilesPanel> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_previewError!, textAlign: TextAlign.center),
Text(_previewError!, textAlign: TextAlign.center),
const SizedBox(height: 8),
if (_previewBytes != null || _previewError != null)
TextButton(onPressed: _download, child: const AppText('下载')),
TextButton(onPressed: _download, child: const AppText('Download')),
],
),
),
@@ -795,16 +795,16 @@ class _FilesPanelState extends State<FilesPanel> {
Icon(Icons.insert_drive_file_outlined,
size: 40, color: theme.hintColor),
const SizedBox(height: 10),
AppText('这个文件无法预览',
AppText('This file cannot be previewed',
style: TextStyle(color: theme.hintColor)),
const SizedBox(height: 6),
AppText(_fmtSize(_previewBytes?.length ?? 0),
Text(_fmtSize(_previewBytes?.length ?? 0),
style: TextStyle(fontSize: 12, color: theme.hintColor)),
const SizedBox(height: 8),
OutlinedButton.icon(
onPressed: _download,
icon: const Icon(Icons.download_outlined, size: 18),
label: const AppText('下载'),
label: const AppText('Download'),
),
],
),
@@ -1002,12 +1002,12 @@ class _DownloadDialogState extends State<_DownloadDialog> {
? (_received / total).clamp(0.0, 1.0)
: null;
return AlertDialog(
title: const AppText('正在下载'),
title: const AppText('Downloading'),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(widget.name,
Text(widget.name,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 13)),
@@ -1017,16 +1017,16 @@ class _DownloadDialogState extends State<_DownloadDialog> {
const SizedBox(height: 8),
AppText(
total != null
? trArgs('{0} / {1}({2}%)', [
? trArgs('{0} / {1} ({2}%)', [
_size(_received),
_size(total),
(fraction! * 100).toStringAsFixed(0),
])
: trArgs('已下载 {0}', [_size(_received)]),
: trArgs('Downloaded {0}', [_size(_received)]),
style: TextStyle(fontSize: 12, color: theme.hintColor),
),
] else
AppText(_error!,
Text(_error!,
style:
TextStyle(fontSize: 12.5, color: theme.colorScheme.error)),
],
@@ -1040,12 +1040,12 @@ class _DownloadDialogState extends State<_DownloadDialog> {
setState(() => _cancelling = true);
_cancel.cancel();
},
child: AppText(_cancelling ? '正在取消…' : '取消'),
child: AppText(_cancelling ? 'Canceling…' : 'Cancel'),
)
else
TextButton(
onPressed: () => Navigator.of(context).pop(),
child: const AppText('关闭'),
child: const AppText('Close'),
),
],
);
+2 -2
View File
@@ -127,13 +127,13 @@ class _HomeScreenState extends State<HomeScreen> {
children: [
Icon(Icons.forum_outlined, size: 40, color: scheme.onSurfaceVariant),
const SizedBox(height: 12),
AppText('选择一个会话',
AppText('Choose a session',
style: TextStyle(fontSize: 16, color: scheme.onSurfaceVariant)),
if (!wide) ...[
const SizedBox(height: 12),
FilledButton(
onPressed: () => _scaffold.currentState?.openDrawer(),
child: const AppText('打开会话列表'),
child: const AppText('Open the session list'),
),
],
],
+68 -68
View File
@@ -49,7 +49,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
if (client == null || _projectId.isEmpty) {
setState(() {
_loading = false;
_error = tr('这个会话没有关联目录');
_error = tr('This session has no directory');
});
return;
}
@@ -91,7 +91,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
void _fail(Object error) {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: AppText('$error')));
.showSnackBar(SnackBar(content: Text('$error')));
}
bool _matches(Iterable<String> fields) {
@@ -117,8 +117,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
decoration: InputDecoration(
isDense: true,
hintText: _memory == null
? tr('搜索笔记、待办与计划')
: tr('搜索笔记、待办、计划与记忆'),
? tr('Search notes, todos, and plans')
: tr('Search notes, todos, plans, and memory'),
prefixIcon: const Icon(Icons.search, size: 18),
suffixIcon: _query.isEmpty
? null
@@ -135,7 +135,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
),
),
IconButton(
tooltip: tr('刷新'),
tooltip: tr('Refresh'),
visualDensity: VisualDensity.compact,
icon: const Icon(Icons.refresh, size: 20),
onPressed: _load,
@@ -152,11 +152,11 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
List<(String, String, int)> get _sectionsList {
final context = _context;
return [
('notes', tr('笔记'), context?.notes.length ?? 0),
('todos', tr('待办'), context?.todos.length ?? 0),
('plans', tr('计划'), context?.plans.length ?? 0),
('notes', tr('Notes'), context?.notes.length ?? 0),
('todos', tr('Todos'), context?.todos.length ?? 0),
('plans', tr('Plans'), context?.plans.length ?? 0),
if (_memory != null)
('memory', tr('记忆'),
('memory', tr('Memory'),
(_memory!.global.length + _memory!.project.length)),
];
}
@@ -190,11 +190,11 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_error!,
Text(_error!,
textAlign: TextAlign.center,
style: TextStyle(color: theme.colorScheme.error, fontSize: 13)),
const SizedBox(height: 8),
FilledButton(onPressed: _load, child: const AppText('重试')),
FilledButton(onPressed: _load, child: const AppText('Retry')),
],
),
),
@@ -224,12 +224,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
});
return Column(
children: [
_sectionHeader(theme, trArgs('{0} 条笔记', [notes.length]),
'新建笔记', _addNote),
_sectionHeader(theme, trArgs('{0} notes', [notes.length]),
'New note', _addNote),
Expanded(
child: notes.isEmpty
? _empty(theme, Icons.sticky_note_2_outlined,
_query.isEmpty ? '还没有笔记' : '没有匹配的笔记')
_query.isEmpty ? 'No notes yet' : 'No matching notes')
: ListView.builder(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
itemCount: notes.length,
@@ -259,7 +259,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(
Text(
note.body.trim(),
maxLines: 5,
overflow: TextOverflow.ellipsis,
@@ -274,7 +274,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
child: Icon(Icons.push_pin,
size: 12, color: scheme.primary),
),
AppText(
Text(
_stamp(note.updatedAt),
style:
TextStyle(fontSize: 11, color: theme.hintColor),
@@ -309,10 +309,10 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
}
},
itemBuilder: (_) => [
const PopupMenuItem(value: 'edit', child: AppText('编辑')),
const PopupMenuItem(value: 'edit', child: AppText('Edit')),
PopupMenuItem(
value: 'pin', child: AppText(note.pinned ? '取消置顶' : '置顶')),
const PopupMenuItem(value: 'delete', child: AppText('删除')),
value: 'pin', child: AppText(note.pinned ? 'Unpin' : 'Pin')),
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
],
),
],
@@ -331,12 +331,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
final done = todos.where((todo) => todo.completed).length;
return Column(
children: [
_sectionHeader(theme, trArgs('{0}/{1} 已完成', [done, todos.length]),
'新建待办', _addTodo),
_sectionHeader(theme, trArgs('{0}/{1} done', [done, todos.length]),
'New todo', _addTodo),
Expanded(
child: todos.isEmpty
? _empty(theme, Icons.checklist,
_query.isEmpty ? '还没有待办' : '没有匹配的待办')
_query.isEmpty ? 'No todos yet' : 'No matching todos')
: ListView.builder(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 12),
itemCount: todos.length,
@@ -373,7 +373,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
}
},
itemBuilder: (_) => const [
PopupMenuItem(value: 'delete', child: AppText('删除')),
PopupMenuItem(value: 'delete', child: AppText('Delete')),
],
),
);
@@ -407,12 +407,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
});
return Column(
children: [
_sectionHeader(theme, trArgs('{0} 份计划', [plans.length]),
'新建计划', _newPlan),
_sectionHeader(theme, trArgs('{0} plans', [plans.length]),
'New plan', _newPlan),
Expanded(
child: plans.isEmpty
? _empty(theme, Icons.description_outlined,
_query.isEmpty ? '还没有计划' : '没有匹配的计划')
_query.isEmpty ? 'No plans yet' : 'No matching plans')
: ListView.builder(
padding: const EdgeInsets.fromLTRB(8, 0, 8, 12),
itemCount: plans.length,
@@ -438,7 +438,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
child: Icon(Icons.push_pin, size: 13, color: scheme.primary),
),
Expanded(
child: AppText(plan.title.isEmpty ? plan.file : plan.title,
child: Text(plan.title.isEmpty ? plan.file : plan.title,
maxLines: 2, overflow: TextOverflow.ellipsis),
),
],
@@ -461,7 +461,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
),
),
const SizedBox(width: 6),
AppText('${plan.progressDone}/${plan.progressTotal}',
Text('${plan.progressDone}/${plan.progressTotal}',
style:
TextStyle(fontSize: 11, color: theme.hintColor)),
],
@@ -469,7 +469,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
],
const SizedBox(height: 2),
AppText(
plan.source == 'shared' ? '团队共享' : '个人',
plan.source == 'shared' ? 'Shared' : 'Personal',
style: TextStyle(fontSize: 11, color: theme.hintColor),
),
],
@@ -497,8 +497,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
},
itemBuilder: (_) => [
PopupMenuItem(
value: 'pin', child: AppText(plan.pinned ? '取消置顶' : '置顶')),
const PopupMenuItem(value: 'delete', child: AppText('删除')),
value: 'pin', child: AppText(plan.pinned ? 'Unpin' : 'Pin')),
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
],
),
onTap: () => _viewPlan(plan),
@@ -511,7 +511,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
Widget _memoryBody(ThemeData theme) {
final snapshot = _memory;
if (snapshot == null) {
return _empty(theme, Icons.psychology_outlined, '记忆功能未启用');
return _empty(theme, Icons.psychology_outlined, 'Memory is not enabled');
}
final global = snapshot.global
.where((m) => _matches([m.title, m.body]))
@@ -523,20 +523,20 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
return _empty(
theme,
Icons.psychology_outlined,
_query.isEmpty ? '还没有记忆' : '没有匹配的记忆');
_query.isEmpty ? 'No memories yet' : 'No matching memories');
}
return ListView(
padding: const EdgeInsets.fromLTRB(12, 0, 12, 12),
children: [
_memoryGroup(theme, tr('全局记忆'), global, 'global',
_memoryGroup(theme, tr('Global memory'), global, 'global',
failed: snapshot.globalFailed),
const SizedBox(height: 8),
_memoryGroup(theme, tr('项目记忆'), project, 'project',
_memoryGroup(theme, tr('Project memory'), project, 'project',
failed: snapshot.projectFailed),
Padding(
padding: const EdgeInsets.only(top: 6),
child: AppText(
'记忆由 agent 在会话中记录;你可以在这里修改或删除它。',
'Memory is recorded by the agent during sessions; you can edit or delete it here.',
style: TextStyle(fontSize: 11.5, color: theme.hintColor),
),
),
@@ -552,20 +552,20 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
children: [
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: AppText(trArgs('{0}({1})', [title, entries.length]),
child: AppText(trArgs('{0} ({1})', [title, entries.length]),
style: TextStyle(fontSize: 12, color: theme.hintColor)),
),
if (failed)
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: AppText('读取失败,请刷新',
child: AppText('Could not load, refresh to retry',
style: TextStyle(
fontSize: 12, color: theme.colorScheme.error)),
)
else if (entries.isEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 4),
child: AppText('暂无', style: TextStyle(fontSize: 12, color: theme.hintColor)),
child: AppText('None', style: TextStyle(fontSize: 12, color: theme.hintColor)),
),
for (final entry in entries) _memoryCard(theme, entry, scope),
],
@@ -591,7 +591,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
Row(
children: [
Flexible(
child: AppText(entry.title,
child: Text(entry.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
@@ -605,7 +605,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
color: scheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(4),
),
child: AppText(entry.typeLabel,
child: Text(entry.typeLabel,
style: TextStyle(
fontSize: 10, color: theme.hintColor)),
),
@@ -618,7 +618,7 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
],
),
const SizedBox(height: 3),
AppText(entry.body,
Text(entry.body,
maxLines: 4,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 12.5, height: 1.35)),
@@ -635,8 +635,8 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
}
},
itemBuilder: (_) => const [
PopupMenuItem(value: 'edit', child: AppText('编辑')),
PopupMenuItem(value: 'delete', child: AppText('删除')),
PopupMenuItem(value: 'edit', child: AppText('Edit')),
PopupMenuItem(value: 'delete', child: AppText('Delete')),
],
),
],
@@ -741,13 +741,13 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
final text = await showDialog<String>(
context: context,
builder: (_) => _TextPromptDialog(
title: note == null ? '新建笔记' : '编辑笔记',
hint: tr('记点什么,供之后的会话参考'),
title: note == null ? 'New note' : 'Edit note',
hint: tr('Write something for later sessions to read'),
initial: note?.body ?? '',
maxLength: 3000,
maxLines: 10,
minLines: 4,
action: '保存',
action: 'Save',
),
);
if (text == null || text.isEmpty) return;
@@ -770,12 +770,12 @@ class _KnowledgePanelState extends State<KnowledgePanel> {
final text = await showDialog<String>(
context: context,
builder: (_) => _TextPromptDialog(
title: '新建待办',
hint: tr('要做什么'),
title: 'New todo',
hint: tr('What needs doing'),
maxLength: 1000,
maxLines: 1,
minLines: 1,
action: '保存',
action: 'Save',
),
);
if (text == null || text.isEmpty) return;
@@ -876,7 +876,7 @@ class _PlanPageState extends State<_PlanPage> {
} catch (error) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: AppText('$error')));
.showSnackBar(SnackBar(content: Text('$error')));
}
} finally {
if (mounted) setState(() => _saving = false);
@@ -887,18 +887,18 @@ class _PlanPageState extends State<_PlanPage> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: AppText(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis),
title: Text(widget.title, maxLines: 1, overflow: TextOverflow.ellipsis),
actions: [
if (_editing)
TextButton(
onPressed: _saving ? null : () => setState(() => _editing = false),
child: const AppText('取消'),
child: const AppText('Cancel'),
),
TextButton(
onPressed: _saving
? null
: (_editing ? _save : () => setState(() => _editing = true)),
child: AppText(_saving ? '保存中…' : (_editing ? '保存' : '编辑')),
child: AppText(_saving ? 'Saving…' : (_editing ? 'Save' : 'Edit')),
),
],
),
@@ -983,7 +983,7 @@ class _TextPromptDialogState extends State<_TextPromptDialog> {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () => Navigator.pop(context, _controller.text.trim()),
child: AppText(widget.action)),
@@ -1014,7 +1014,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const AppText('新建计划'),
title: const AppText('New plan'),
content: SizedBox(
width: double.maxFinite,
child: Column(
@@ -1025,7 +1025,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
autofocus: true,
maxLength: 160,
decoration: InputDecoration(
labelText: tr('标题'),
labelText: tr('Title'),
border: const OutlineInputBorder(),
),
),
@@ -1036,7 +1036,7 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
minLines: 6,
decoration: InputDecoration(
alignLabelWithHint: true,
labelText: tr('计划正文(Markdown)'),
labelText: tr('Plan body (Markdown)'),
border: const OutlineInputBorder(),
),
),
@@ -1046,11 +1046,11 @@ class _NewPlanDialogState extends State<_NewPlanDialog> {
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () => Navigator.pop(
context, (_title.text.trim(), _body.text)),
child: const AppText('创建')),
child: const AppText('Create')),
],
);
}
@@ -1082,7 +1082,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const AppText('编辑记忆'),
title: const AppText('Edit memory'),
content: SizedBox(
width: double.maxFinite,
child: Column(
@@ -1093,7 +1093,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
autofocus: true,
maxLength: 120,
decoration: InputDecoration(
labelText: tr('标题'),
labelText: tr('Title'),
border: const OutlineInputBorder(),
),
),
@@ -1105,9 +1105,9 @@ class _MemoryDialogState extends State<_MemoryDialog> {
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
segments: const [
ButtonSegment(value: 'fact', label: AppText('事实')),
ButtonSegment(value: 'preference', label: AppText('偏好')),
ButtonSegment(value: 'reference', label: AppText('参考')),
ButtonSegment(value: 'fact', label: AppText('Fact')),
ButtonSegment(value: 'preference', label: AppText('Preference')),
ButtonSegment(value: 'reference', label: AppText('Reference')),
],
selected: {_type},
onSelectionChanged: (value) =>
@@ -1121,7 +1121,7 @@ class _MemoryDialogState extends State<_MemoryDialog> {
minLines: 4,
decoration: InputDecoration(
alignLabelWithHint: true,
labelText: tr('内容'),
labelText: tr('Content'),
border: const OutlineInputBorder(),
),
),
@@ -1130,14 +1130,14 @@ class _MemoryDialogState extends State<_MemoryDialog> {
),
actions: [
TextButton(
onPressed: () => Navigator.pop(context), child: const AppText('取消')),
onPressed: () => Navigator.pop(context), child: const AppText('Cancel')),
FilledButton(
onPressed: () {
final title = _title.text.trim();
if (title.isEmpty) return;
Navigator.pop(context, (title, _body.text.trim(), _type));
},
child: const AppText('保存'),
child: const AppText('Save'),
),
],
);
+16 -16
View File
@@ -177,7 +177,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: AppText(trArgs('选择失败:{0}', [e]))));
.showSnackBar(SnackBar(content: AppText(trArgs('Could not attach: {0}', [e]))));
}
} finally {
if (mounted) setState(() => _attaching = false);
@@ -208,14 +208,14 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
? null
: IconButton(
icon: const Icon(Icons.menu),
tooltip: tr('会话'),
tooltip: tr('Sessions'),
onPressed: widget.onOpenSessions,
),
title: const AppText('新会话'),
title: const AppText('New session'),
actions: [
IconButton(
icon: const Icon(Icons.folder_open_outlined),
tooltip: tr('文件'),
tooltip: tr('Files'),
onPressed: () => showFilesPanel(context, app, draft.directory),
),
],
@@ -230,7 +230,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
child: Padding(
padding: const EdgeInsets.all(32),
child: AppText(
'我们今天要做什么?',
'What are we building today?',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 26,
@@ -253,7 +253,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
if (draft.error != null)
Padding(
padding: const EdgeInsets.only(bottom: 6),
child: AppText(
child: Text(
draft.error!,
style: TextStyle(
fontSize: 12.5, color: scheme.error),
@@ -301,8 +301,8 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
const SizedBox(width: 5),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 170),
child: AppText(
label.isEmpty ? '选择项目' : label,
child: Text(
label.isEmpty ? tr('Choose project') : label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12.5, color: theme.hintColor),
@@ -323,7 +323,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
Widget body = ComposerBox(
controller: _text,
focusNode: _inputFocus,
hint: tr('规划、构建或提问'),
hint: tr('Plan, build, or ask'),
maxLines: 5,
keyboardInset: keyboardInset,
textInputAction:
@@ -355,7 +355,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
},
leading: _roundKey(
icon: Icons.attach_file,
label: tr('添加附件'),
label: tr('Add attachment'),
onTap: _pickFiles,
busy: _attaching,
),
@@ -478,7 +478,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(16, 14, 16, 6),
child: AppText('选择项目',
child: AppText('Choose project',
style:
TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
),
@@ -490,8 +490,8 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
dense: true,
leading: ProjectIcon(
app: widget.app, chat: true, size: 20),
title: const AppText('聊天'),
subtitle: const AppText('不关联项目,保存在 OpenChamber 的聊天目录'),
title: const AppText('Chat'),
subtitle: const AppText('Not tied to a project, saved in OpenChamber\'s chat directory'),
trailing: draft.directory == AppState.chatTarget
? Icon(Icons.check,
size: 18,
@@ -509,9 +509,9 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
dense: true,
leading:
ProjectIcon(app: widget.app, project: project, size: 20),
title: AppText(project.label,
title: Text(project.label,
maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: AppText(project.canonical,
subtitle: Text(project.canonical,
maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: project.canonical == draft.directory
? Icon(Icons.check,
@@ -528,7 +528,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
if (projects.isEmpty)
const Padding(
padding: EdgeInsets.all(24),
child: AppText('没有可用的项目', textAlign: TextAlign.center),
child: AppText('No projects available', textAlign: TextAlign.center),
),
],
),
+18 -18
View File
@@ -93,7 +93,7 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
return;
}
if (cameras.isEmpty) {
if (mounted) setState(() => _error = tr('没有可用的相机'));
if (mounted) setState(() => _error = tr('No camera available'));
return;
}
CameraDescription pick = cameras.first;
@@ -124,11 +124,11 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
await controller.startImageStream(_onFrame);
_watchdog = Timer(const Duration(seconds: 4), () {
if (!mounted || _frames > 0 || _error != null) return;
setState(() => _hint = tr('没有收到相机画面,请关闭后重试'));
setState(() => _hint = tr('No camera frames received; close and try again'));
});
_slowHint = Timer(const Duration(seconds: 12), () {
if (!mounted || _found || _frames == 0) return;
_showHint(tr('还没识别到二维码,试着靠近一点或让二维码占满取景框'),
_showHint(tr('No QR code yet; move closer or fill the frame with the code'),
sticky: true);
});
return;
@@ -153,11 +153,11 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
if (error.code == 'CameraAccessDenied' ||
error.code == 'CameraAccessDeniedWithoutPrompt' ||
error.code == 'CameraAccessRestricted') {
return tr('需要相机权限才能扫码。请在系统设置里允许 OpenChamber 使用相机。');
return tr('Camera permission is required to scan. Allow OpenChamber to use the camera in system settings.');
}
return trArgs('无法打开相机:{0}', [error.description ?? error.code]);
return trArgs('Could not open the camera: {0}', [error.description ?? error.code]);
}
return trArgs('无法打开相机:{0}', [error]);
return trArgs('Could not open the camera: {0}', [error]);
}
void _onFrame(CameraImage image) {
@@ -189,14 +189,14 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
if (text.trim().startsWith('openchamber://connect')) {
_accept(text.trim());
} else {
_showHint(tr('这不是 OpenChamber 配对二维码'));
_showHint(tr('This is not an OpenChamber pairing QR code'));
}
}).catchError((Object error) {
_decoding = false;
_decodeErrors += 1;
if (_decodeErrors == 1) {
debugPrint('qr: decode failed: $error');
if (mounted) _showHint(tr('二维码解码出错,请重试'));
if (mounted) _showHint(tr('Could not decode the QR code; try again'));
}
});
}
@@ -249,7 +249,7 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
await controller.setFlashMode(_torch ? FlashMode.off : FlashMode.torch);
if (mounted) setState(() => _torch = !_torch);
} catch (_) {
if (mounted) _showHint(tr('这个相机不支持手电筒'));
if (mounted) _showHint(tr('This camera does not support the flashlight'));
}
}
@@ -275,13 +275,13 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
const Icon(Icons.no_photography_outlined,
size: 36, color: Colors.white70),
const SizedBox(height: 12),
AppText(_error!,
Text(_error!,
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white70)),
const SizedBox(height: 16),
FilledButton.tonal(
onPressed: _start,
child: const AppText('重试'),
child: const AppText('Retry'),
),
],
),
@@ -296,14 +296,14 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
Row(
children: [
IconButton(
tooltip: tr('关闭'),
tooltip: tr('Close'),
icon: const Icon(Icons.close),
color: Colors.white,
onPressed: () => Navigator.of(context).pop(),
),
const Spacer(),
IconButton(
tooltip: tr('手电筒'),
tooltip: tr('Flashlight'),
icon: Icon(_torch ? Icons.flash_on : Icons.flash_off),
color: Colors.white,
onPressed: _toggleTorch,
@@ -315,22 +315,22 @@ class _ScanQrScreenState extends State<ScanQrScreen> {
padding: const EdgeInsets.fromLTRB(24, 0, 24, 32),
child: Column(
children: [
AppText(
_hint ?? '把配对二维码放进框内',
Text(
_hint ?? tr('Put the pairing QR code inside the frame'),
textAlign: TextAlign.center,
style: const TextStyle(color: Colors.white, fontSize: 14),
),
const SizedBox(height: 6),
const AppText(
'在 OpenChamber 网页端打开「连接设备」,选择二维码',
'In the OpenChamber web app, open “Connect a device” and choose the QR code',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.white60, fontSize: 12),
),
if (ready && _frames > 0)
Padding(
padding: const EdgeInsets.only(top: 8),
child: AppText(
trArgs('{0} · 已扫描 {1} 帧 / 解码 {2} 次',
child: Text(
trArgs('{0} · {1} frames scanned / {2} decode attempts',
[_frameShape ?? '', _frames, _decodeAttempts]),
textAlign: TextAlign.center,
style: const TextStyle(
+43 -43
View File
@@ -60,7 +60,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
project.label,
project.canonical,
),
_TaskScope(Client.scheduledChatsScope, tr('聊天')),
_TaskScope(Client.scheduledChatsScope, tr('Chat')),
];
}
@@ -84,7 +84,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
setState(() {
_loading = false;
_tasks = const [];
_error = client == null ? '未连接服务器' : null;
_error = client == null ? tr('Not connected to a server') : null;
});
return;
}
@@ -105,15 +105,15 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
_loading = false;
_tasks = const [];
_error = e.status == 404
? '服务器不支持计划任务'
: trArgs('加载计划任务失败:{0}', [e.message]);
? 'The server doesn\'t support scheduled tasks'
: trArgs('Couldn\'t load scheduled tasks: {0}', [e.message]);
});
} catch (e) {
if (!mounted || _scope?.id != scope.id) return;
setState(() {
_loading = false;
_tasks = const [];
_error = trArgs('加载计划任务失败:{0}', [e]);
_error = trArgs('Couldn\'t load scheduled tasks: {0}', [e]);
});
}
}
@@ -144,20 +144,20 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
Future<bool> _save(_TaskScope scope, ScheduledTask draft) async {
final client = app.client;
if (client == null) {
_say('未连接服务器');
_say(tr('Not connected to a server'));
return false;
}
try {
final tasks = await client.saveScheduledTask(scope.id, draft);
if (!mounted) return true;
if (_scope?.id == scope.id) setState(() => _tasks = tasks);
_say('计划任务已保存');
_say('Scheduled task saved');
return true;
} on ApiError catch (e) {
_say(e.message.isEmpty ? '保存任务失败' : e.message);
_say(e.message.isEmpty ? 'Couldn\'t save task' : e.message);
return false;
} catch (e) {
_say(trArgs('保存任务失败:{0}', [e]));
_say(trArgs('Couldn\'t save task: {0}', [e]));
return false;
}
}
@@ -173,7 +173,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
if (!mounted) return;
if (_scope?.id == scope.id) setState(() => _tasks = tasks);
} catch (e) {
_say(e is ApiError && e.message.isNotEmpty ? e.message : '更新任务失败');
_say(e is ApiError && e.message.isNotEmpty ? e.message : 'Couldn\'t update task');
await _load();
} finally {
if (mounted) setState(() => _busyId = '');
@@ -187,12 +187,12 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
setState(() => _busyId = task.id);
try {
await client.runScheduledTask(scope.id, task.id);
_say('任务已启动');
_say('Task started');
await _load();
} on ApiError catch (e) {
_say(e.status == 409 ? '任务已在队列中等待' : (e.message.isEmpty ? '运行任务失败' : e.message));
_say(e.status == 409 ? 'Task is already waiting in the queue' : (e.message.isEmpty ? 'Couldn\'t run task' : e.message));
} catch (e) {
_say(trArgs('运行任务失败:{0}', [e]));
_say(trArgs('Couldn\'t run task: {0}', [e]));
} finally {
if (mounted) setState(() => _busyId = '');
}
@@ -205,15 +205,15 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
final ok = await showDialog<bool>(
context: context,
builder: (dialog) => AlertDialog(
title: const AppText('删除计划任务?'),
content: AppText(trArgs('“{0}”及其计划会被删除。', [task.name])),
title: const AppText('Delete scheduled task?'),
content: AppText(trArgs('“{0}” and its schedule will be deleted.', [task.name])),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialog, false),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () => Navigator.pop(dialog, true),
child: const AppText('删除')),
child: const AppText('Delete')),
],
),
);
@@ -223,9 +223,9 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
final tasks = await client.deleteScheduledTask(scope.id, task.id);
if (!mounted) return;
if (_scope?.id == scope.id) setState(() => _tasks = tasks);
_say('计划任务已删除');
_say('Scheduled task deleted');
} catch (e) {
_say(e is ApiError && e.message.isNotEmpty ? e.message : '删除任务失败');
_say(e is ApiError && e.message.isNotEmpty ? e.message : 'Couldn\'t delete task');
} finally {
if (mounted) setState(() => _busyId = '');
}
@@ -236,16 +236,16 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(
title: const AppText('计划任务'),
title: const AppText('Scheduled tasks'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
tooltip: tr('刷新'),
tooltip: tr('Refresh'),
onPressed: _loading ? null : _load,
),
IconButton(
icon: const Icon(Icons.add),
tooltip: tr('新建任务'),
tooltip: tr('New task'),
onPressed: _scope == null ? null : () => _openEditor(),
),
],
@@ -267,7 +267,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
children: [
Icon(Icons.folder_outlined, size: 18, color: theme.hintColor),
const SizedBox(width: 8),
AppText('运行位置', style: TextStyle(fontSize: 13, color: theme.hintColor)),
AppText('Runs in', style: TextStyle(fontSize: 13, color: theme.hintColor)),
const SizedBox(width: 10),
Expanded(
child: DropdownButtonHideUnderline(
@@ -278,7 +278,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
for (final scope in _scopes)
DropdownMenuItem(
value: scope.id,
child: AppText(scope.label,
child: Text(scope.label,
maxLines: 1, overflow: TextOverflow.ellipsis),
),
],
@@ -309,9 +309,9 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_error!, style: TextStyle(color: theme.hintColor)),
Text(_error!, style: TextStyle(color: theme.hintColor)),
const SizedBox(height: 8),
TextButton(onPressed: _load, child: const AppText('重试')),
TextButton(onPressed: _load, child: const AppText('Retry')),
],
),
);
@@ -323,12 +323,12 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
children: [
Icon(Icons.event_note_outlined, size: 36, color: theme.hintColor),
const SizedBox(height: 10),
AppText('暂无计划任务。', style: TextStyle(color: theme.hintColor)),
AppText('No scheduled tasks yet.', style: TextStyle(color: theme.hintColor)),
const SizedBox(height: 8),
FilledButton.tonalIcon(
onPressed: () => _openEditor(),
icon: const Icon(Icons.add, size: 18),
label: const AppText('新建任务'),
label: const AppText('New task'),
),
],
),
@@ -353,14 +353,14 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
_ => theme.hintColor,
};
final next = task.nextRunAt > 0 && task.enabled
? trArgs('下次:{0}', [scheduledRelativeTime(task.nextRunAt)])
: (task.enabled ? '' : '已暂停');
? trArgs('Next: {0}', [scheduledRelativeTime(task.nextRunAt)])
: (task.enabled ? '' : 'Paused');
final last = task.lastRunAt > 0
? trArgs('上次运行 {0} · {1}', [
? trArgs('Last run {0} · {1}', [
scheduledClock(task.lastRunAt),
scheduledStatusLabel(task.lastStatus),
])
: '从未运行';
: 'Never run';
return Card(
margin: const EdgeInsets.symmetric(vertical: 4, horizontal: 2),
clipBehavior: Clip.antiAlias,
@@ -374,7 +374,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
Row(
children: [
Expanded(
child: AppText(
child: Text(
task.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -396,7 +396,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
onChanged: (v) => _toggle(task, v),
),
PopupMenuButton<String>(
tooltip: tr('更多'),
tooltip: tr('More'),
onSelected: (value) {
switch (value) {
case 'run':
@@ -408,23 +408,23 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
}
},
itemBuilder: (_) => [
const PopupMenuItem(value: 'run', child: AppText('立即运行')),
const PopupMenuItem(value: 'edit', child: AppText('编辑')),
const PopupMenuItem(value: 'run', child: AppText('Run now')),
const PopupMenuItem(value: 'edit', child: AppText('Edit')),
PopupMenuItem(
value: 'delete',
child: AppText('删除',
child: AppText('Delete',
style: TextStyle(color: theme.colorScheme.error)),
),
],
),
],
),
AppText(scheduledScheduleText(task),
Text(scheduledScheduleText(task),
style: TextStyle(fontSize: 13, color: theme.colorScheme.onSurfaceVariant)),
if (task.targetSessionId.isEmpty)
const SizedBox.shrink()
else
AppText('发送到现有会话', style: TextStyle(fontSize: 11.5, color: theme.hintColor)),
AppText('Sends to an existing session', style: TextStyle(fontSize: 11.5, color: theme.hintColor)),
const SizedBox(height: 4),
Row(
children: [
@@ -441,7 +441,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
const SizedBox(width: 6),
],
Expanded(
child: AppText(
child: Text(
last,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -449,7 +449,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
),
),
if (next.isNotEmpty)
AppText(next,
Text(next,
style:
TextStyle(fontSize: 11.5, color: theme.hintColor)),
],
@@ -457,7 +457,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
if (task.lastError.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 4),
child: AppText(
child: Text(
task.lastError,
maxLines: 2,
overflow: TextOverflow.ellipsis,
@@ -466,7 +466,7 @@ class _ScheduledTasksScreenState extends State<ScheduledTasksScreen> {
),
),
const SizedBox(height: 2),
AppText(
Text(
task.modelLabel,
maxLines: 1,
overflow: TextOverflow.ellipsis,
+39 -40
View File
@@ -75,7 +75,7 @@ class _ServersScreenState extends State<ServersScreen> {
style: theme.textTheme.headlineMedium
?.copyWith(fontWeight: FontWeight.bold)),
const SizedBox(height: 4),
AppText('连接你的 OpenChamber 服务器',
AppText('Connect to your OpenChamber server',
style: theme.textTheme.bodyMedium
?.copyWith(color: theme.hintColor)),
],
@@ -84,7 +84,7 @@ class _ServersScreenState extends State<ServersScreen> {
if (widget.app.error != null)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: AppText(widget.app.error!,
child: Text(widget.app.error!,
style: TextStyle(color: theme.colorScheme.error, fontSize: 13)),
),
Expanded(
@@ -99,7 +99,7 @@ class _ServersScreenState extends State<ServersScreen> {
child: OutlinedButton.icon(
onPressed: () => _startEdit(null),
icon: const Icon(Icons.add),
label: const AppText('添加服务器'),
label: const AppText('Add server'),
),
),
const SizedBox(width: 8),
@@ -107,7 +107,7 @@ class _ServersScreenState extends State<ServersScreen> {
child: FilledButton.tonalIcon(
onPressed: _pair,
icon: const Icon(Icons.qr_code_2, size: 18),
label: const AppText('配对链接'),
label: const AppText('Pairing link'),
),
),
],
@@ -127,14 +127,14 @@ class _ServersScreenState extends State<ServersScreen> {
return Card(
margin: const EdgeInsets.only(bottom: 10),
child: ListTile(
title: AppText(c.label, style: const TextStyle(fontWeight: FontWeight.w600)),
title: Text(c.label, style: const TextStyle(fontWeight: FontWeight.w600)),
subtitle: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
AppText(c.isRelay ? trArgs('经由 Relay · {0}', [c.serverId]) : c.url,
Text(c.isRelay ? trArgs('Via Relay · {0}', [c.serverId]) : c.url,
maxLines: 1, overflow: TextOverflow.ellipsis),
if (!c.isRelay && c.proxy.isNotEmpty)
AppText(trArgs('经由 {0}', [c.proxy]),
AppText(trArgs('Via {0}', [c.proxy]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12, color: theme.hintColor)),
@@ -144,9 +144,9 @@ class _ServersScreenState extends State<ServersScreen> {
mainAxisSize: MainAxisSize.min,
children: [
if (connected)
AppText('已连接', style: TextStyle(color: theme.colorScheme.primary))
AppText('Connected', style: TextStyle(color: theme.colorScheme.primary))
else
TextButton(onPressed: () => _connect(c), child: const AppText('连接')),
TextButton(onPressed: () => _connect(c), child: const AppText('Connect')),
PopupMenuButton<String>(
onSelected: (v) {
if (v == 'edit') {
@@ -156,8 +156,8 @@ class _ServersScreenState extends State<ServersScreen> {
}
},
itemBuilder: (_) => const [
PopupMenuItem(value: 'edit', child: AppText('编辑')),
PopupMenuItem(value: 'delete', child: AppText('删除')),
PopupMenuItem(value: 'edit', child: AppText('Edit')),
PopupMenuItem(value: 'delete', child: AppText('Delete')),
],
),
],
@@ -222,28 +222,28 @@ class _ServersScreenState extends State<ServersScreen> {
setState(() => _editing = false);
},
),
title: AppText(_editNew ? '添加服务器' : trArgs('连接 {0}', [_edit!.label])),
title: AppText(_editNew ? 'Add server' : trArgs('Connect to {0}', [_edit!.label])),
),
body: ListView(
padding: const EdgeInsets.all(16),
children: [
_labelText('名称'),
_labelText('Name'),
TextField(
controller: TextEditingController(text: _label),
onChanged: (v) => _label = v,
decoration: InputDecoration(
hintText: tr('如 我的电脑'), border: const OutlineInputBorder()),
hintText: tr('e.g. My computer'), border: const OutlineInputBorder()),
),
const SizedBox(height: 12),
if (_edit?.isRelay == true) ...[
const ListTile(
contentPadding: EdgeInsets.zero,
leading: Icon(Icons.lock_outline, size: 20),
title: AppText('通过 Relay 连接'),
subtitle: AppText('端到端加密;服务器与设备令牌保持不变'),
title: AppText('Connect through Relay'),
subtitle: AppText('End-to-end encrypted; the server and device token stay the same'),
),
] else ...[
_labelText('服务器地址'),
_labelText('Server address'),
TextField(
controller: TextEditingController(text: _url),
onChanged: (v) => _url = v,
@@ -252,47 +252,47 @@ class _ServersScreenState extends State<ServersScreen> {
hintText: 'http://192.168.1.10:3000', border: OutlineInputBorder()),
),
const SizedBox(height: 12),
_labelText('代理(可选)'),
_labelText('Proxy (optional)'),
TextField(
controller: TextEditingController(text: _proxy),
onChanged: (v) => _proxy = v,
keyboardType: TextInputType.url,
decoration: InputDecoration(
hintText: tr('http://… 或 socks5://…'),
hintText: tr('http://… or socks5://…'),
border: const OutlineInputBorder()),
),
const SizedBox(height: 12),
_labelText('自签证书指纹(可选)'),
_labelText('Self-signed certificate fingerprint (optional)'),
TextField(
controller: TextEditingController(text: _fingerprint),
onChanged: (v) => _fingerprint = v,
decoration: InputDecoration(
hintText: tr('SHA-256 十六进制'),
hintText: tr('SHA-256 hex'),
border: const OutlineInputBorder()),
),
SwitchListTile(
contentPadding: EdgeInsets.zero,
title: const AppText('信任自签名证书'),
title: const AppText('Trust self-signed certificates'),
value: _insecure,
onChanged: (v) => setState(() => _insecure = v),
),
// Shown for new servers too: a password-protected instance rejects
// the first attempt, and this is where the password goes.
_labelText('密码(如果需要)'),
_labelText('Password (if required)'),
TextField(
controller: TextEditingController(text: _password),
focusNode: _passwordFocus,
onChanged: (v) => _password = v,
obscureText: true,
decoration: InputDecoration(
hintText: tr('服务器密码;服务器未设置可留空'),
hintText: tr('Server password; leave empty if the server has none'),
border: const OutlineInputBorder()),
),
],
if (_formError != null)
Padding(
padding: const EdgeInsets.only(top: 8),
child: AppText(_formError!,
child: Text(_formError!,
style: TextStyle(color: theme.colorScheme.error)),
),
const SizedBox(height: 16),
@@ -301,7 +301,7 @@ class _ServersScreenState extends State<ServersScreen> {
child: _connecting
? const SizedBox(
height: 20, width: 20, child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('连接'),
: const AppText('Connect'),
),
],
),
@@ -354,7 +354,7 @@ class _ServersScreenState extends State<ServersScreen> {
/// The server asked for a password: put the caret where it is typed.
void _focusPasswordIfNeeded(String? message) {
// The message is already in the UI's language; look for the same word.
if (message == null || !message.contains(tr('需要密码'))) return;
if (message == null || !message.contains(tr('Password'))) return;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _passwordFocus.requestFocus();
});
@@ -370,16 +370,16 @@ class _ServersScreenState extends State<ServersScreen> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('删除服务器?'),
content: AppText(trArgs('“{0}”将从列表移除,设备令牌也会删除。', [c.label])),
title: const AppText('Delete server?'),
content: AppText(trArgs('“{0}” will be removed from the list, and its device token will be deleted.', [c.label])),
actions: [
TextButton(onPressed: () => Navigator.pop(context), child: const AppText('取消')),
TextButton(onPressed: () => Navigator.pop(context), child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
widget.app.removeConnection(c);
},
child: const AppText('删除'),
child: const AppText('Delete'),
),
],
),
@@ -458,7 +458,7 @@ class _PairingDialogState extends State<_PairingDialog> {
}
setState(() {
_busy = false;
_error = widget.app.lastError ?? tr('配对失败');
_error = widget.app.lastError ?? tr('Pairing failed');
});
widget.app.clearLastError();
}
@@ -467,7 +467,7 @@ class _PairingDialogState extends State<_PairingDialog> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return AlertDialog(
title: const AppText('配对链接'),
title: const AppText('Pairing link'),
content: SizedBox(
width: 420,
child: Column(
@@ -475,8 +475,7 @@ class _PairingDialogState extends State<_PairingDialog> {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
AppText(
'在 OpenChamber 网页端打开「连接设备」,粘贴链接或直接扫描二维码。'
'链接里带一次性密钥,以及直连地址或私有 Relay。',
'In the OpenChamber web app, open “Connect a device”, then paste the link or scan the QR code. The link carries a one-time key and either a direct address or a private Relay.',
style: TextStyle(fontSize: 12.5, color: theme.hintColor),
),
const SizedBox(height: 12),
@@ -495,7 +494,7 @@ class _PairingDialogState extends State<_PairingDialog> {
if (_error != null)
Padding(
padding: const EdgeInsets.only(top: 8),
child: AppText(_error!,
child: Text(_error!,
style: TextStyle(color: theme.colorScheme.error, fontSize: 12.5)),
),
Row(
@@ -503,13 +502,13 @@ class _PairingDialogState extends State<_PairingDialog> {
TextButton.icon(
onPressed: _busy ? null : _scan,
icon: const Icon(Icons.qr_code_scanner, size: 18),
label: const AppText('扫码'),
label: const AppText('Scan QR code'),
),
const SizedBox(width: 4),
TextButton.icon(
onPressed: _busy ? null : _paste,
icon: const Icon(Icons.content_paste, size: 18),
label: const AppText('粘贴'),
label: const AppText('Paste'),
),
],
),
@@ -519,14 +518,14 @@ class _PairingDialogState extends State<_PairingDialog> {
actions: [
TextButton(
onPressed: _busy ? null : () => Navigator.of(context).pop(),
child: const AppText('取消'),
child: const AppText('Cancel'),
),
FilledButton(
onPressed: _busy ? null : _connect,
child: _busy
? const SizedBox(
width: 18, height: 18, child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('配对并连接'),
: const AppText('Pair and connect'),
),
],
);
+66 -66
View File
@@ -81,13 +81,13 @@ class _SessionListPaneState extends State<SessionListPane> {
children: [
const SizedBox(width: 12),
const Expanded(
child: AppText('会话',
child: AppText('Sessions',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w600)),
),
IconButton(
icon: Icon(_searchOpen ? Icons.close : Icons.search),
tooltip: tr('搜索'),
tooltip: tr('Search'),
onPressed: () {
setState(() {
_searchOpen = !_searchOpen;
@@ -100,7 +100,7 @@ class _SessionListPaneState extends State<SessionListPane> {
),
IconButton(
icon: const Icon(Icons.add),
tooltip: tr('新会话'),
tooltip: tr('New session'),
onPressed: () => _newSession(),
),
],
@@ -114,7 +114,7 @@ class _SessionListPaneState extends State<SessionListPane> {
autofocus: true,
onChanged: _onSearchChanged,
decoration: InputDecoration(
hintText: tr('搜索会话'),
hintText: tr('Search sessions'),
prefixIcon: const Icon(Icons.search),
border: const OutlineInputBorder(),
isDense: true,
@@ -127,13 +127,13 @@ class _SessionListPaneState extends State<SessionListPane> {
child: Row(
children: [
Expanded(
child: AppText(_app.error!,
child: Text(_app.error!,
style: TextStyle(
color: scheme.error, fontSize: 13)),
),
TextButton(
onPressed: _app.refreshSessions,
child: const AppText('重试')),
child: const AppText('Retry')),
],
),
),
@@ -189,12 +189,12 @@ class _SessionListPaneState extends State<SessionListPane> {
),
IconButton(
icon: const Icon(Icons.widgets_outlined),
tooltip: tr('全部功能'),
tooltip: tr('All features'),
onPressed: _openFeatures,
),
IconButton(
icon: const Icon(Icons.settings_outlined),
tooltip: tr('设置'),
tooltip: tr('Settings'),
onPressed: _openSettings,
),
],
@@ -242,10 +242,10 @@ class _SessionListPaneState extends State<SessionListPane> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
AppText(_searchCtrl.text.isEmpty ? '暂无会话' : '没有匹配的会话'),
AppText(_searchCtrl.text.isEmpty ? 'No sessions' : 'No matching sessions'),
const SizedBox(height: 8),
FilledButton(
onPressed: () => _newSession(), child: const AppText('新会话')),
onPressed: () => _newSession(), child: const AppText('New session')),
],
),
);
@@ -284,7 +284,7 @@ class _SessionListPaneState extends State<SessionListPane> {
_SessionGroup(
key: entry.key,
label: entry.key == AppState.chatTarget
? '聊天'
? tr('Chat')
: _app.projectLabelFor(entry.value.first.directory),
// The first session's own path: the server knows that spelling.
path: entry.key == AppState.chatTarget
@@ -350,8 +350,8 @@ class _SessionListPaneState extends State<SessionListPane> {
),
],
),
title: AppText(
group.label.isEmpty ? '未命名项目' : group.label,
title: Text(
group.label.isEmpty ? tr('Untitled project') : group.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -362,7 +362,7 @@ class _SessionListPaneState extends State<SessionListPane> {
),
subtitle: group.path.isEmpty
? null
: AppText(
: Text(
group.path,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -377,8 +377,8 @@ class _SessionListPaneState extends State<SessionListPane> {
icon: const Icon(Icons.add, size: 20),
padding: EdgeInsets.zero,
tooltip: group.key == AppState.chatTarget
? tr('新建聊天')
: tr('在此项目新会话'),
? tr('New chat')
: tr('New session in this project'),
onPressed: () => _newSession(
directory: group.key == AppState.chatTarget
? AppState.chatTarget
@@ -413,10 +413,10 @@ class _SessionListPaneState extends State<SessionListPane> {
final yesterday = today.subtract(const Duration(days: 1));
final weekAgo = today.subtract(const Duration(days: 7));
final buckets = <String, List<Session>>{
'今天': [],
'昨天': [],
'本周早些时候': [],
'更早': [],
'Today': [],
'Yesterday': [],
'Earlier this week': [],
'Earlier': [],
};
for (final session in sessions) {
final time = session.updated > 0
@@ -424,12 +424,12 @@ class _SessionListPaneState extends State<SessionListPane> {
: DateTime.fromMillisecondsSinceEpoch(session.created);
final day = DateTime(time.year, time.month, time.day);
final key = day == today
? '今天'
? 'Today'
: day == yesterday
? '昨天'
? 'Yesterday'
: day.isAfter(weekAgo)
? '本周早些时候'
: '更早';
? 'Earlier this week'
: 'Earlier';
buckets[key]!.add(session);
}
return [
@@ -459,7 +459,7 @@ class _SessionListPaneState extends State<SessionListPane> {
size: 13, color: Theme.of(context).hintColor),
const SizedBox(width: 5),
Expanded(
child: AppText('已置顶',
child: AppText('Pinned',
style: TextStyle(
fontSize: 12.5,
fontWeight: FontWeight.w700,
@@ -478,25 +478,25 @@ class _SessionListPaneState extends State<SessionListPane> {
Widget _draftRow(SessionDraft draft) {
final theme = Theme.of(context);
final label = draft.firstLine.isEmpty ? tr('新会话') : draft.firstLine;
final label = draft.firstLine.isEmpty ? tr('New session') : draft.firstLine;
final project = _app.projectLabelFor(draft.directory);
return ListTile(
selected: _app.draftOpen,
leading: Icon(Icons.edit_outlined, size: 18, color: theme.hintColor),
title: AppText(
title: Text(
label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontStyle: FontStyle.italic),
),
subtitle: AppText(
project.isEmpty ? '草稿' : trArgs('草稿 · {0}', [project]),
project.isEmpty ? 'Draft' : trArgs('Draft · {0}', [project]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
trailing: IconButton(
icon: const Icon(Icons.close, size: 18),
tooltip: tr('丢弃草稿'),
tooltip: tr('Discard draft'),
onPressed: () => _app.discardDraft(),
),
onTap: () {
@@ -569,21 +569,21 @@ class _SessionListPaneState extends State<SessionListPane> {
SlidableAction(
onPressed: (_) => _app.togglePin(session),
icon: Icons.push_pin_outlined,
label: session.isPinned ? tr('取消置顶') : tr('置顶'),
label: session.isPinned ? tr('Unpin') : tr('Pin'),
backgroundColor: scheme.secondaryContainer,
foregroundColor: scheme.onSecondaryContainer,
),
SlidableAction(
onPressed: (_) => _archive(session, archived),
icon: archived ? Icons.unarchive_outlined : Icons.archive_outlined,
label: archived ? tr('取消归档') : tr('归档'),
label: archived ? tr('Unarchive') : tr('Archive'),
backgroundColor: scheme.surfaceContainerHighest,
foregroundColor: scheme.onSurface,
),
SlidableAction(
onPressed: (_) => _confirmDelete(session),
icon: Icons.delete_outline,
label: tr('删除'),
label: tr('Delete'),
backgroundColor: scheme.errorContainer,
foregroundColor: scheme.onErrorContainer,
),
@@ -615,7 +615,7 @@ class _SessionListPaneState extends State<SessionListPane> {
? Icons.expand_more
: Icons.chevron_right,
size: 18),
tooltip: expanded ? tr('收起子代理') : tr('展开子代理'),
tooltip: expanded ? tr('Collapse subagents') : tr('Expand subagents'),
padding: EdgeInsets.zero,
visualDensity: VisualDensity.compact,
constraints:
@@ -629,8 +629,8 @@ class _SessionListPaneState extends State<SessionListPane> {
}),
),
),
title: AppText(
session.title.isEmpty ? '(无标题会话)' : session.title,
title: Text(
session.title.isEmpty ? tr('(Untitled session)') : session.title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -638,8 +638,8 @@ class _SessionListPaneState extends State<SessionListPane> {
fontWeight: selected ? FontWeight.w600 : FontWeight.w400,
),
),
subtitle: AppText(
child ? trArgs('子代理 · {0}', [_subtitle(session)]) : _subtitle(session),
subtitle: Text(
child ? trArgs('Subagent · {0}', [_subtitle(session)]) : _subtitle(session),
maxLines: 1,
overflow: TextOverflow.ellipsis),
trailing: Row(
@@ -696,22 +696,22 @@ class _SessionListPaneState extends State<SessionListPane> {
case 'copy':
Clipboard.setData(ClipboardData(text: session.id));
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: AppText('已复制会话 ID')));
const SnackBar(content: AppText('Session ID copied')));
break;
}
},
itemBuilder: (_) => [
if (!archived) ...[
const PopupMenuItem(value: 'rename', child: AppText('重命名')),
const PopupMenuItem(value: 'rename', child: AppText('Rename')),
PopupMenuItem(
value: 'pin',
child: AppText(session.isPinned ? '取消置顶' : '置顶')),
child: AppText(session.isPinned ? 'Unpin' : 'Pin')),
],
PopupMenuItem(
value: 'archive',
child: AppText(archived ? '取消归档' : '归档')),
const PopupMenuItem(value: 'delete', child: AppText('删除')),
const PopupMenuItem(value: 'copy', child: AppText('复制会话 ID')),
child: AppText(archived ? 'Unarchive' : 'Archive')),
const PopupMenuItem(value: 'delete', child: AppText('Delete')),
const PopupMenuItem(value: 'copy', child: AppText('Copy session ID')),
],
),
);
@@ -731,7 +731,7 @@ class _SessionListPaneState extends State<SessionListPane> {
width: 16,
height: 16,
child: CircularProgressIndicator(strokeWidth: 2))
: const AppText('载入更多'),
: const AppText('Load more'),
),
TextButton.icon(
icon: Icon(
@@ -741,10 +741,10 @@ class _SessionListPaneState extends State<SessionListPane> {
size: 16),
label: AppText(
_showArchived
? '隐藏已归档'
? 'Hide archived'
: archivedCount == null
? '显示已归档'
: trArgs('显示已归档 ({0})', [archivedCount]),
? 'Show archived'
: trArgs('Show archived ({0})', [archivedCount]),
style: const TextStyle(fontSize: 12.5),
),
onPressed: app.archivedLoading ? null : _toggleArchived,
@@ -765,7 +765,7 @@ class _SessionListPaneState extends State<SessionListPane> {
app.archivedSessions.isEmpty)
Padding(
padding: const EdgeInsets.only(bottom: 8),
child: AppText('没有已归档的会话',
child: AppText('No archived sessions',
style: TextStyle(fontSize: 12, color: scheme.outline)),
),
],
@@ -785,7 +785,7 @@ class _SessionListPaneState extends State<SessionListPane> {
final parts = <String>[];
if (s.agent.isNotEmpty) parts.add(s.agent);
final children = _childrenOf(s).length;
if (children > 0) parts.add(trArgs('{0} 个子代理', [children]));
if (children > 0) parts.add(trArgs('{0} subagents', [children]));
if (s.model != null) parts.add(_app.modelName(s.model));
if (s.updated > 0) {
final t = DateTime.fromMillisecondsSinceEpoch(s.updated);
@@ -812,18 +812,18 @@ class _SessionListPaneState extends State<SessionListPane> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('重命名'),
title: const AppText('Rename'),
content: TextField(controller: ctrl, autofocus: true),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
_app.client?.updateSession(s.id, title: ctrl.text);
},
child: const AppText('保存'),
child: const AppText('Save'),
),
],
),
@@ -834,12 +834,12 @@ class _SessionListPaneState extends State<SessionListPane> {
showDialog(
context: context,
builder: (context) => AlertDialog(
title: const AppText('删除会话?'),
content: AppText(trArgs('“{0}”及其子会话将被删除,且无法恢复。', [s.title])),
title: const AppText('Delete session?'),
content: AppText(trArgs('“{0}” and its subagent sessions will be deleted permanently.', [s.title])),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () {
Navigator.pop(context);
@@ -848,7 +848,7 @@ class _SessionListPaneState extends State<SessionListPane> {
_app.archivedSessions.removeWhere((x) => x.id == s.id);
_app.touch();
},
child: const AppText('删除'),
child: const AppText('Delete'),
),
],
),
@@ -865,20 +865,20 @@ class _SessionListPaneState extends State<SessionListPane> {
children: [
const Padding(
padding: EdgeInsets.all(12),
child: AppText('服务器',
child: AppText('Servers',
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
),
for (final c in app.connections) ...[
ListTile(
title: AppText(c.label),
subtitle: AppText(c.isRelay
? trArgs('经由 Relay · {0}', [c.serverId])
title: Text(c.label),
subtitle: Text(c.isRelay
? trArgs('Via Relay · {0}', [c.serverId])
: (c.proxy.isEmpty
? c.url
: trArgs('{0}\n经由 {1}', [c.url, c.proxy]))),
: trArgs('{0}\nvia {1}', [c.url, c.proxy]))),
trailing: app.conn?.id == c.id
? AppText('已连接',
? AppText('Connected',
style: TextStyle(
color: Theme.of(context).colorScheme.primary))
: null,
@@ -890,7 +890,7 @@ class _SessionListPaneState extends State<SessionListPane> {
],
ListTile(
leading: const Icon(Icons.add),
title: const AppText('添加服务器'),
title: const AppText('Add server'),
onTap: () {
Navigator.pop(context);
Navigator.of(context).push(MaterialPageRoute(
@@ -900,8 +900,8 @@ class _SessionListPaneState extends State<SessionListPane> {
),
ListTile(
leading: const Icon(Icons.qr_code_2),
title: const AppText('配对链接'),
subtitle: const AppText('直连地址或 OpenChamber Relay'),
title: const AppText('Pairing link'),
subtitle: const AppText('Direct address or OpenChamber Relay'),
onTap: () {
Navigator.pop(context);
showPairingDialog(context, app);
@@ -910,7 +910,7 @@ class _SessionListPaneState extends State<SessionListPane> {
if (app.client != null)
ListTile(
leading: const Icon(Icons.link_off),
title: const AppText('断开当前连接'),
title: const AppText('Disconnect'),
onTap: () {
Navigator.pop(context);
app.disconnect();
+110 -111
View File
@@ -21,52 +21,52 @@ class SettingsScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const AppText('设置')),
appBar: AppBar(title: const AppText('Settings')),
body: ListView(
padding: const EdgeInsets.only(top: 4, bottom: 32),
children: [
const _SectionHeader('常规'),
const _SectionHeader('General'),
_Section(children: [
_NavTile(
icon: Icons.translate,
title: '语言',
subtitle: '跟随系统、中文或 English',
title: 'Language',
subtitle: 'Follow the system, Chinese or English',
builder: (_) => const LanguageSettingsPage(),
),
_NavTile(
icon: Icons.tune,
title: '通用',
subtitle: '智能体工具与记忆',
title: 'Agent tools',
subtitle: 'Agent tools and memory',
builder: (_) => GeneralSettingsPage(app: app),
),
_NavTile(
icon: Icons.chat_bubble_outline,
title: '聊天',
subtitle: '追问处理行为',
title: 'Chat',
subtitle: 'Follow-up behavior',
builder: (_) => ChatSettingsPage(app: app),
),
]),
const _SectionHeader('外观', note: '仅当前设备生效,不同步到服务器'),
const _SectionHeader('Appearance', note: 'Applies to this device only; not synced to the server'),
_Section(children: [
_NavTile(
icon: Icons.palette_outlined,
title: '主题',
subtitle: '主题模式与主题色',
title: 'Theme',
subtitle: 'Theme mode and color',
builder: (_) => const ThemeSettingsPage(),
),
_NavTile(
icon: Icons.pets_outlined,
title: '宠物',
subtitle: '导入、启用与大小',
title: 'Pet',
subtitle: 'Import, enable and size',
builder: (_) => const PetSettingsPage(),
),
]),
const _SectionHeader('帮助与关于'),
const _SectionHeader('Help & about'),
_Section(children: [
_NavTile(
icon: Icons.info_outline,
title: '关于',
subtitle: '版本、服务端与开源许可',
title: 'About',
subtitle: 'Version, server and open-source licenses',
builder: (_) => AboutSettingsPage(app: app),
),
]),
@@ -123,7 +123,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: AppText(
trArgs('保存失败:{0}', [app.lastError ?? tr('未知错误')]))),
trArgs('Couldn\'t save: {0}', [app.lastError ?? tr('Unknown error')]))),
);
app.clearLastError();
}
@@ -133,32 +133,32 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(title: const AppText('通用')),
appBar: AppBar(title: const AppText('Agent tools')),
body: ListenableBuilder(
listenable: app,
builder: (context, _) => ListView(
padding: const EdgeInsets.only(top: 4, bottom: 32),
children: [
const _SectionHeader('在聊天中'),
const _SectionHeader('In chat'),
_Section(children: [
_switch(
icon: Icons.bar_chart,
title: '图表和原型',
subtitle: '让智能体在聊天中展示图表、表格、示意图和界面草图(与你的文件隔离),并请你在其中选择一个选项。',
title: 'Charts and prototypes',
subtitle: 'Let the agent show charts, tables, diagrams and UI sketches in chat (isolated from your files) and ask you to pick one of them.',
value: app.renderToolEnabled,
key: 'agentRenderToolEnabled',
),
_switch(
icon: Icons.image_outlined,
title: '图像',
subtitle: '让智能体用你选择的模型生成和编辑图像,费用由该模型的提供商收取。',
title: 'Images',
subtitle: 'Let the agent generate and edit images with the model you choose; the model\'s provider charges for it.',
value: app.imageToolEnabled,
key: 'agentImageToolEnabled',
),
if (app.imageToolEnabled)
ListTile(
contentPadding: const EdgeInsets.fromLTRB(52, 0, 16, 4),
title: const AppText('图像模型'),
title: const AppText('Image model'),
subtitle: AppText(_imageModelName(),
maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: const Icon(Icons.chevron_right, size: 20),
@@ -166,26 +166,26 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
),
_switch(
icon: Icons.shield_outlined,
title: '密钥',
subtitle: '允许智能体在聊天中的私密卡片上向你索取 API 密钥、令牌或密码。值不会进入对话。',
title: 'Secrets',
subtitle: 'Let the agent ask you for API keys, tokens or passwords on a private card in chat. Values never enter the conversation.',
value: app.secretToolEnabled,
key: 'agentSecretToolEnabled',
),
_switch(
icon: Icons.notifications_none,
title: '通知',
subtitle: '工作完成或卡住时,智能体会通知你。',
title: 'Notifications',
subtitle: 'The agent notifies you when work finishes or gets stuck.',
value: app.notifyToolEnabled,
key: 'agentNotifyToolEnabled',
),
]),
const _SectionHeader('智能体知道的内容'),
const _SectionHeader('What the agent knows'),
_Section(children: [
if (app.memoryToolsAvailable) ...[
_switch(
icon: Icons.psychology_outlined,
title: '记忆',
subtitle: '跨会话记住关于你和每个项目的事实。',
title: 'Memory',
subtitle: 'Remember facts about you and each project across sessions.',
value: app.memoryToolEnabled,
key: 'agentMemoryToolEnabled',
),
@@ -193,15 +193,15 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
],
_switch(
icon: Icons.sticky_note_2_outlined,
title: '项目知识',
subtitle: '让智能体读取并更新项目的笔记、待办和计划。',
title: 'Project knowledge',
subtitle: 'Let the agent read and update the project\'s notes, todos and plans.',
value: app.knowledgeToolEnabled,
key: 'agentKnowledgeToolEnabled',
),
_switch(
icon: Icons.insert_chart_outlined,
title: '用量限额',
subtitle: '让智能体查看各提供商的限额及重置时间。',
title: 'Usage limits',
subtitle: 'Let the agent check each provider\'s limits and reset times.',
value: app.usageToolEnabled,
key: 'agentUsageToolEnabled',
),
@@ -230,7 +230,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
String _imageModelName() {
final value = app.imageModel;
if (value.isEmpty) return '未选择';
if (value.isEmpty) return 'Not selected';
for (final m in _imageModels ?? const <ModelInfo>[]) {
if ('${m.providerId}/${m.id}' == value) return m.name;
}
@@ -242,7 +242,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
List<Widget> _dreaming(ThemeData theme) {
final variants = _dreamingVariants();
final name = app.memoryDreamingModel.isEmpty
? '默认模型'
? 'Default model'
: (app.modelNames[app.memoryDreamingModel] ?? app.memoryDreamingModel);
return [
InkWell(
@@ -257,10 +257,10 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
onChanged: (v) =>
_save('agentMemoryDreamingEnabled', v ?? false),
),
Expanded(child: AppText('整理记忆')),
Expanded(child: AppText('Tidy memory')),
IconButton(
icon: const Icon(Icons.info_outline, size: 18),
tooltip: tr('整理记忆'),
tooltip: tr('Tidy memory'),
onPressed: _dreamingInfo,
),
],
@@ -279,7 +279,7 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
alignment: Alignment.centerLeft,
padding: const EdgeInsets.symmetric(horizontal: 12),
),
child: AppText(name,
child: Text(name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 13)),
@@ -295,9 +295,9 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
style: TextStyle(
fontSize: 13, color: theme.colorScheme.onSurface),
items: [
const DropdownMenuItem(value: '', child: AppText('默认')),
const DropdownMenuItem(value: '', child: AppText('Default')),
for (final v in variants)
DropdownMenuItem(value: v, child: AppText(v)),
DropdownMenuItem(value: v, child: Text(v)),
],
onChanged: (v) => _save('agentMemoryDreamingVariant', v ?? ''),
),
@@ -321,12 +321,12 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
await showDialog<void>(
context: context,
builder: (dialog) => AlertDialog(
title: const AppText('整理记忆'),
title: const AppText('Tidy memory'),
content: const AppText(
'每天一次,在没有会话运行时,智能体会在后台整理记忆:合并重复条目,删除已过时或项目文档中已有的内容。'),
'Once a day, when no session is running, the agent tidies memory in the background: merging duplicates and removing entries that are obsolete or already in the project docs.'),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialog), child: const AppText('知道了')),
onPressed: () => Navigator.pop(dialog), child: const AppText('Got it')),
],
),
);
@@ -337,14 +337,14 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
if (!mounted) return;
if (models.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: AppText('你的提供商中没有图像模型')),
const SnackBar(content: AppText('Your provider has no image models')),
);
return;
}
final picked = await _chooseFromSheet(
context: context,
title: '图像模型',
noneLabel: '不指定',
title: 'Image model',
noneLabel: 'None',
selected: app.imageModel,
options: [
for (final m in models)
@@ -370,8 +370,8 @@ class _GeneralSettingsPageState extends State<GeneralSettingsPage> {
if (!mounted) return;
final picked = await _chooseFromSheet(
context: context,
title: '整理记忆使用的模型',
noneLabel: '默认模型',
title: 'Model for tidying memory',
noneLabel: 'Default model',
selected: app.memoryDreamingModel,
options: [
for (final m in app.modelList)
@@ -451,14 +451,13 @@ class LanguageSettingsPage extends StatelessWidget {
Widget build(BuildContext context) {
final l10n = L10n.instance;
return Scaffold(
appBar: AppBar(title: const AppText('语言')),
appBar: AppBar(title: const AppText('Language')),
body: ListenableBuilder(
listenable: l10n,
builder: (context, _) {
final english = l10n.isEnglish;
final systemName = l10n.locale.languageCode == 'zh'
? AppLanguage.zh.labelFor(english)
: AppLanguage.en.labelFor(english);
? l10n.languageLabel(AppLanguage.zh)
: l10n.languageLabel(AppLanguage.en);
return ListView(
padding: const EdgeInsets.only(top: 8, bottom: 32),
children: [
@@ -472,9 +471,9 @@ class LanguageSettingsPage extends StatelessWidget {
for (final choice in AppLanguage.values)
RadioListTile<AppLanguage>(
value: choice,
title: AppText(choice.labelFor(english)),
title: AppText(l10n.languageLabel(choice)),
subtitle: choice == AppLanguage.system
? AppText(trArgs('当前:{0}', [systemName]))
? AppText(trArgs('Current: {0}', [systemName]))
: null,
),
],
@@ -483,7 +482,7 @@ class LanguageSettingsPage extends StatelessWidget {
Padding(
padding: const EdgeInsets.fromLTRB(20, 12, 20, 0),
child: AppText(
'界面文字与系统自带的日期、时间选择器会一起切换。',
'The UI text switches together with the system\'s date and time pickers.',
style: TextStyle(
fontSize: 12.5,
color: Theme.of(context).hintColor),
@@ -519,7 +518,7 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(title: const AppText('聊天')),
appBar: AppBar(title: const AppText('Chat')),
body: ListenableBuilder(
listenable: widget.app,
builder: (context, _) {
@@ -528,8 +527,8 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
padding: const EdgeInsets.only(top: 8, bottom: 32),
children: [
const ListTile(
title: AppText('追问处理行为'),
subtitle: AppText('运行中按发送时,消息默认怎么处理。与网页端设置同步。'),
title: AppText('Follow-up behavior'),
subtitle: AppText('What happens by default when you press send while a run is in progress. Synced with the web client\'s setting.'),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 6),
@@ -538,12 +537,12 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
runSpacing: 8,
children: [
ChoiceChip(
label: const AppText('转向'),
label: const AppText('Steer'),
selected: steer,
onSelected: (_) => _setFollowUp('steer'),
),
ChoiceChip(
label: const AppText('排队'),
label: const AppText('Queue'),
selected: !steer,
onSelected: (_) => _setFollowUp('queue'),
),
@@ -553,7 +552,7 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 8),
child: AppText(
steer ? '转向:在下一步加入当前回合,工作继续。' : '排队:等当前回合结束后再发送。',
steer ? 'Steer: joins the current turn at the next step and work continues.' : 'Queue: sends after the current turn ends.',
style: TextStyle(fontSize: 12.5, color: theme.hintColor),
),
),
@@ -568,7 +567,7 @@ class _ChatSettingsPageState extends State<ChatSettingsPage> {
final ok = await widget.app.setFollowUpBehavior(value);
if (!ok && mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: AppText(widget.app.lastError ?? '保存失败')),
SnackBar(content: AppText(widget.app.lastError ?? 'Couldn\'t save')),
);
widget.app.clearLastError();
}
@@ -581,16 +580,16 @@ class ThemeSettingsPage extends StatelessWidget {
const ThemeSettingsPage({super.key});
static const _modes = [
(ThemeMode.system, '跟随系统'),
(ThemeMode.light, '浅色'),
(ThemeMode.dark, '深色'),
(ThemeMode.system, 'Follow system'),
(ThemeMode.light, 'Light'),
(ThemeMode.dark, 'Dark'),
];
@override
Widget build(BuildContext context) {
final look = AppearancePrefs.instance;
return Scaffold(
appBar: AppBar(title: const AppText('主题')),
appBar: AppBar(title: const AppText('Theme')),
body: ListenableBuilder(
listenable: look,
builder: (context, _) {
@@ -600,10 +599,10 @@ class ThemeSettingsPage extends StatelessWidget {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(20, 0, 20, 8),
child: AppText('主题只保存在本机,不随服务器同步。',
child: AppText('The theme is stored on this device only and does not sync with the server.',
style: TextStyle(fontSize: 12.5)),
),
const _Label('主题模式'),
const _Label('Theme mode'),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 12),
child: Wrap(
@@ -619,7 +618,7 @@ class ThemeSettingsPage extends StatelessWidget {
],
),
),
const _Label('主题色'),
const _Label('Accent color'),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 8),
child: Wrap(
@@ -644,7 +643,7 @@ class ThemeSettingsPage extends StatelessWidget {
return Semantics(
button: true,
selected: selected,
label: trArgs('主题色 {0}', [seed.toRadixString(16)]),
label: trArgs('Accent color {0}', [seed.toRadixString(16)]),
child: InkWell(
borderRadius: BorderRadius.circular(22),
onTap: () => look.setSeedColor(seed),
@@ -690,7 +689,7 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Scaffold(
appBar: AppBar(title: const AppText('宠物')),
appBar: AppBar(title: const AppText('Pet')),
body: ListenableBuilder(
listenable: PetLibrary.instance,
builder: (context, _) {
@@ -701,7 +700,7 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(20, 0, 20, 8),
child: AppText('默认不提供宠物;宠物包只存放在本机。',
child: AppText('No pet is included; pet packs stay on this device.',
style: TextStyle(fontSize: 12.5)),
),
if (pack == null) ..._empty(theme) else ..._loaded(theme, pack),
@@ -714,15 +713,15 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
List<Widget> _empty(ThemeData theme) => [
const ListTile(
title: AppText('尚未导入宠物'),
subtitle: AppText('导入一个宠物包(.zip)后,它会站在输入框上方。'),
title: AppText('No pet imported'),
subtitle: AppText('Import a pet pack (.zip) and it will stand above the input box.'),
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 8),
child: FilledButton.tonalIcon(
onPressed: _importPet,
icon: const Icon(Icons.file_upload_outlined, size: 18),
label: const AppText('导入宠物包'),
label: const AppText('Import pet pack'),
),
),
];
@@ -733,27 +732,27 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
[pack.author, pack.license].where((s) => s.trim().isNotEmpty).join(' · ');
return [
ListTile(
title: AppText(pack.name.isEmpty ? pack.id : pack.name),
title: Text(pack.name.isEmpty ? pack.id : pack.name),
subtitle: info.isEmpty
? null
: AppText(info, maxLines: 2, overflow: TextOverflow.ellipsis),
: Text(info, maxLines: 2, overflow: TextOverflow.ellipsis),
),
SwitchListTile(
title: const AppText('启用宠物'),
subtitle: const AppText('站在输入框上方,默认关闭'),
title: const AppText('Enable pet'),
subtitle: const AppText('Stands above the input box; off by default'),
value: library.enabled,
onChanged: (v) => library.setEnabled(v),
),
const _Label('大小'),
const _Label('Size'),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 8),
child: Wrap(
spacing: 8,
children: [
for (final (size, label) in const [
(40.0, '小'),
(52.0, '中'),
(64.0, '大'),
(40.0, 'Small'),
(52.0, 'Medium'),
(64.0, 'Large'),
])
ChoiceChip(
label: AppText(label),
@@ -770,12 +769,12 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
FilledButton.tonalIcon(
onPressed: _importPet,
icon: const Icon(Icons.swap_horiz, size: 18),
label: const AppText('更换宠物包'),
label: const AppText('Change pet pack'),
),
const SizedBox(width: 8),
TextButton(
onPressed: _confirmRemovePet,
child: const AppText('移除'),
child: const AppText('Remove'),
),
],
),
@@ -786,7 +785,7 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
Future<void> _importPet() async {
try {
final file = await FilePicker.pickFile(
dialogTitle: tr('选择宠物包(.zip)'),
dialogTitle: tr('Select a pet pack (.zip)'),
type: FileType.custom,
allowedExtensions: const ['zip'],
);
@@ -797,12 +796,12 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: AppText(trArgs(
'已导入 {0}', [pack.name.isEmpty ? pack.id : pack.name]))),
'Imported {0}', [pack.name.isEmpty ? pack.id : pack.name]))),
);
} catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: AppText(trArgs('导入失败:{0}', [e]))),
SnackBar(content: AppText(trArgs('Import failed: {0}', [e]))),
);
}
}
@@ -811,15 +810,15 @@ class _PetSettingsPageState extends State<PetSettingsPage> {
final ok = await showDialog<bool>(
context: context,
builder: (dialog) => AlertDialog(
title: const AppText('移除宠物?'),
content: const AppText('本机保存的宠物包会被删除。'),
title: const AppText('Remove pet?'),
content: const AppText('The pet pack stored on this device will be deleted.'),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialog, false),
child: const AppText('取消')),
child: const AppText('Cancel')),
FilledButton(
onPressed: () => Navigator.pop(dialog, true),
child: const AppText('移除')),
child: const AppText('Remove')),
],
),
);
@@ -873,11 +872,11 @@ class _AboutSettingsPageState extends State<AboutSettingsPage> {
width: 14, height: 14, child: CircularProgressIndicator(strokeWidth: 1.6));
}
final text = !_loaded
? '读取中…'
? 'Loading…'
: widget.app.client == null
? '未连接'
? 'Not connected'
: value.isEmpty
? '未获取到'
? 'Not available'
: value;
return AppText(text,
style: TextStyle(
@@ -893,11 +892,11 @@ class _AboutSettingsPageState extends State<AboutSettingsPage> {
final versions = _versions;
return Scaffold(
appBar: AppBar(
title: const AppText('关于'),
title: const AppText('About'),
actions: [
IconButton(
icon: const Icon(Icons.refresh),
tooltip: tr('重新获取服务端版本'),
tooltip: tr('Fetch the server version again'),
onPressed: _loading ? null : _load,
),
],
@@ -927,7 +926,7 @@ class _AboutSettingsPageState extends State<AboutSettingsPage> {
AppText('OpenChamber',
style: theme.textTheme.titleLarge
?.copyWith(fontWeight: FontWeight.w600)),
AppText('手机客户端',
AppText('Mobile client',
style: TextStyle(
fontSize: 12.5, color: theme.hintColor)),
],
@@ -936,27 +935,27 @@ class _AboutSettingsPageState extends State<AboutSettingsPage> {
],
),
),
const _SectionHeader('应用'),
const _SectionHeader('App'),
_Section(children: [
ListTile(
leading: const Icon(Icons.tag, size: 20),
title: const AppText('版本'),
title: const AppText('Version'),
trailing: AppText(
appVersion.isEmpty ? '未知' : appVersion,
appVersion.isEmpty ? 'Unknown' : appVersion,
style: const TextStyle(fontSize: 13),
),
),
ListTile(
leading: const Icon(Icons.description_outlined, size: 20),
title: const AppText('开源许可'),
subtitle: const AppText('本应用使用的第三方组件与它们的许可证'),
title: const AppText('Open-source licenses'),
subtitle: const AppText('Third-party components used by this app and their licenses'),
trailing: const Icon(Icons.chevron_right, size: 20),
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (_) => const LicensesPage(),
)),
),
]),
const _SectionHeader('服务端', note: '版本取自当前连接的服务器'),
const _SectionHeader('Server', note: 'Version comes from the currently connected server'),
_Section(children: [
ListTile(
leading: const Icon(Icons.terminal, size: 20),
@@ -1015,7 +1014,7 @@ class _LicensesPageState extends State<LicensesPage> {
final theme = Theme.of(context);
final licenses = _licenses;
return Scaffold(
appBar: AppBar(title: const AppText('开源许可')),
appBar: AppBar(title: const AppText('Open-source licenses')),
body: licenses == null
? const Center(child: CircularProgressIndicator())
: ListView.separated(
@@ -1028,7 +1027,7 @@ class _LicensesPageState extends State<LicensesPage> {
return Padding(
padding: const EdgeInsets.fromLTRB(20, 14, 20, 14),
child: AppText(
'下面列出随本应用打包的第三方组件;点开可阅读完整许可证。',
'Third-party components bundled with this app are listed below; tap one to read its full license.',
style:
TextStyle(fontSize: 12.5, color: theme.hintColor),
),
@@ -1036,7 +1035,7 @@ class _LicensesPageState extends State<LicensesPage> {
}
final name = licenses.keys.elementAt(i - 1);
return ListTile(
title: AppText(name),
title: Text(name),
trailing: const Icon(Icons.chevron_right, size: 20),
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (_) => _LicenseTextPage(
@@ -1073,11 +1072,11 @@ class _LicenseTextPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: AppText(name)),
appBar: AppBar(title: Text(name)),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: SelectableText(
text.isEmpty ? tr('该组件没有附带许可证文本。') : text,
text.isEmpty ? tr('This component has no license text.') : text,
style: const TextStyle(fontSize: 12, fontFamily: 'monospace', height: 1.45),
),
),
+18 -18
View File
@@ -121,20 +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 => (tr('未启动'), theme.hintColor),
TerminalLinkState.creating => (tr('正在创建…'), theme.hintColor),
TerminalLinkState.connecting => (tr('正在连接…'), theme.hintColor),
TerminalLinkState.idle => (tr('Not started'), theme.hintColor),
TerminalLinkState.creating => (tr('Creating…'), theme.hintColor),
TerminalLinkState.connecting => (tr('Connecting…'), 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),
(tr('Connection lost, reconnecting…'), scheme.error),
TerminalLinkState.open => (tr('Running'), scheme.primary),
TerminalLinkState.exited => (state.detail ?? tr('Exited'), theme.hintColor),
TerminalLinkState.error => (state.detail ?? tr('Connection failed'), scheme.error),
};
return Row(
children: [
Expanded(
child: PopupMenuButton<int>(
tooltip: tr('切换终端'),
tooltip: tr('Switch terminal'),
position: PopupMenuPosition.under,
onSelected: _onTabMenu,
itemBuilder: (_) => [
@@ -154,7 +154,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
),
const SizedBox(width: 10),
Expanded(
child: AppText(
child: Text(
_workspace.tabs[i].label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -170,7 +170,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
children: [
Icon(Icons.add, size: 18),
SizedBox(width: 10),
AppText('新建终端'),
AppText('New terminal'),
],
),
),
@@ -183,7 +183,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
Icon(Icons.circle, size: 8, color: color),
const SizedBox(width: 6),
Flexible(
child: AppText(
child: Text(
tab.label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -193,7 +193,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
),
const SizedBox(width: 4),
Flexible(
child: AppText(
child: Text(
'· $label',
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -207,13 +207,13 @@ class _TerminalPanelState extends State<TerminalPanel> {
),
),
IconButton(
tooltip: tr('键盘'),
tooltip: tr('Keyboard'),
visualDensity: VisualDensity.compact,
icon: const Icon(Icons.keyboard_outlined, size: 18),
onPressed: () => _focus.requestFocus(),
),
IconButton(
tooltip: tr('重新启动'),
tooltip: tr('Restart'),
visualDensity: VisualDensity.compact,
icon: const Icon(Icons.restart_alt, size: 18),
onPressed: state.link == TerminalLinkState.exited ||
@@ -223,7 +223,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
: null,
),
PopupMenuButton<String>(
tooltip: tr('更多'),
tooltip: tr('More'),
icon: const Icon(Icons.more_vert, size: 18),
onSelected: (value) {
switch (value) {
@@ -236,8 +236,8 @@ class _TerminalPanelState extends State<TerminalPanel> {
}
},
itemBuilder: (_) => const [
PopupMenuItem(value: 'clear', child: AppText('清屏')),
PopupMenuItem(value: 'close', child: AppText('关闭此终端')),
PopupMenuItem(value: 'clear', child: AppText('Clear screen')),
PopupMenuItem(value: 'close', child: AppText('Close this terminal')),
],
),
],
@@ -336,7 +336,7 @@ class _TerminalPanelState extends State<TerminalPanel> {
border: Border.all(
color: active ? scheme.primary : Colors.transparent, width: 1),
),
child: AppText(
child: Text(
label,
maxLines: 1,
style: TextStyle(