Files

154 lines
5.6 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/widgets.dart';
class AppLocalizations {
const AppLocalizations(this.locale);
final Locale locale;
static const supportedLocales = [Locale('en'), Locale('zh', 'Hans')];
static AppLocalizations of(BuildContext context) =>
Localizations.of<AppLocalizations>(context, AppLocalizations)!;
static const delegate = _AppLocalizationsDelegate();
String text(String value) {
if (locale.languageCode != 'zh') return value;
final translated = _zh[value];
if (translated != null) return translated;
final hostCount = RegExp(r'^(\d+) hosts loaded$').firstMatch(value);
if (hostCount != null) {
return format('{count} hosts loaded', {'count': hostCount.group(1)!});
}
return value;
}
String format(String value, Map<String, Object> values) {
var result = text(value);
for (final entry in values.entries) {
result = result.replaceAll('{${entry.key}}', '${entry.value}');
}
return result;
}
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
bool isSupported(Locale locale) =>
locale.languageCode == 'en' || locale.languageCode == 'zh';
@override
Future<AppLocalizations> load(Locale locale) async => AppLocalizations(
locale.languageCode == 'zh'
? const Locale('zh', 'Hans')
: const Locale('en'),
);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
const _zh = <String, String>{
'RemoteDesk': 'RemoteDesk',
'Devices': '设备',
'Sessions': '会话',
'Settings': '设置',
'Service online': '服务在线',
'Service offline': '服务离线',
'Control service online': '控制服务在线',
'Local control service is unavailable': '本地控制服务不可用',
'Control service offline': '控制服务离线',
'Checking control service': '正在检查控制服务',
'Control service is unavailable': '控制服务不可用',
'Control service did not respond': '控制服务无响应',
'Control service rejected the request': '控制服务拒绝了请求',
'Control service returned invalid data': '控制服务返回了无效数据',
'Add host': '添加主机',
'Refresh control service': '刷新控制服务',
'Search hosts': '搜索主机',
'Clear search': '清除搜索',
'No saved hosts': '暂无已保存主机',
'No matching hosts': '没有匹配的主机',
'Unable to load hosts': '无法加载主机列表',
'Host database has an invalid format': '主机数据库格式无效',
'Host list saved': '主机列表已保存',
'{count} hosts loaded': '已加载 {count} 台主机',
'New Linux host': '新建 Linux 主机',
'Linux host': 'Linux 主机',
'Delete host': '删除主机',
'Delete host?': '删除主机?',
'Remove {name} from this device?': '从此设备中移除 {name}',
'Cancel': '取消',
'Delete': '删除',
'Display name': '显示名称',
'Agent address': 'Agent 地址',
'Linux user': 'Linux 用户',
'TLS certificate SHA-256': 'TLS 证书 SHA-256',
'64 lowercase hexadecimal characters': '64 位小写十六进制字符',
'Enter a display name.': '请输入显示名称。',
'Enter the Agent address.': '请输入 Agent 地址。',
'Enter the Linux user.': '请输入 Linux 用户。',
'Enter a lowercase 64-character SHA-256 fingerprint.':
'请输入 64 位小写 SHA-256 指纹。',
'Connect desktop': '连接桌面',
'Open terminal': '打开终端',
'Test connection': '测试连接',
'Save': '保存',
'Unsaved changes': '未保存',
'Discard unsaved changes?': '放弃未保存的更改?',
'The current host changes have not been saved.': '当前主机更改尚未保存。',
'Keep editing': '继续编辑',
'Discard': '放弃更改',
'Native desktop session started': '原生桌面会话已启动',
'Native terminal started': '原生终端已启动',
'Unable to start desktop session': '无法启动桌面会话',
'Unable to start terminal': '无法启动终端',
'Session diagnostics updated': '会话诊断已更新',
'Session diagnostics unavailable': '会话诊断不可用',
'Agent probe failed': 'Agent 探测失败',
'Agent responded in {ms} ms': 'Agent 在 {ms} ms 内响应',
'Desktop ready': '桌面就绪',
'No desktop': '无桌面能力',
'Terminal ready': '终端就绪',
'No terminal': '无终端能力',
'Files ready': '文件就绪',
'No files': '无文件能力',
'Protocol {major}.{minor}': '协议 {major}.{minor}',
'No sessions yet': '暂无会话',
'Open devices': '打开设备',
'Native sessions': '原生会话',
'Refresh session diagnostics': '刷新会话诊断',
'Waiting for diagnostics': '等待诊断数据',
'Session': '会话',
'starting': '启动中',
'connecting': '连接中',
'connected': '已连接',
'reconnecting': '重连中',
'failed': '失败',
'terminated': '已结束',
'Decode': '解码',
'Present': '呈现',
'Frames': '帧数',
'Local service': '本地服务',
'Reconnect service': '重连服务',
'Session defaults': '会话默认值',
'Stream resolution': '串流分辨率',
'Open fullscreen': '打开全屏',
'Follow window size': '跟随窗口尺寸',
'Remote input': '远程输入',
'Read clipboard': '读取剪贴板',
'Write clipboard': '写入剪贴板',
'Language': '语言',
'Close to system tray': '关闭到系统托盘',
'Keep RemoteDesk running when the window is closed.':
'关闭窗口时让 RemoteDesk 继续在后台运行。',
'System default': '跟随系统',
'English': 'English',
'简体中文': '简体中文',
'Show RemoteDesk': '显示 RemoteDesk',
'Exit': '退出',
};