修复英文问题,添加遗漏本地化
This commit is contained in:
@@ -179,6 +179,18 @@ MonoBehaviour:
|
||||
m_Key: note
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47671075222315008
|
||||
m_Key: Pain
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47672437142183936
|
||||
m_Key: Stop
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47673186144215040
|
||||
m_Key: "Kill\t"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
m_KeyGenerator:
|
||||
|
||||
@@ -196,6 +196,18 @@ MonoBehaviour:
|
||||
m_Localized: Early test, not final quality
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47671075222315008
|
||||
m_Localized: Please, JUST LET ME DIE
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47672437142183936
|
||||
m_Localized: JUST STOP! STOP PLEASE !
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47673186144215040
|
||||
m_Localized: KILL ME! KILL ME!
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
|
||||
@@ -184,6 +184,18 @@ MonoBehaviour:
|
||||
m_Localized: "\u65E9\u671F\u6D4B\u8BD5\uFF0C\u4E0D\u4EE3\u8868\u6700\u7EC8\u54C1\u8D28"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47671075222315008
|
||||
m_Localized: "\u8BA9\u6211\u6B7B\uFF0C\u8BA9\u6211\u53BB\u6B7B"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47672437142183936
|
||||
m_Localized: "\u505C\u4E0B\u6765\uFF01\u505C\u4E0B\u6765\uFF01"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
- m_Id: 47673186144215040
|
||||
m_Localized: "\u6740\u4E86\u6211\u5427\uFF01\u6740\u4E86\u6211\u5427\uFF01"
|
||||
m_Metadata:
|
||||
m_Items: []
|
||||
references:
|
||||
version: 2
|
||||
RefIds:
|
||||
|
||||
+2901
-836
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,7 @@ using UnityEngine;
|
||||
using UnityEngine.Localization;
|
||||
using UnityEngine.Localization.Settings;
|
||||
using UnityEngine.Localization.Tables;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace AibisDream.Framework
|
||||
{
|
||||
@@ -47,20 +48,23 @@ namespace AibisDream.Framework
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void SwitchLanguage(string localeCode)
|
||||
{
|
||||
var selectedLocale =
|
||||
LocalizationSettings.AvailableLocales.Locales.Find(locale => locale.Identifier.Code == localeCode);
|
||||
public static async void SwitchLanguage(string localeCode)
|
||||
{
|
||||
// 等待本地化系统初始化完成
|
||||
await LocalizationSettings.InitializationOperation.Task;
|
||||
|
||||
var selectedLocale =
|
||||
LocalizationSettings.AvailableLocales.Locales.Find(locale => locale.Identifier.Code == localeCode);
|
||||
|
||||
if (selectedLocale)
|
||||
{
|
||||
LocalizationSettings.SelectedLocale = selectedLocale;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Locale with code {localeCode} not found.");
|
||||
}
|
||||
if (selectedLocale)
|
||||
{
|
||||
LocalizationSettings.SelectedLocale = selectedLocale;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Locale with code {localeCode} not found.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 本地化参数
|
||||
@@ -100,6 +104,15 @@ namespace AibisDream.Framework
|
||||
// 本地化参数则去除前缀,非本地化参数直接返回
|
||||
return key.StartsWith(LocalizationPrefix) ? key[LocalizationPrefix.Length..] : key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 确保本地化系统已初始化
|
||||
/// </summary>
|
||||
/// <returns>初始化操作</returns>
|
||||
public static async System.Threading.Tasks.Task EnsureInitialized()
|
||||
{
|
||||
await LocalizationSettings.InitializationOperation.Task;
|
||||
}
|
||||
}
|
||||
|
||||
public class LocalizationTable
|
||||
@@ -107,36 +120,58 @@ namespace AibisDream.Framework
|
||||
public string TableName { get; }
|
||||
|
||||
private StringTable _stringTable;
|
||||
private bool _isInitialized = false;
|
||||
|
||||
public LocalizationTable(string tableName)
|
||||
{
|
||||
TableName = tableName;
|
||||
Debug.Log($"表格{tableName}已加载");
|
||||
Debug.Log($"开始初始化表格{tableName}");
|
||||
InitializeAsync();
|
||||
}
|
||||
|
||||
private async void InitializeAsync()
|
||||
{
|
||||
// 等待本地化系统初始化完成
|
||||
await LocalizationSettings.InitializationOperation.Task;
|
||||
|
||||
_stringTable = LocalizationSettings.StringDatabase.GetTable(TableName);
|
||||
LocalizationSettings.SelectedLocaleChanged += OnLocaleChanged;
|
||||
_isInitialized = true;
|
||||
|
||||
Debug.Log($"表格{_stringTable.TableCollectionName}已加载");
|
||||
Debug.Log($"表格{TableName}已成功加载");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged;
|
||||
if (_isInitialized)
|
||||
{
|
||||
LocalizationSettings.SelectedLocaleChanged -= OnLocaleChanged;
|
||||
}
|
||||
_stringTable = null;
|
||||
_isInitialized = false;
|
||||
}
|
||||
|
||||
private void OnLocaleChanged(Locale locale)
|
||||
{
|
||||
_stringTable = LocalizationSettings.StringDatabase.GetTable(TableName);
|
||||
if (_isInitialized)
|
||||
{
|
||||
_stringTable = LocalizationSettings.StringDatabase.GetTable(TableName);
|
||||
}
|
||||
}
|
||||
|
||||
public StringTableEntry this[string key] => _stringTable[key];
|
||||
public StringTableEntry this[string key] => _isInitialized ? _stringTable?[key] : null;
|
||||
|
||||
public bool TryGetValue(string key, out StringTableEntry value)
|
||||
{
|
||||
value = _stringTable.GetEntry(key);
|
||||
return value != null;
|
||||
if (_isInitialized && _stringTable != null)
|
||||
{
|
||||
value = _stringTable.GetEntry(key);
|
||||
return value != null;
|
||||
}
|
||||
value = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public LocaleIdentifier LocaleIdentifier => _stringTable.LocaleIdentifier;
|
||||
public LocaleIdentifier? LocaleIdentifier => _isInitialized ? _stringTable?.LocaleIdentifier : null;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using AibisDream.Framework;
|
||||
using AibisDream.Kit;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Localization.Settings;
|
||||
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||
|
||||
namespace AibisDream
|
||||
{
|
||||
@@ -33,7 +34,7 @@ namespace AibisDream
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSettingChanged(string propName, string value)
|
||||
private async void OnSettingChanged(string propName, string value)
|
||||
{
|
||||
// 配置项同步
|
||||
switch (propName)
|
||||
@@ -52,7 +53,8 @@ namespace AibisDream
|
||||
GameManager.Instance.SetScreenMode(value);
|
||||
break;
|
||||
case "Language":
|
||||
// TODO 修改语言
|
||||
// 确保本地化系统已初始化
|
||||
await LocalizationSettings.InitializationOperation.Task;
|
||||
LocalizationKit.SwitchLanguage(value);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -100,7 +100,7 @@ PlayerSettings:
|
||||
xboxEnableFitness: 0
|
||||
visibleInBackground: 1
|
||||
allowFullscreenSwitch: 1
|
||||
fullscreenMode: 2
|
||||
fullscreenMode: 0
|
||||
xboxSpeechDB: 0
|
||||
xboxEnableHeadOrientation: 0
|
||||
xboxEnableGuest: 0
|
||||
@@ -133,7 +133,7 @@ PlayerSettings:
|
||||
vulkanEnableLateAcquireNextImage: 0
|
||||
vulkanEnableCommandBufferRecycling: 1
|
||||
loadStoreDebugModeEnabled: 0
|
||||
bundleVersion: 0.3.2.6-20250902-034036
|
||||
bundleVersion: 0.3.2.8-20250902-042459
|
||||
preloadedAssets:
|
||||
- {fileID: 11400000, guid: 0fb2bc2476953fc43a74f0ab8879077c, type: 2}
|
||||
metroInputSource: 0
|
||||
|
||||
Reference in New Issue
Block a user