feat: 全量英文界面(i18n 翻译表接入全部页面与服务层文案)
This commit is contained in:
1 parent
2eb3f42731
commit
71e76b1c2b
26 files changed
+775
-325
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
/// 服务器卡片的数据状态。
|
||||
enum ServerCardState {
|
||||
@@ -75,7 +76,7 @@ class ServerCard extends StatelessWidget {
|
||||
case ServerCardState.offline:
|
||||
return '离线';
|
||||
case ServerCardState.loading:
|
||||
return '检测中';
|
||||
return S.t('检测中');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +193,7 @@ class ServerCard extends StatelessWidget {
|
||||
|
||||
Widget _buildMenu(BuildContext context, ColorScheme scheme) {
|
||||
return PopupMenuButton<String>(
|
||||
tooltip: '更多操作',
|
||||
tooltip: S.t('更多操作'),
|
||||
icon: Icon(Icons.more_vert, size: 20, color: scheme.onSurfaceVariant),
|
||||
padding: EdgeInsets.zero,
|
||||
itemBuilder: (context) => [
|
||||
@@ -203,7 +204,7 @@ class ServerCard extends StatelessWidget {
|
||||
children: [
|
||||
Icon(Icons.edit_outlined, size: 19),
|
||||
SizedBox(width: 12),
|
||||
Text('编辑'),
|
||||
T('编辑'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -214,7 +215,7 @@ class ServerCard extends StatelessWidget {
|
||||
children: [
|
||||
Icon(Icons.delete_outline, size: 19, color: scheme.error),
|
||||
const SizedBox(width: 12),
|
||||
Text('删除', style: TextStyle(color: scheme.error)),
|
||||
T('删除', style: TextStyle(color: scheme.error)),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -255,9 +256,9 @@ class ServerCard extends StatelessWidget {
|
||||
|
||||
if (state == ServerCardState.loading) {
|
||||
return _pillRow(context, [
|
||||
const _Pill(
|
||||
_Pill(
|
||||
icon: Icons.autorenew_rounded,
|
||||
label: '正在获取状态',
|
||||
label: S.t('正在获取状态'),
|
||||
color: Color(0xFF94A3B8),
|
||||
),
|
||||
]);
|
||||
@@ -266,16 +267,16 @@ class ServerCard extends StatelessWidget {
|
||||
if (!online) {
|
||||
return Row(
|
||||
children: [
|
||||
const Flexible(
|
||||
Flexible(
|
||||
child: _Pill(
|
||||
icon: Icons.cloud_off_outlined,
|
||||
label: '无法连接',
|
||||
label: S.t('无法连接'),
|
||||
color: Color(0xFFF87171),
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
'点击重试',
|
||||
S.t('点击重试'),
|
||||
style: theme.textTheme.labelSmall?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -291,7 +292,7 @@ class ServerCard extends StatelessWidget {
|
||||
icon: Icons.people_alt_outlined,
|
||||
label: maxPlayers != null
|
||||
? '${playerCount ?? 0}/$maxPlayers'
|
||||
: '${playerCount ?? 0} 人',
|
||||
: S.f('{0} 人', [playerCount ?? 0]),
|
||||
color: scheme.primary,
|
||||
emphasized: true,
|
||||
),
|
||||
@@ -313,7 +314,7 @@ class ServerCard extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(
|
||||
'进入控制台',
|
||||
S.t('进入控制台'),
|
||||
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||
color: scheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../providers/server_provider.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
class ServerFormDialog extends StatefulWidget {
|
||||
final ServerConfig? existingServer;
|
||||
@@ -53,14 +54,14 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
}
|
||||
|
||||
String? _validateRequired(String? value, String field) {
|
||||
if (value == null || value.trim().isEmpty) return '$field不能为空';
|
||||
if (value == null || value.trim().isEmpty) return S.f('{0}不能为空', [field]);
|
||||
return null;
|
||||
}
|
||||
|
||||
String? _validatePort(String? value) {
|
||||
if (value == null || value.trim().isEmpty) return '端口不能为空';
|
||||
if (value == null || value.trim().isEmpty) return S.t('端口不能为空');
|
||||
final port = int.tryParse(value.trim());
|
||||
if (port == null || port < 1 || port > 65535) return '端口范围 1-65535';
|
||||
if (port == null || port < 1 || port > 65535) return S.t('端口范围 1-65535');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -94,21 +95,21 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
children: [
|
||||
TextFormField(
|
||||
controller: _nameCtrl,
|
||||
decoration: const InputDecoration(labelText: '服务器名称', hintText: '例如: 我的生存服'),
|
||||
decoration: InputDecoration(labelText: S.t('服务器名称'), hintText: S.t('例如: 我的生存服')),
|
||||
validator: (v) => _validateRequired(v, '服务器名称'),
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _hostCtrl,
|
||||
decoration: const InputDecoration(labelText: '主机地址', hintText: 'IP 或域名'),
|
||||
decoration: InputDecoration(labelText: S.t('主机地址'), hintText: S.t('IP 或域名')),
|
||||
validator: (v) => _validateRequired(v, '主机地址'),
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _portCtrl,
|
||||
decoration: const InputDecoration(labelText: 'RCON 端口', hintText: '默认 25575'),
|
||||
decoration: InputDecoration(labelText: S.t('RCON 端口'), hintText: S.t('默认 25575')),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: _validatePort,
|
||||
textInputAction: TextInputAction.next,
|
||||
@@ -118,7 +119,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
controller: _passCtrl,
|
||||
obscureText: _obscurePassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'RCON 密码',
|
||||
labelText: S.t('RCON 密码'),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscurePassword ? Icons.visibility_off_outlined : Icons.visibility_outlined),
|
||||
onPressed: () => setState(() => _obscurePassword = !_obscurePassword),
|
||||
@@ -131,15 +132,15 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
const SizedBox(height: 8),
|
||||
SwitchListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
title: const Text('SSH 连接(可选)'),
|
||||
subtitle: const Text('用于模组插件管理与远程终端'),
|
||||
title: T('SSH 连接(可选)'),
|
||||
subtitle: T('用于模组插件管理与远程终端'),
|
||||
value: _sshEnabled,
|
||||
onChanged: (v) => setState(() => _sshEnabled = v),
|
||||
),
|
||||
if (_sshEnabled) ...[
|
||||
TextFormField(
|
||||
controller: _sshPortCtrl,
|
||||
decoration: const InputDecoration(labelText: 'SSH 端口', hintText: '默认 22'),
|
||||
decoration: InputDecoration(labelText: S.t('SSH 端口'), hintText: S.t('默认 22')),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (v) {
|
||||
if (!_sshEnabled) return null;
|
||||
@@ -150,7 +151,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
const SizedBox(height: 12),
|
||||
TextFormField(
|
||||
controller: _sshUserCtrl,
|
||||
decoration: const InputDecoration(labelText: 'SSH 用户名', hintText: '例如 root'),
|
||||
decoration: InputDecoration(labelText: S.t('SSH 用户名'), hintText: S.t('例如 root')),
|
||||
validator: (v) => _sshEnabled ? _validateRequired(v, 'SSH 用户名') : null,
|
||||
textInputAction: TextInputAction.next,
|
||||
),
|
||||
@@ -159,7 +160,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
controller: _sshPasswordCtrl,
|
||||
obscureText: _obscureSshPassword,
|
||||
decoration: InputDecoration(
|
||||
labelText: 'SSH 密码',
|
||||
labelText: S.t('SSH 密码'),
|
||||
suffixIcon: IconButton(
|
||||
icon: Icon(_obscureSshPassword
|
||||
? Icons.visibility_off_outlined
|
||||
@@ -178,7 +179,7 @@ class _ServerFormDialogState extends State<ServerFormDialog> {
|
||||
),
|
||||
),
|
||||
actions: [
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
|
||||
TextButton(onPressed: () => Navigator.pop(context), child: T('取消')),
|
||||
FilledButton(onPressed: _submit, child: Text(isEditing ? '保存' : '添加')),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -9,6 +9,7 @@ import '../console/console_page.dart';
|
||||
import '../settings/settings_page.dart';
|
||||
import 'server_card.dart';
|
||||
import 'server_form_dialog.dart';
|
||||
import '../../core/l10n/strings.dart';
|
||||
|
||||
class ServerListPage extends StatefulWidget {
|
||||
const ServerListPage({super.key});
|
||||
@@ -101,7 +102,7 @@ class _ServerListPageState extends State<ServerListPage> {
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(height: 16),
|
||||
Text('正在连接...'),
|
||||
T('正在连接...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -128,7 +129,7 @@ class _ServerListPageState extends State<ServerListPage> {
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('连接失败:$error')),
|
||||
SnackBar(content: Text(S.f('连接失败:{0}', [error.toString()]))),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -165,16 +166,16 @@ class _ServerListPageState extends State<ServerListPage> {
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (_) => AlertDialog(
|
||||
title: const Text('确认删除'),
|
||||
content: Text('确定要删除服务器「${server.name}」吗?'),
|
||||
title: T('确认删除'),
|
||||
content: Text(S.f('确定要删除服务器「{0}」吗?', [server.name])),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: const Text('取消'),
|
||||
child: T('取消'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
child: const Text('删除', style: TextStyle(color: Colors.red)),
|
||||
child: T('删除', style: TextStyle(color: Colors.red)),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -198,7 +199,7 @@ class _ServerListPageState extends State<ServerListPage> {
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings_outlined),
|
||||
tooltip: '设置',
|
||||
tooltip: S.t('设置'),
|
||||
onPressed: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (_) => const SettingsPage()),
|
||||
@@ -239,7 +240,7 @@ class _ServerListPageState extends State<ServerListPage> {
|
||||
floatingActionButton: FloatingActionButton.extended(
|
||||
onPressed: _addServer,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('添加服务器'),
|
||||
label: T('添加服务器'),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -274,14 +275,14 @@ class _EmptyState extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
'还没有添加服务器',
|
||||
S.t('还没有添加服务器'),
|
||||
style: theme.textTheme.titleMedium?.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'填入主机地址与 RCON 密码,即可在手机上管理',
|
||||
S.t('填入主机地址与 RCON 密码,即可在手机上管理'),
|
||||
textAlign: TextAlign.center,
|
||||
style: theme.textTheme.bodySmall?.copyWith(
|
||||
color: scheme.onSurfaceVariant,
|
||||
@@ -291,7 +292,7 @@ class _EmptyState extends StatelessWidget {
|
||||
FilledButton.icon(
|
||||
onPressed: onAdd,
|
||||
icon: const Icon(Icons.add),
|
||||
label: const Text('添加服务器'),
|
||||
label: T('添加服务器'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user