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

View File

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

View File

@ -1,5 +1,8 @@
{
"@@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": {},
"app_shortcut_name": "SC漢化盒子DEV.lnk",

View File

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

View File

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

View File

@ -75,7 +75,8 @@ class IndexUI extends HookConsumerWidget {
pane: NavigationPane(
selected: curIndex.value,
items: getNavigationPaneItems(curIndex),
size: const NavigationPaneSize(openWidth: 64),
size: NavigationPaneSize(
openWidth: S.current.app_language_code.startsWith("zh") ? 64 : 74),
),
paneBodyBuilder: (item, child) {
return FocusTraversalGroup(
@ -103,7 +104,7 @@ class IndexUI extends HookConsumerWidget {
icon: Padding(
padding: const EdgeInsets.only(top: 6, bottom: 6),
child: SizedBox(
width: 32,
width: S.current.app_language_code.startsWith("zh") ? 32 : 42,
child: Column(
mainAxisSize: MainAxisSize.min,
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/ast/visitor.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:translator/translator.dart';
import 'package:uuid/v4.dart';
final stringResult = <String>[];
@ -49,13 +50,60 @@ class AutoL10nTools {
// sort map with value length
final newMap = Map.fromEntries(
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);
}
}
}
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) {
final parseResult = parseFile(
path: file.path, featureSet: FeatureSet.latestLanguageVersion());
@ -67,7 +115,7 @@ class AutoL10nTools {
for (var key in jsonMap.keys) {
if (key == "@@locale") continue;
final mapValue = jsonMap[key] as String;
if (mapValue.contains("{{") && mapValue.contains("}}")) {
if (mapValue.contains("{") && mapValue.contains("}")) {
print("skipping args value === $mapValue");
continue;
}

View File

@ -1,11 +1,18 @@
import 'auto_l10n.dart';
void main(List<String> args) {
void main(List<String> args) async {
switch (args.elementAtOrNull(0)) {
case "l10n_gen":
return AutoL10nTools().genL10nFiles();
case "l10n_replace":
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:
throw Exception("cmd not found");
}

View File

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