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

+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'),
),
],
);