feat: English and Chinese, and selectable chat text

- settings → general → language picks system, Chinese or English; the
  choice is stored on the device and read before the first frame
- our Chinese strings are translated through tr()/trArgs() and AppText,
  with the English in lib/l10n/en_*.dart; a missing entry falls back to
  Chinese and a test checks that every literal in lib has one
- AppText rebuilds on a language change (it depends on the resolved
  locale), so const text and whole pages switch at once; the built-in
  date/time pickers and selection menu follow the same language
- server and user data (titles, messages, prompts, paths) is never
  translated
- the chat list sits in a SelectionArea: long-press selects message text
  and shows the copy/select-all menu
- bump to 0.5.2
This commit is contained in:
blumia committed 2026-11-26 09:04:25 +08:00
1 parent da4bfb6826
commit 7b5bccf28f
42 files changed
+1943 -735

No files matched your search

+17 -16
View File
@@ -13,6 +13,7 @@ import '../widgets/pet_sprite.dart';
import '../widgets/project_icon.dart';
import '../widgets/slash_palette.dart';
import 'files_panel.dart';
import '../l10n.dart';
class NewSessionScreen extends StatefulWidget {
final AppState app;
@@ -176,7 +177,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('选择失败:$e')));
.showSnackBar(SnackBar(content: AppText(trArgs('选择失败:{0}', [e]))));
}
} finally {
if (mounted) setState(() => _attaching = false);
@@ -207,14 +208,14 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
? null
: IconButton(
icon: const Icon(Icons.menu),
tooltip: '会话',
tooltip: tr('会话'),
onPressed: widget.onOpenSessions,
),
title: const Text('新会话'),
title: const AppText('新会话'),
actions: [
IconButton(
icon: const Icon(Icons.folder_open_outlined),
tooltip: '文件',
tooltip: tr('文件'),
onPressed: () => showFilesPanel(context, app, draft.directory),
),
],
@@ -228,7 +229,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
child: Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Text(
child: AppText(
'我们今天要做什么?',
textAlign: TextAlign.center,
style: TextStyle(
@@ -252,7 +253,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
if (draft.error != null)
Padding(
padding: const EdgeInsets.only(bottom: 6),
child: Text(
child: AppText(
draft.error!,
style: TextStyle(
fontSize: 12.5, color: scheme.error),
@@ -300,7 +301,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
const SizedBox(width: 5),
ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 170),
child: Text(
child: AppText(
label.isEmpty ? '选择项目' : label,
maxLines: 1,
overflow: TextOverflow.ellipsis,
@@ -322,7 +323,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
Widget body = ComposerBox(
controller: _text,
focusNode: _inputFocus,
hint: '规划、构建或提问',
hint: tr('规划、构建或提问'),
maxLines: 5,
keyboardInset: keyboardInset,
textInputAction:
@@ -354,7 +355,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
},
leading: _roundKey(
icon: Icons.attach_file,
label: '添加附件',
label: tr('添加附件'),
onTap: _pickFiles,
busy: _attaching,
),
@@ -477,7 +478,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
children: [
const Padding(
padding: EdgeInsets.fromLTRB(16, 14, 16, 6),
child: Text('选择项目',
child: AppText('选择项目',
style:
TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
),
@@ -489,8 +490,8 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
dense: true,
leading: ProjectIcon(
app: widget.app, chat: true, size: 20),
title: const Text('聊天'),
subtitle: const Text('不关联项目,保存在 OpenChamber 的聊天目录'),
title: const AppText('聊天'),
subtitle: const AppText('不关联项目,保存在 OpenChamber 的聊天目录'),
trailing: draft.directory == AppState.chatTarget
? Icon(Icons.check,
size: 18,
@@ -508,9 +509,9 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
dense: true,
leading:
ProjectIcon(app: widget.app, project: project, size: 20),
title: Text(project.label,
title: AppText(project.label,
maxLines: 1, overflow: TextOverflow.ellipsis),
subtitle: Text(project.canonical,
subtitle: AppText(project.canonical,
maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: project.canonical == draft.directory
? Icon(Icons.check,
@@ -527,7 +528,7 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
if (projects.isEmpty)
const Padding(
padding: EdgeInsets.all(24),
child: Text('没有可用的项目', textAlign: TextAlign.center),
child: AppText('没有可用的项目', textAlign: TextAlign.center),
),
],
),
@@ -555,4 +556,4 @@ class _NewSessionScreenState extends State<NewSessionScreen> {
}
return byPath.values.toList();
}
}
}