l10: update

This commit is contained in:
xkeyC 2024-03-17 12:44:50 +08:00
parent d382484739
commit ead05516aa
13 changed files with 1606 additions and 1740 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_CN'; String get localeName => 'zh_CN';
static String m0(v0, v1) => "SC汉化盒子 V${v0} ${v1}"; static String m0(v0, v1) => "SC汉化盒子 V${v0} ${v1}";
static String m1(v0) => "初始化失败:${v0}"; static String m1(v0) => "初始化失败:${v0}";
@ -43,7 +43,7 @@ class MessageLookup extends MessageLookupByLibrary {
static String m10(v0) => static String m10(v0) =>
"为注册表项添加 ForcedPhysicalSectorSizeInBytes 值 模拟旧设备。硬盘分区(${v0})"; "为注册表项添加 ForcedPhysicalSectorSizeInBytes 值 模拟旧设备。硬盘分区(${v0})";
static String m11(v0) => "中文安装路径!这可能会导致游戏 启动/安装 错误!(${v0}请在RSI启动器更换安装路径。"; static String m11(V0) => "中文安装路径!这可能会导致游戏 启动/安装 错误!(${V0}请在RSI启动器更换安装路径。";
static String m12(v0) => "点击修复为您创建 LIVE 文件夹,完成后重试安装。(${v0})"; static String m12(v0) => "点击修复为您创建 LIVE 文件夹,完成后重试安装。(${v0})";
@ -127,7 +127,7 @@ class MessageLookup extends MessageLookupByLibrary {
static String m48(v0, v1, v2, v3, v4) => static String m48(v0, v1, v2, v3, v4) =>
"系统:${v0}\n\n处理器:${v1}\n\n内存大小:${v2}GB\n\n显卡信息:\n${v3}\n\n硬盘信息:\n${v4}\n\n"; "系统:${v0}\n\n处理器:${v1}\n\n内存大小:${v2}GB\n\n显卡信息:\n${v3}\n\n硬盘信息:\n${v4}\n\n";
static String m49(v0) => "处理失败!:${v0}"; static String m49(V0) => "处理失败!:${V0}";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@ -167,10 +167,11 @@ class MessageLookup extends MessageLookupByLibrary {
"app_index_menu_tools": MessageLookupByLibrary.simpleMessage("工具"), "app_index_menu_tools": MessageLookupByLibrary.simpleMessage("工具"),
"app_index_version_info": m0, "app_index_version_info": m0,
"app_init_failed_with_reason": m1, "app_init_failed_with_reason": m1,
"app_language_code": MessageLookupByLibrary.simpleMessage("zh_CN"),
"app_language_name": MessageLookupByLibrary.simpleMessage("简体中文"),
"app_shortcut_name": "app_shortcut_name":
MessageLookupByLibrary.simpleMessage("SC汉化盒子DEV.lnk"), MessageLookupByLibrary.simpleMessage("SC汉化盒子DEV.lnk"),
"app_splash_almost_done": "app_splash_almost_done": MessageLookupByLibrary.simpleMessage("即将完成…"),
MessageLookupByLibrary.simpleMessage("即将完成..."),
"app_splash_checking_availability": "app_splash_checking_availability":
MessageLookupByLibrary.simpleMessage("正在检测可用性,这可能需要一点时间..."), MessageLookupByLibrary.simpleMessage("正在检测可用性,这可能需要一点时间..."),
"app_splash_checking_for_updates": "app_splash_checking_for_updates":

View File

@ -20,7 +20,7 @@ typedef String MessageIfAbsent(String messageStr, List<dynamic> args);
class MessageLookup extends MessageLookupByLibrary { class MessageLookup extends MessageLookupByLibrary {
String get localeName => 'zh_TW'; String get localeName => 'zh_TW';
static String m0(v0, v1) => "SC漢化盒子 V${v0} ${v1}"; static String m0(v0, v1) => "SC漢化盒子 V${v0} ${v1}";
static String m1(v0) => "初始化失敗:${v0}"; static String m1(v0) => "初始化失敗:${v0}";
@ -43,7 +43,7 @@ class MessageLookup extends MessageLookupByLibrary {
static String m10(v0) => static String m10(v0) =>
"為註冊表項添加 ForcedPhysicalSectorSizeInBytes 值 模擬舊設備。硬盤分區(${v0})"; "為註冊表項添加 ForcedPhysicalSectorSizeInBytes 值 模擬舊設備。硬盤分區(${v0})";
static String m11(v0) => "中文安裝路徑!這可能會導致遊戲 啟動/安裝 錯誤!(${v0}請在RSI啟動器更換安裝路徑。"; static String m11(V0) => "中文安裝路徑!這可能會導致遊戲 啟動/安裝 錯誤!(${V0}請在RSI啟動器更換安裝路徑。";
static String m12(v0) => "點擊修復為您創建 LIVE 文件夾,完成後重試安裝。(${v0})"; static String m12(v0) => "點擊修復為您創建 LIVE 文件夾,完成後重試安裝。(${v0})";
@ -127,7 +127,7 @@ class MessageLookup extends MessageLookupByLibrary {
static String m48(v0, v1, v2, v3, v4) => static String m48(v0, v1, v2, v3, v4) =>
"系統:${v0}\n\n處理器:${v1}\n\n內存大小:${v2}GB\n\n顯卡信息:\n${v3}\n\n硬盤信息:\n${v4}\n\n"; "系統:${v0}\n\n處理器:${v1}\n\n內存大小:${v2}GB\n\n顯卡信息:\n${v3}\n\n硬盤信息:\n${v4}\n\n";
static String m49(v0) => "處理失敗!:${v0}"; static String m49(V0) => "處理失敗!:${V0}";
final messages = _notInlinedMessages(_notInlinedMessages); final messages = _notInlinedMessages(_notInlinedMessages);
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
@ -167,10 +167,11 @@ class MessageLookup extends MessageLookupByLibrary {
"app_index_menu_tools": MessageLookupByLibrary.simpleMessage("工具"), "app_index_menu_tools": MessageLookupByLibrary.simpleMessage("工具"),
"app_index_version_info": m0, "app_index_version_info": m0,
"app_init_failed_with_reason": m1, "app_init_failed_with_reason": m1,
"app_language_code": MessageLookupByLibrary.simpleMessage("zh_TW"),
"app_language_name": MessageLookupByLibrary.simpleMessage("繁體中文"),
"app_shortcut_name": "app_shortcut_name":
MessageLookupByLibrary.simpleMessage("SC漢化盒子DEV.lnk"), MessageLookupByLibrary.simpleMessage("SC漢化盒子DEV.lnk"),
"app_splash_almost_done": "app_splash_almost_done": MessageLookupByLibrary.simpleMessage("即將完成…"),
MessageLookupByLibrary.simpleMessage("即將完成..."),
"app_splash_checking_availability": "app_splash_checking_availability":
MessageLookupByLibrary.simpleMessage("正在檢測可用性,這可能需要一點時間..."), MessageLookupByLibrary.simpleMessage("正在檢測可用性,這可能需要一點時間..."),
"app_splash_checking_for_updates": "app_splash_checking_for_updates":

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
{ {
"@@locale": "zh_CN", "@@locale": "zh_CN",
"@auto_translate_locale": "zh-cn",
"app_language_name": "简体中文",
"app_language_code": "zh_CN",
"app_index_version_info": "SC汉化盒子 V{v0} {v1}", "app_index_version_info": "SC汉化盒子 V{v0} {v1}",
"@app_index_version_info": {}, "@app_index_version_info": {},
"app_shortcut_name": "SC汉化盒子DEV.lnk", "app_shortcut_name": "SC汉化盒子DEV.lnk",

View File

@ -1,5 +1,8 @@
{ {
"@@locale": "zh_TW", "@@locale": "zh_TW",
"@auto_translate_locale": "zh-tw",
"app_language_name": "繁體中文",
"app_language_code": "zh_TW",
"app_index_version_info": "SC漢化盒子 V{v0} {v1}", "app_index_version_info": "SC漢化盒子 V{v0} {v1}",
"@app_index_version_info": {}, "@app_index_version_info": {},
"app_shortcut_name": "SC漢化盒子DEV.lnk", "app_shortcut_name": "SC漢化盒子DEV.lnk",

View File

@ -51,7 +51,7 @@ class App extends HookConsumerWidget {
builder: (context, child) { builder: (context, child) {
return MediaQuery( return MediaQuery(
data: data:
MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling), MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling),
child: child ?? const SizedBox(), child: child ?? const SizedBox(),
); );
}, },
@ -65,10 +65,10 @@ class App extends HookConsumerWidget {
micaBackgroundColor: appState.themeConf.micaColor, micaBackgroundColor: appState.themeConf.micaColor,
buttonTheme: ButtonThemeData( buttonTheme: ButtonThemeData(
defaultButtonStyle: ButtonStyle( defaultButtonStyle: ButtonStyle(
shape: ButtonState.all(RoundedRectangleBorder( shape: ButtonState.all(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
side: BorderSide(color: Colors.white.withOpacity(.01)))), side: BorderSide(color: Colors.white.withOpacity(.01)))),
))), ))),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
routeInformationParser: router.routeInformationParser, routeInformationParser: router.routeInformationParser,
routerDelegate: router.routerDelegate, routerDelegate: router.routerDelegate,
@ -108,10 +108,10 @@ Widget _defaultWebviewTitleBar(BuildContext context) {
const SizedBox(width: 12), const SizedBox(width: 12),
(state.isLoading) (state.isLoading)
? const SizedBox( ? const SizedBox(
width: 24, width: 24,
height: 24, height: 24,
child: ProgressRing(), child: ProgressRing(),
) )
: const SizedBox(width: 24), : const SizedBox(width: 24),
const SizedBox(width: 12), const SizedBox(width: 12),
SelectableText(state.url ?? ""), SelectableText(state.url ?? ""),

View File

@ -505,7 +505,12 @@ class HomeUI extends HookConsumerWidget {
style: const TextStyle(fontSize: 18), style: const TextStyle(fontSize: 18),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
Text(item.infoString), Text(
item.infoString,
style: TextStyle(
fontSize: 14,
color: Colors.white.withOpacity(.6)),
),
], ],
)), )),
if (item.key == "localization" && if (item.key == "localization" &&
@ -580,6 +585,7 @@ class HomeUI extends HookConsumerWidget {
padding: const EdgeInsets.only(top: 4), padding: const EdgeInsets.only(top: 4),
child: Text( child: Text(
info, info,
maxLines: 1,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
color: Colors.white.withOpacity(.6)), color: Colors.white.withOpacity(.6)),

View File

@ -75,7 +75,8 @@ class IndexUI extends HookConsumerWidget {
pane: NavigationPane( pane: NavigationPane(
selected: curIndex.value, selected: curIndex.value,
items: getNavigationPaneItems(curIndex), items: getNavigationPaneItems(curIndex),
size: const NavigationPaneSize(openWidth: 64), size: NavigationPaneSize(
openWidth: S.current.app_language_code.startsWith("zh") ? 64 : 74),
), ),
paneBodyBuilder: (item, child) { paneBodyBuilder: (item, child) {
return FocusTraversalGroup( return FocusTraversalGroup(
@ -103,7 +104,7 @@ class IndexUI extends HookConsumerWidget {
icon: Padding( icon: Padding(
padding: const EdgeInsets.only(top: 6, bottom: 6), padding: const EdgeInsets.only(top: 6, bottom: 6),
child: SizedBox( child: SizedBox(
width: 32, width: S.current.app_language_code.startsWith("zh") ? 32 : 42,
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [

View File

@ -4,6 +4,7 @@ import 'package:analyzer/dart/analysis/utilities.dart';
import 'package:analyzer/dart/analysis/features.dart'; import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/ast.dart';
import 'package:translator/translator.dart';
import 'package:uuid/v4.dart'; import 'package:uuid/v4.dart';
final stringResult = <String>[]; final stringResult = <String>[];
@ -49,13 +50,60 @@ class AutoL10nTools {
// sort map with value length // sort map with value length
final newMap = Map.fromEntries( final newMap = Map.fromEntries(
jsonMap.entries.toList() jsonMap.entries.toList()
..sort((a, b) => (b.value as String).length.compareTo((a.value as String).length)), ..sort((a, b) => (b.value as String)
.length
.compareTo((a.value as String).length)),
); );
_replaceDartFile(entity, newMap); _replaceDartFile(entity, newMap);
} }
} }
} }
Future<void> autoTranslate({required String form, required String to}) async {
final formFile = File("./lib/l10n/intl_$form.arb");
final toFile = File("./lib/l10n/intl_$to.arb");
final translator = GoogleTranslator();
final formMap =
json.decode(formFile.readAsStringSync()) as Map<String, dynamic>;
final toMap =
json.decode(toFile.readAsStringSync()) as Map<String, dynamic>;
final formLocaleCode = formMap["@auto_translate_locale"] as String;
final toLocaleCode = toMap["@auto_translate_locale"] as String;
print("formLocaleCode: $formLocaleCode, toLocaleCode: $toLocaleCode");
final newMap = <String, dynamic>{};
try {
for (var key in formMap.keys) {
if (toMap.keys.contains(key)) {
newMap[key] = toMap[key];
continue;
}
if (key.toString().startsWith("@") || key == "locale_code") {
continue;
}
final value = formMap[key] as String;
final result = await translator.translate(value,
from: formLocaleCode, to: toLocaleCode);
var resultValue = result.text;
//
if (toLocaleCode == "en") {
resultValue = resultValue[0].toUpperCase() + resultValue.substring(1);
}
print("translate $key: $value -> $resultValue");
newMap[key] = resultValue;
await Future.delayed(Duration(milliseconds: 500));
}
} catch (e) {
print(e);
toMap.addAll(newMap);
toFile.writeAsStringSync(json.encode(toMap));
}
toMap.addAll(newMap);
toFile.writeAsStringSync(json.encode(toMap));
}
void _processDartFile(File file) { void _processDartFile(File file) {
final parseResult = parseFile( final parseResult = parseFile(
path: file.path, featureSet: FeatureSet.latestLanguageVersion()); path: file.path, featureSet: FeatureSet.latestLanguageVersion());
@ -67,7 +115,7 @@ class AutoL10nTools {
for (var key in jsonMap.keys) { for (var key in jsonMap.keys) {
if (key == "@@locale") continue; if (key == "@@locale") continue;
final mapValue = jsonMap[key] as String; final mapValue = jsonMap[key] as String;
if (mapValue.contains("{{") && mapValue.contains("}}")) { if (mapValue.contains("{") && mapValue.contains("}")) {
print("skipping args value === $mapValue"); print("skipping args value === $mapValue");
continue; continue;
} }

View File

@ -1,11 +1,18 @@
import 'auto_l10n.dart'; import 'auto_l10n.dart';
void main(List<String> args) { void main(List<String> args) async {
switch (args.elementAtOrNull(0)) { switch (args.elementAtOrNull(0)) {
case "l10n_gen": case "l10n_gen":
return AutoL10nTools().genL10nFiles(); return AutoL10nTools().genL10nFiles();
case "l10n_replace": case "l10n_replace":
return AutoL10nTools().replaceL10nFiles(); return AutoL10nTools().replaceL10nFiles();
case "l10n_auto_translate":
final form = args.elementAtOrNull(1);
final to = args.elementAtOrNull(2);
if (form == null || to == null) {
throw Exception("form or to is null");
}
return await AutoL10nTools().autoTranslate(form: form, to: to);
default: default:
throw Exception("cmd not found"); throw Exception("cmd not found");
} }

View File

@ -11,6 +11,7 @@ dependencies:
# path: ^1.8.0 # path: ^1.8.0
analyzer: ^6.4.1 analyzer: ^6.4.1
uuid: ^4.3.3 uuid: ^4.3.3
translator: ^1.0.0
dev_dependencies: dev_dependencies:
lints: ^3.0.0 lints: ^3.0.0