feat: 多语言 初步引入

This commit is contained in:
2024-03-15 00:01:06 +08:00
parent eae02be2af
commit b2c13a8a6f
45 changed files with 525 additions and 446 deletions

View File

@ -24,7 +24,7 @@ class HomeCountdownDialogUI extends HookConsumerWidget {
Navigator.of(context).pop();
}),
const SizedBox(width: 12),
const Text("节日倒计时"),
Text(S.current.home_holiday_countdown),
],
),
content: homeState.countdownFestivalListData == null
@ -85,7 +85,7 @@ class HomeCountdownDialogUI extends HookConsumerWidget {
),
const SizedBox(height: 12),
Text(
"* 以上节日日期由人工收录、维护,可能存在错误,欢迎反馈!",
S.current.home_holiday_countdown_disclaimer,
style: TextStyle(
fontSize: 13, color: Colors.white.withOpacity(.3)),
)
@ -95,4 +95,4 @@ class HomeCountdownDialogUI extends HookConsumerWidget {
),
);
}
}
}

View File

@ -14,12 +14,12 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
useEffect(() {
ref.read(homeGameLoginUIModelProvider.notifier).launchWebLogin(context);
return null;
}, const []);
}, []);
return ContentDialog(
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * .56,
),
title: (loginState.loginStatus == 2) ? null : const Text("一键启动"),
title: (loginState.loginStatus == 2) ? null : Text(S.current.home_action_one_click_launch),
content: AnimatedSize(
duration: const Duration(milliseconds: 230),
child: Padding(
@ -33,13 +33,13 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
Center(
child: Column(
children: [
const Text("登录中..."),
Text(S.current.home_title_logging_in),
const SizedBox(height: 12),
const ProgressRing(),
if (loginState.isDeviceSupportWinHello ?? false)
const SizedBox(height: 24),
Text(
"* 若开启了自动填充,请留意弹出的 Windows Hello 窗口",
S.current.home_info_auto_fill_notice,
style: TextStyle(
fontSize: 13, color: Colors.white.withOpacity(.6)),
)
@ -52,9 +52,9 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
child: Column(
children: [
const SizedBox(height: 12),
const Text(
"欢迎回来!",
style: TextStyle(fontSize: 20),
Text(
S.current.home_login_title_welcome_back,
style: const TextStyle(fontSize: 20),
),
const SizedBox(height: 24),
if (loginState.avatarUrl != null)
@ -74,7 +74,7 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
fontSize: 24, fontWeight: FontWeight.bold),
),
const SizedBox(height: 32),
const Text("正在为您启动游戏..."),
Text(S.current.home_login_title_launching_game),
const SizedBox(height: 12),
const ProgressRing(),
],
@ -87,4 +87,4 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
),
);
}
}
}

View File

