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

+8 -7
View File
@@ -6,6 +6,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import '../api/models.dart';
import '../l10n.dart';
enum DiffLineKind { context, add, del, hunk, meta }
@@ -246,8 +247,8 @@ class DiffView extends StatelessWidget {
child: Row(
children: [
Expanded(
child: Text(
file.path ?? '文件 ${fileIndex + 1}',
child: AppText(
file.path ?? trArgs('文件 {0}', [fileIndex + 1]),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
@@ -278,7 +279,7 @@ class DiffView extends StatelessWidget {
rows.add(Container(
color: background,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 1),
child: Text(
child: AppText(
line.text.isEmpty ? ' ' : line.text,
style: mono.copyWith(color: foreground),
),
@@ -288,8 +289,8 @@ class DiffView extends StatelessWidget {
if (total > maxLines) {
rows.add(Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
child: Text(
'仅显示前 $maxLines 行,共 $total 行',
child: AppText(
trArgs('仅显示前 {0} 行,共 {1} 行', [maxLines, total]),
style: TextStyle(fontSize: 11, color: theme.hintColor),
),
));
@@ -332,10 +333,10 @@ class DiffStats extends StatelessWidget {
return Row(
mainAxisSize: MainAxisSize.min,
children: [
if (added > 0) Text('+$added', style: style.copyWith(color: addFg)),
if (added > 0) AppText('+$added', style: style.copyWith(color: addFg)),
if (added > 0 && removed > 0) const SizedBox(width: 4),
if (removed > 0)
Text('−$removed', style: style.copyWith(color: delFg)),
AppText('−$removed', style: style.copyWith(color: delFg)),
],
);
}