mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 02:04:44 +08:00
feat: l10n
This commit is contained in:
@ -860,18 +860,21 @@ class HomeUI extends HookConsumerWidget {
|
||||
HomeUIModel model, WidgetRef ref) async {
|
||||
final localizationState = ref.read(localizationUIModelProvider);
|
||||
if (localizationState.communityInputMethodLanguageData == null) {
|
||||
showToast(context, "功能维护中,请稍后重试");
|
||||
showToast(context, S.current.input_method_feature_maintenance);
|
||||
return;
|
||||
}
|
||||
if (localizationState.installedCommunityInputMethodSupportVersion == null) {
|
||||
final userOK = await showConfirmDialogs(context, "未安装社区输入法支持",
|
||||
Text("是否前往汉化管理安装?\n\n如已安装汉化,请卸载并在重新安装时打开社区输入法支持开关。"));
|
||||
final userOK = await showConfirmDialogs(
|
||||
context,
|
||||
S.current.input_method_community_input_method_not_installed,
|
||||
Text(S.current.input_method_install_community_input_method_prompt));
|
||||
if (userOK) {
|
||||
if (!context.mounted) return;
|
||||
() async {
|
||||
await _onMenuTap(context, 'localization', homeState, ref);
|
||||
final localizationState = ref.read(localizationUIModelProvider);
|
||||
if (localizationState.installedCommunityInputMethodSupportVersion != null) {
|
||||
if (localizationState.installedCommunityInputMethodSupportVersion !=
|
||||
null) {
|
||||
await Future.delayed(Duration(milliseconds: 300));
|
||||
if (!context.mounted) return;
|
||||
await _goInputMethod(context, model);
|
||||
|
@ -6,6 +6,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/input_method/input_method_dialog_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/input_method/server.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'server_qr_dialog_ui.dart';
|
||||
|
||||
@ -38,13 +39,32 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
children: [
|
||||
SizedBox(height: 12),
|
||||
InfoBar(
|
||||
title: Text("使用说明"),
|
||||
content: Text(
|
||||
"在上方文本框中输入文字,并将下方转码后的文本复制到游戏的文本框中,即可在聊天频道中发送游戏不支持输入的文字。"),
|
||||
title: Text(S.current.input_method_usage_instructions),
|
||||
content: Text(S.current.input_method_input_text_instructions),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
SizedBox(height: 12),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
GestureDetector(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(3),
|
||||
child: Text(
|
||||
S.current.input_method_online_version_prompt,
|
||||
style: TextStyle(
|
||||
color: Color(0xff4ca0e0),
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
launchUrlString("https://ime.citizenwiki.cn/");
|
||||
}),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 12),
|
||||
TextFormBox(
|
||||
placeholder: "请输入文本...",
|
||||
placeholder: S.current.input_method_input_placeholder,
|
||||
controller: srcTextCtrl,
|
||||
maxLines: 5,
|
||||
placeholderStyle:
|
||||
@ -63,7 +83,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
),
|
||||
SizedBox(height: 16),
|
||||
TextFormBox(
|
||||
placeholder: "这里是转码后的文本...",
|
||||
placeholder: S.current.input_method_encoded_text_placeholder,
|
||||
controller: destTextCtrl,
|
||||
maxLines: 5,
|
||||
placeholderStyle:
|
||||
@ -81,29 +101,33 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text("远程输入服务:"),
|
||||
SizedBox(width: 6),
|
||||
if (serverState.isServerStartup)
|
||||
Button(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
ServerQrDialogUI(),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
serverState.serverAddressText ?? "...",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
Row(
|
||||
children: [
|
||||
Text(S.current.input_method_remote_input_service),
|
||||
SizedBox(width: 6),
|
||||
if (serverState.isServerStartup)
|
||||
Button(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) =>
|
||||
ServerQrDialogUI(),
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
serverState.serverAddressText ?? "...",
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 14),
|
||||
ToggleSwitch(
|
||||
checked: serverState.isServerStartup,
|
||||
onChanged: (b) =>
|
||||
_onSwitchServer(context, b, serverModel)),
|
||||
SizedBox(width: 14),
|
||||
ToggleSwitch(
|
||||
checked: serverState.isServerStartup,
|
||||
onChanged: (b) =>
|
||||
_onSwitchServer(context, b, serverModel)),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
@ -112,7 +136,7 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
Expanded(
|
||||
child: Text(
|
||||
textAlign: TextAlign.end,
|
||||
"*本功能建议仅在非公共频道中使用。若用户选择在公共频道中使用本功能,由此产生的任何后果(包括但不限于被其他玩家举报刷屏等),均由用户自行承担。\n*若该功能被滥用,我们将关闭该功能。",
|
||||
S.current.input_method_disclaimer,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: Colors.white.withOpacity(.6),
|
||||
@ -139,13 +163,13 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
context.pop();
|
||||
}),
|
||||
const SizedBox(width: 12),
|
||||
Text("社区输入法(实验性)"),
|
||||
Text(S.current.input_method_experimental_input_method),
|
||||
Spacer(),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
"自动复制",
|
||||
S.current.input_method_auto_copy,
|
||||
style: TextStyle(fontSize: 14),
|
||||
),
|
||||
SizedBox(width: 12),
|
||||
@ -174,11 +198,9 @@ class InputMethodDialogUI extends HookConsumerWidget {
|
||||
BuildContext context, bool value, InputMethodServer serverModel) async {
|
||||
if (value) {
|
||||
final userOK = await showConfirmDialogs(
|
||||
context,
|
||||
"确认启用远程输入?",
|
||||
Text(
|
||||
"开启此功能后,可通过手机访问远程服务地址,快捷输入文字,省去切换窗口的麻烦,游戏流程不中断。\n\n若弹出防火墙提示,请展开弹窗,手动勾选所有网络类型并允许,否则可能无法正常访问此功能。"),
|
||||
);
|
||||
context,
|
||||
S.current.input_method_confirm_enable_remote_input,
|
||||
Text(S.current.input_method_enable_remote_input_instructions));
|
||||
if (userOK) {
|
||||
// ignore: use_build_context_synchronously
|
||||
await serverModel.startServer().unwrap(context: context);
|
||||
|
@ -30,12 +30,13 @@ class InputMethodDialogUIModel extends _$InputMethodDialogUIModel {
|
||||
return state;
|
||||
}
|
||||
|
||||
_init() async {
|
||||
final localizationState = ref.watch(localizationUIModelProvider);
|
||||
_init({bool skipUpdate = false}) async {
|
||||
final localizationState = ref.read(localizationUIModelProvider);
|
||||
final localizationModel = ref.read(localizationUIModelProvider.notifier);
|
||||
if (localizationState.installedCommunityInputMethodSupportVersion == null) {
|
||||
return;
|
||||
}
|
||||
if (!skipUpdate) await localizationModel.checkCommunityInputMethodUpdate();
|
||||
final keyMaps =
|
||||
await localizationModel.getCommunityInputMethodSupportData();
|
||||
dPrint("[InputMethodDialogUIModel] keyMapsLen: ${keyMaps?.length}");
|
||||
|
@ -96,7 +96,7 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
list.removeWhere((element) => !element.contains('192.168.'));
|
||||
}
|
||||
if (list.isEmpty) {
|
||||
list.add("获取地址失败,请手动查看电脑IP");
|
||||
list.add(S.current.input_method_address_fetch_failed);
|
||||
}
|
||||
return list.join(", ");
|
||||
}
|
||||
@ -187,7 +187,7 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
return Response.badRequest(
|
||||
body: json.encode({
|
||||
"result": "error",
|
||||
"message": "文本不能为空!",
|
||||
"message": S.current.input_method_text_cannot_be_empty,
|
||||
}));
|
||||
}
|
||||
final autoCopy = data["autoCopy"] ?? false;
|
||||
@ -200,7 +200,7 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
);
|
||||
return Response.ok(json.encode({
|
||||
"result": "ok",
|
||||
"message": "发送成功!",
|
||||
"message": S.current.input_method_send_success,
|
||||
}));
|
||||
} catch (e) {
|
||||
return Response.internalServerError(
|
||||
@ -213,4 +213,4 @@ class InputMethodServer extends _$InputMethodServer {
|
||||
return Response.notFound("Not Found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:qr_flutter/qr_flutter.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:starcitizen_doctor/generated/l10n.dart';
|
||||
|
||||
import 'server.dart';
|
||||
|
||||
@ -57,10 +58,10 @@ class ServerQrDialogUI extends HookConsumerWidget {
|
||||
children: [
|
||||
SizedBox(width: double.infinity, height: 12),
|
||||
if (hasMultipleUrls) ...[
|
||||
Text("我们没能找到合适的 ip 地址来访问服务,请您尝试以下地址(左右切换)"),
|
||||
Text(S.current.input_method_ip_address_not_found),
|
||||
] else
|
||||
Text(
|
||||
"请使用您的移动设备扫描以下二维码,或手动访问连接",
|
||||
S.current.input_method_scan_qr_code,
|
||||
style: TextStyle(color: Colors.white.withOpacity(.8)),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
@ -115,8 +116,8 @@ class ServerQrDialogUI extends HookConsumerWidget {
|
||||
context.pop();
|
||||
}),
|
||||
const SizedBox(width: 12),
|
||||
Text("服务二维码"),
|
||||
Text(S.current.input_method_service_qr_code),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -321,7 +321,9 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
// ignore: avoid_build_context_in_providers
|
||||
Future<void> onInstall(BuildContext context) async {
|
||||
var isEnableCommunityInputMethod = true;
|
||||
final userOK = await showConfirmDialogs(context, "确认安装高级汉化?", HookConsumer(
|
||||
final userOK = await showConfirmDialogs(context,
|
||||
S.current.input_method_confirm_install_advanced_localization,
|
||||
HookConsumer(
|
||||
builder: (BuildContext context, WidgetRef ref, Widget? child) {
|
||||
final globalIni = useState<StringBuffer?>(null);
|
||||
final enableCommunityInputMethod = useState(true);
|
||||
@ -369,7 +371,7 @@ class AdvancedLocalizationUIModel extends _$AdvancedLocalizationUIModel {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"安装社区输入法支持",
|
||||
S.current.input_method_install_community_input_method_support,
|
||||
),
|
||||
Spacer(),
|
||||
ToggleSwitch(
|
||||
|
@ -113,7 +113,10 @@ class LocalizationDialogUI extends HookConsumerWidget {
|
||||
.installedCommunityInputMethodSupportVersion !=
|
||||
null)
|
||||
Text(
|
||||
"社区输入法支持:${state.installedCommunityInputMethodSupportVersion}",
|
||||
S.current
|
||||
.input_method_community_input_method_support_version(
|
||||
state.installedCommunityInputMethodSupportVersion ??
|
||||
"?"),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
@ -138,7 +138,7 @@ class LocalizationFromFileDialogUI extends HookConsumerWidget {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"安装社区输入法支持",
|
||||
S.current.input_method_install_community_input_method_support,
|
||||
),
|
||||
Spacer(),
|
||||
ToggleSwitch(
|
||||
@ -160,4 +160,4 @@ class LocalizationFromFileDialogUI extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/widgets/widgets.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
import 'package:starcitizen_doctor/common/rust/api/win32_api.dart' as win32;
|
||||
|
||||
part 'localization_ui_model.g.dart';
|
||||
|
||||
part 'localization_ui_model.freezed.dart';
|
||||
@ -323,6 +325,36 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<(String, String)>
|
||||
getIniContentWithoutCommunityInputMethodSupportData() async {
|
||||
final iniPath =
|
||||
"${_scDataDir.absolute.path}\\Localization\\${state.selectedLanguage}\\global.ini";
|
||||
final iniFile = File(iniPath);
|
||||
if (!await iniFile.exists()) {
|
||||
return ("", "");
|
||||
}
|
||||
final iniStringSplit = (await iniFile.readAsString()).split("\n");
|
||||
final sb = StringBuffer();
|
||||
var b = false;
|
||||
for (var i = 0; i < iniStringSplit.length; i++) {
|
||||
final line = iniStringSplit[i];
|
||||
|
||||
if (line.trim().startsWith(
|
||||
"_starcitizen_doctor_localization_community_input_method_version=")) {
|
||||
b = true;
|
||||
continue;
|
||||
} else if (line
|
||||
.trim()
|
||||
.startsWith("_starcitizen_doctor_localization_version=")) {
|
||||
b = false;
|
||||
return (sb.toString(), line.split("=").last.trim());
|
||||
} else if (!b) {
|
||||
sb.writeln(line);
|
||||
}
|
||||
}
|
||||
return ("", "");
|
||||
}
|
||||
|
||||
Future? doRemoteInstall(BuildContext context, ScLocalizationData value,
|
||||
{bool isEnableCommunityInputMethod = false}) async {
|
||||
AnalyticsApi.touch("install_localization");
|
||||
@ -557,9 +589,35 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
await checkCommunityInputMethodUpdate();
|
||||
return updates;
|
||||
}
|
||||
|
||||
Future<void> checkCommunityInputMethodUpdate() async {
|
||||
final cloudVersion = state.communityInputMethodLanguageData?.version;
|
||||
final localVersion = state.installedCommunityInputMethodSupportVersion;
|
||||
if (cloudVersion == null || localVersion == null) return;
|
||||
if (localVersion != cloudVersion) {
|
||||
// 版本不一致,自动检查更新
|
||||
final (localIniString, versioName) =
|
||||
await getIniContentWithoutCommunityInputMethodSupportData();
|
||||
if (localIniString.trim().isEmpty) {
|
||||
dPrint(
|
||||
"[InputMethodDialogUIModel] check update Error localIniString is empty");
|
||||
return;
|
||||
}
|
||||
await installFormString(StringBuffer(localIniString), versioName,
|
||||
isEnableCommunityInputMethod: true);
|
||||
await win32.sendNotify(
|
||||
summary: S.current.input_method_support_updated,
|
||||
body: S.current.input_method_support_updated_to_version(cloudVersion),
|
||||
appName: S.current.home_title_app_name,
|
||||
appId: ConstConf.isMSE
|
||||
? "56575xkeyC.MSE_bsn1nexg8e4qe!starcitizendoctor"
|
||||
: "{6D809377-6AF0-444B-8957-A3773F02200E}\\Starcitizen_Doctor\\starcitizen_doctor.exe");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> onChangeGameInstallPath(String value) async {
|
||||
await _loadData();
|
||||
}
|
||||
@ -622,7 +680,7 @@ class LocalizationUIModel extends _$LocalizationUIModel {
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
"安装社区输入法支持",
|
||||
S.current.input_method_install_community_input_method_support,
|
||||
),
|
||||
Spacer(),
|
||||
StatefulBuilder(
|
||||
|
Reference in New Issue
Block a user