@ -25,7 +25,7 @@ part 'home_game_login_dialog_ui_model.g.dart';
@freezed
class HomeGameLoginState with _$HomeGameLoginState {
const factory HomeGameLoginState({
factory HomeGameLoginState({
required int loginStatus,
String? nickname,
String? avatarUrl,
@ -41,7 +41,7 @@ class HomeGameLoginState with _$HomeGameLoginState {
class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
@override
HomeGameLoginState build() {
return const HomeGameLoginState(loginStatus: 0);
return HomeGameLoginState(loginStatus: 0);
}
final LocalAuthentication _localAuth = LocalAuthentication();
@ -53,9 +53,9 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
state = state.copyWith(isDeviceSupportWinHello: isDeviceSupportWinHello);
if (!context.mounted) return;
goWebView(
context, "登录 RSI 账户", "https://robertsspaceindustries.com/connect",
loginMode: true, rsiLoginCallback: (message, ok) async {
goWebView(context, S.current.home_action_login_rsi_account,
"https://robertsspaceindustries.com/connect", loginMode: true,
rsiLoginCallback: (message, ok) async {
// dPrint(
// "======rsiLoginCallback=== $ok ===== data==\n${json.encode(message)}");
if (message == null || !ok) {
@ -98,12 +98,13 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
if (!context.mounted) return;
final ok = await showConfirmDialogs(
context,
"是否开启自动密码填充?",
S.current.home_action_q_auto_password_fill_prompt,
const Text(
"盒子将使用 PIN 与 Windows 凭据加密保存您的密码,密码只存储在您的设备中。\n\n当下次登录需要输入密码时您只需授权PIN即可自动填充登录。"));
if (ok == true) {
if (await _localAuth.authenticate(
localizedReason: "输入PIN以启用加密") ==
localizedReason:
S.current.home_login_info_enter_pin_to_encrypt) ==
true) {
await _savePwd(inputEmail, inputPassword);
}
@ -129,12 +130,12 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
if (!context.mounted) return;
final ok = await showConfirmDialogs(
context,
"游戏版本过期",
S.current.home_login_info_game_version_outdated,
Text(
"RSI 服务器报告版本号:${releaseInfo?["versionLabel"]} \n\n本地版本号:${buildInfo["RequestedP4ChangeNum"]} \n\n建议使用 RSI Launcher 更新游戏!"),
constraints: BoxConstraints(
maxWidth: MediaQuery.of(context).size.width * .4),
cancel: "忽略");
cancel: S.current.home_login_info_action_ignore);
if (ok == true) {
if (!context.mounted) return;
Navigator.pop(context);
@ -163,7 +164,7 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
if (!context.mounted) return;
final ok = await showConfirmDialogs(
context,
"盒子一键启动",
S.current.home_login_action_title_box_one_click_launch,
const Text(
"本功能可以帮您更加便利的启动游戏。\n\n为确保账户安全 ,本功能使用汉化浏览器保留登录状态,且不会保存您的密码信息(除非你启用了自动填充功能)。"
"\n\n使用此功能登录账号时请确保您的 SC汉化盒子 是从可信任的来源下载。",
@ -182,7 +183,8 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
}
if (!await WebviewWindow.isWebviewAvailable()) {
if (!context.mounted) return;
await showToast(context, "需要安装 WebView2 Runtime");
await showToast(context,
S.current.home_login_action_title_need_webview2_runtime);
if (!context.mounted) return;
await launchUrlString(
"https://developer.microsoft.com/en-us/microsoft-edge/webview2/");

View File

@ -185,7 +185,7 @@ class __$$LoginStatusImplCopyWithImpl<$Res>
/// @nodoc
class _$LoginStatusImpl implements _LoginStatus {
const _$LoginStatusImpl(
_$LoginStatusImpl(
{required this.loginStatus,
this.nickname,
this.avatarUrl,
@ -270,7 +270,7 @@ class _$LoginStatusImpl implements _LoginStatus {
}
abstract class _LoginStatus implements HomeGameLoginState {
const factory _LoginStatus(
factory _LoginStatus(
{required final int loginStatus,
final String? nickname,
final String? avatarUrl,

View File

@ -7,7 +7,7 @@ part of 'home_game_login_dialog_ui_model.dart';
// **************************************************************************
String _$homeGameLoginUIModelHash() =>
r'c26dfd89985ff9246104135c288b673b7f15acf0';
r'bcd5fc6d85345207797dd51253b2608035e1fc36';
/// See also [HomeGameLoginUIModel].
@ProviderFor(HomeGameLoginUIModel)

View File

@ -36,9 +36,9 @@ class HomeMdContentDialogUI extends HookConsumerWidget {
),
actions: [
FilledButton(
child: const Padding(
padding: EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
child: Text("关闭"),
child: Padding(
padding: const EdgeInsets.only(left: 8, right: 8, top: 2, bottom: 2),
child: Text(S.current.action_close),
),
onPressed: () {
Navigator.pop(context);
@ -52,4 +52,4 @@ class HomeMdContentDialogUI extends HookConsumerWidget {
final r = await RSHttp.getText(url);
return r;
}
}
}