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,8 @@ import 'dart:io';
|
||||
|
||||
import 'package:socks5_proxy/socks_client.dart';
|
||||
|
||||
import '../l10n.dart';
|
||||
|
||||
/// One request: a method, a path relative to the server root, its query, the
|
||||
/// headers already decided by [Client] (auth, directory, accept, …) and an
|
||||
/// optional complete body.
|
||||
@@ -96,7 +98,7 @@ class CancelToken {
|
||||
class DownloadCancelled implements Exception {
|
||||
const DownloadCancelled();
|
||||
@override
|
||||
String toString() => '下载已取消';
|
||||
String toString() => tr('下载已取消');
|
||||
}
|
||||
|
||||
/// A proxy as configured: an HTTP CONNECT proxy, or a SOCKS5 one.
|
||||
@@ -118,13 +120,14 @@ ProxyConfig? parseProxy(String? raw) {
|
||||
if (!normalized.contains('://')) normalized = 'http://$normalized';
|
||||
final uri = Uri.tryParse(normalized);
|
||||
if (uri == null || uri.host.isEmpty) {
|
||||
throw ArgumentError('代理地址无效:$raw');
|
||||
throw ArgumentError(trArgs('代理地址无效:{0}', [raw]));
|
||||
}
|
||||
final scheme = uri.scheme.toLowerCase();
|
||||
final socks = scheme == 'socks' || scheme == 'socks5' || scheme == 'socks5h';
|
||||
final http = scheme == 'http' || scheme == 'https';
|
||||
if (!socks && !http) {
|
||||
throw ArgumentError('不支持的代理协议:$scheme(支持 http、https、socks5、socks5h)');
|
||||
throw ArgumentError(trArgs(
|
||||
'不支持的代理协议:{0}(支持 http、https、socks5、socks5h)', [scheme]));
|
||||
}
|
||||
String? user;
|
||||
String? pass;
|
||||
@@ -190,7 +193,7 @@ class DirectTransport implements Transport {
|
||||
if (_proxyAddress != null) return _proxyAddress!;
|
||||
final addresses = await InternetAddress.lookup(_proxyConfig!.host);
|
||||
if (addresses.isEmpty) {
|
||||
throw const SocketException('无法解析代理主机');
|
||||
throw SocketException(tr('无法解析代理主机'));
|
||||
}
|
||||
return _proxyAddress = addresses.first;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user