feat: English and Chinese, and selectable chat text
- settings → general → language picks system, Chinese or English; the choice is stored on the device and read before the first frame - our Chinese strings are translated through tr()/trArgs() and AppText, with the English in lib/l10n/en_*.dart; a missing entry falls back to Chinese and a test checks that every literal in lib has one - AppText rebuilds on a language change (it depends on the resolved locale), so const text and whole pages switch at once; the built-in date/time pickers and selection menu follow the same language - server and user data (titles, messages, prompts, paths) is never translated - the chat list sits in a SelectionArea: long-press selects message text and shows the copy/select-all menu - bump to 0.5.2
This commit is contained in:
1 parent
da4bfb6826
commit
7b5bccf28f
42 files changed
+1943
-735
No files matched your search
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import '../api/models.dart';
|
||||
import '../model_prefs.dart';
|
||||
import '../state.dart';
|
||||
import '../l10n.dart';
|
||||
|
||||
Future<void> showModelPickerSheet(
|
||||
BuildContext context, {
|
||||
@@ -69,16 +70,16 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.fromLTRB(12, 12, 12, 4),
|
||||
child: Text('选择模型',
|
||||
child: AppText('选择模型',
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold)),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: TextField(
|
||||
onChanged: (v) => setState(() => _filter = v),
|
||||
decoration: const InputDecoration(
|
||||
hintText: '搜索',
|
||||
border: OutlineInputBorder(),
|
||||
decoration: InputDecoration(
|
||||
hintText: tr('搜索'),
|
||||
border: const OutlineInputBorder(),
|
||||
isDense: true),
|
||||
),
|
||||
),
|
||||
@@ -92,7 +93,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
Widget _models() {
|
||||
final all = widget.app.modelList;
|
||||
if (all.isEmpty) {
|
||||
return const Center(child: Text('正在载入模型…'));
|
||||
return const Center(child: AppText('正在载入模型…'));
|
||||
}
|
||||
final filter = _filter.trim().toLowerCase();
|
||||
final matching = filter.isEmpty
|
||||
@@ -103,7 +104,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
m.id.toLowerCase().contains(filter))
|
||||
m,
|
||||
];
|
||||
if (matching.isEmpty) return const Center(child: Text('没有结果'));
|
||||
if (matching.isEmpty) return const Center(child: AppText('没有结果'));
|
||||
|
||||
final byKey = {
|
||||
for (final m in all) ModelPrefs.keyFor(m.providerId, m.id): m,
|
||||
@@ -125,7 +126,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
final children = <Widget>[];
|
||||
if (filter.isEmpty) {
|
||||
if (favorites.isNotEmpty) {
|
||||
children.add(_sectionHeader('收藏', 'favorites', count: favorites.length));
|
||||
children.add(_sectionHeader(tr('收藏'), 'favorites', count: favorites.length));
|
||||
if (!_collapsed.contains('favorites')) {
|
||||
for (final model in favorites) {
|
||||
children.add(_modelRow(model));
|
||||
@@ -133,7 +134,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
}
|
||||
}
|
||||
if (recents.isNotEmpty) {
|
||||
children.add(_sectionHeader('最近', 'recents', count: recents.length));
|
||||
children.add(_sectionHeader(tr('最近'), 'recents', count: recents.length));
|
||||
if (!_collapsed.contains('recents')) {
|
||||
for (final model in recents) {
|
||||
children.add(_modelRow(model));
|
||||
@@ -142,7 +143,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
}
|
||||
}
|
||||
for (final entry in providers.entries) {
|
||||
final label = entry.key.isEmpty ? '其它' : entry.key;
|
||||
final label = entry.key.isEmpty ? tr('其它') : entry.key;
|
||||
children.add(_sectionHeader(label, 'provider:${entry.key}',
|
||||
count: entry.value.length));
|
||||
if (!_collapsed.contains('provider:${entry.key}')) {
|
||||
@@ -172,8 +173,8 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
size: 16, color: Theme.of(context).hintColor),
|
||||
const SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Text(
|
||||
count == null ? label : '$label($count)',
|
||||
child: AppText(
|
||||
count == null ? label : trArgs('{0}({1})', [label, count]),
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w700,
|
||||
@@ -199,7 +200,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
title: Row(
|
||||
children: [
|
||||
Flexible(
|
||||
child: Text(model.name,
|
||||
child: AppText(model.name,
|
||||
maxLines: 1, overflow: TextOverflow.ellipsis),
|
||||
),
|
||||
if (model.reasoning)
|
||||
@@ -211,7 +212,8 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
],
|
||||
),
|
||||
subtitle: model.context > 0
|
||||
? Text('${formatTokenCount(model.context)} 上下文',
|
||||
? AppText(
|
||||
trArgs('{0} 上下文', [formatTokenCount(model.context)]),
|
||||
style: TextStyle(fontSize: 11, color: theme.hintColor))
|
||||
: null,
|
||||
trailing: Row(
|
||||
@@ -230,7 +232,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
size: 18,
|
||||
color: favorite ? theme.colorScheme.primary : theme.hintColor,
|
||||
),
|
||||
tooltip: favorite ? '取消收藏' : '收藏',
|
||||
tooltip: favorite ? tr('取消收藏') : tr('收藏'),
|
||||
onPressed: () async {
|
||||
await _prefs.toggleFavorite(key);
|
||||
if (mounted) setState(() {});
|
||||
@@ -287,12 +289,12 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
const Text('思考强度',
|
||||
const AppText('思考强度',
|
||||
style: TextStyle(
|
||||
fontSize: 13, fontWeight: FontWeight.w700)),
|
||||
const SizedBox(width: 6),
|
||||
Expanded(
|
||||
child: Text(model.name,
|
||||
child: AppText(model.name,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
@@ -300,7 +302,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: const Text('完成'),
|
||||
child: const AppText('完成'),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -310,7 +312,7 @@ class _PickerSheetState extends State<_PickerSheet> {
|
||||
children: [
|
||||
for (final option in options)
|
||||
ChoiceChip(
|
||||
label: Text(effortLabel(option),
|
||||
label: AppText(effortLabel(option),
|
||||
style: const TextStyle(fontSize: 12.5)),
|
||||
selected: (_effortVariant ?? '') == (option ?? ''),
|
||||
onSelected: (_) => _pickEffort(model, option),
|
||||
|
||||
Reference in new issue
Block a user