refactor: centralize localization keys and remove runtime Chinese literals

This commit is contained in:
2026-06-23 21:19:42 +08:00
parent 34c99701ca
commit 036243fd4a
32 changed files with 873 additions and 403 deletions
+7 -10
View File
@@ -1,4 +1,4 @@
namespace UXAssist.Functions;
namespace UXAssist.Functions;
using System;
using System.Collections.Generic;
@@ -9,10 +9,7 @@ public static class TechFunctions
{
public static void Init()
{
I18N.Add("Do you want to use metadata to buyout the following tech?", "Do you want to use metadata to buyout the following tech?", "要使用元数据买断以下科技吗?");
I18N.Add("The following is the required metadata for buyout:", "The following is the required metadata for buyout:", "以下是买断所需元数据:");
I18N.Add("Batch buyout tech", "Batch buyout tech", "批量买断科技");
}
}
private static void CheckTechUnlockProperties(GameHistoryData history, TechProto techProto, SortedList<int, int> properties, List<Tuple<TechProto, int, int>> techList, int maxLevel = 10000, bool withPrerequisites = true, HashSet<int> seenTechs = null)
{
@@ -187,13 +184,13 @@ public static class TechFunctions
}
if (!enough)
{
UIMessageBox.Show("元数据".Translate(), "元数据不足".Translate(), "确定".Translate(), UIMessageBox.ERROR);
UIMessageBox.Show(I18NKeys.Metadata.Translate(), I18NKeys.InsufficientMetadata.Translate(), I18NKeys.Ok.Translate(), UIMessageBox.ERROR);
return;
}
if (!history.hasUsedPropertyBanAchievement)
{
UIMessageBox.Show("初次使用元数据标题".Translate(), "初次使用元数据描述".Translate(), "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, DoUnlockCalculatedTechs);
UIMessageBox.Show(I18NKeys.FirstTimeUsingMetadataTitle.Translate(), I18NKeys.FirstTimeUsingMetadataDescription.Translate(), I18NKeys.Cancel.Translate(), I18NKeys.Ok.Translate(), UIMessageBox.QUESTION, null, DoUnlockCalculatedTechs);
return;
}
@@ -236,7 +233,7 @@ public static class TechFunctions
if (consumption.Value <= 0) continue;
msg += $"\n {LDB.items.Select(consumption.Key).propertyName}x{consumption.Value}";
}
UIMessageBox.Show("Batch buyout tech".Translate(), msg, "取消".Translate(), "确定".Translate(), UIMessageBox.QUESTION, null, UnlockWithPropertiesImmediately);
UIMessageBox.Show("Batch buyout tech".Translate(), msg, I18NKeys.Cancel.Translate(), I18NKeys.Ok.Translate(), UIMessageBox.QUESTION, null, UnlockWithPropertiesImmediately);
return;
void AddToMsg(ref string str, Tuple<TechProto, int, int> tuple)
@@ -246,10 +243,10 @@ public static class TechFunctions
if (tuple.Item2 <= 0)
str += $"\n {tuple.Item1.name}";
else
str += $"\n {tuple.Item1.name}{"".Translate()}{tuple.Item2}";
str += $"\n {tuple.Item1.name}{I18NKeys.TechLevelPrefix.Translate()}{tuple.Item2}";
}
else
str += $"\n {tuple.Item1.name}{"".Translate()}{tuple.Item2}->{tuple.Item3}";
str += $"\n {tuple.Item1.name}{I18NKeys.TechLevelPrefix.Translate()}{tuple.Item2}->{tuple.Item3}";
}
}
+2 -5
View File
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;
using UnityEngine.UI;
using UXAssist.Common;
@@ -14,10 +14,7 @@ internal static class AutoConstructUI
public static void Init()
{
I18N.Add("Enable auto-construct", "Enable auto-construct", "启用自动建造");
I18N.Add("Disable auto-construct", "Disable auto-construct", "禁用自动建造");
I18N.Add("Buildings to construct: {0}", "Buildings to construct: {0}", "待建造数量: {0}");
}
}
public static void Start()
{
+2 -4
View File
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UXAssist.Common;
using UXAssist.UI;
@@ -10,9 +10,7 @@ internal static class AutoCruiseUI
public static void Init()
{
I18N.Add("Enable auto-cruise", "Enable auto-cruise", "启用自动巡航");
I18N.Add("Disable auto-cruise", "Disable auto-cruise", "禁用自动巡航");
}
}
public static void Start()
{
+2 -4
View File
@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using CommonAPI.Systems;
using UXAssist.Common;
@@ -24,9 +24,7 @@ internal static class MenuButtonUI
name = "OpenUXAssistConfigWindow",
canOverride = true
});
I18N.Add("KEYOpenUXAssistConfigWindow", "[UXA] Open UXAssist Config Window", "[UXA] 打开UX助手设置面板");
I18N.Add("UXAssist Config", "UXAssist Config", "UX助手设置");
I18N.OnInitialized += RecreateConfigWindow;
I18N.OnInitialized += RecreateConfigWindow;
}
public static void Start()
+4 -9
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Text;
using UnityEngine;
@@ -31,12 +31,7 @@ internal static class MilkyWayUI
public static void Init()
{
I18N.Add("No recent milkyway upload results", "No recent milkyway upload results", "没有最近的银河系发电数据上传结果");
I18N.Add("Success", "Success", "成功");
I18N.Add("Failure: ", "Failure: ", "失败: ");
I18N.Add("Show top players", "Show top players", "显示玩家排行榜");
I18N.Add("Hide top players", "Hide top players", "隐藏玩家排行榜");
}
}
public static void Start()
{
@@ -118,7 +113,7 @@ internal static class MilkyWayUI
{
if (_clusterUploadResultsCount == 0)
{
UIMessageBox.Show("UXAssist".Translate(), "No recent milkyway upload results".Translate(), "确定".Translate(), UIMessageBox.INFO, null);
UIMessageBox.Show("UXAssist".Translate(), "No recent milkyway upload results".Translate(), I18NKeys.Ok.Translate(), UIMessageBox.INFO, null);
return;
}
StringBuilder sb = new();
@@ -129,7 +124,7 @@ internal static class MilkyWayUI
var res = _clusterUploadResults[(i + _clusterUploadResultsHead) % ClusterUploadResultKeepCount];
sb.AppendLine($"{res.UploadTime.ToString("yyyy-MM-dd HH:mm:ss")} - {((res.Result is 0 or 20) ? "Success".Translate() : ("Failure: ".Translate() + res.Result.ToString()))} - {res.RequestTime:F2}s");
}
UIMessageBox.Show("UXAssist".Translate(), sb.ToString(), "确定".Translate(), UIMessageBox.INFO, null);
UIMessageBox.Show("UXAssist".Translate(), sb.ToString(), I18NKeys.Ok.Translate(), UIMessageBox.INFO, null);
}
}
+2 -10
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -60,15 +60,7 @@ internal static class StarmapFilterUI
public static void Init()
{
I18N.Add("High yield", "High yield", "高产");
I18N.Add("Perfect", "Perfect", "完美");
I18N.Add("Union results", "Union results", "结果取并集");
I18N.Add("All 6 Basic Ores", "All 6 Basic Ores", "六种基础矿物齐全");
I18N.Add("Show original name", "Show original name", "显示原始名称");
I18N.Add("Show distance", "Show distance", "显示距离");
I18N.Add("Show planet count", "Show planet count", "显示行星数");
I18N.Add("Show all information", "Show all information", "显示全部信息");
}
}
public static void Start()
{