현지화 방식 변경

This commit is contained in:
NTG_Lenovo 2025-07-28 18:50:50 +09:00
parent 441964bb68
commit 5dde8020ba

View File

@ -7,39 +7,33 @@
namespace DDD
{
public enum TableName
{
None = 0,
Item_Name,
Item_Description,
Global_Message,
}
public class LocalizationManager : Singleton<LocalizationManager>, IManager
{
private readonly Dictionary<string, LocalizedString> _localizedCache = new();
private string _currentLocaleCode;
private bool _isInitialized;
private const string Name = "_name";
private const string Description = "_description";
public void PreInit()
public async void PreInit()
{
_localizedCache.Clear();
_currentLocaleCode = GetCurrentLocaleCode();
foreach (TableName table in System.Enum.GetValues(typeof(TableName)))
var tables = await LocalizationSettings.StringDatabase.GetAllTables().Task;
foreach (var table in tables)
{
if (table == TableName.None) continue;
var tableName = table.SharedData.TableCollectionName;
var tableName = table.ToString();
var stringTable = LocalizationSettings.StringDatabase.GetTable(tableName);
if (stringTable == null)
if (table == null)
{
Debug.LogWarning($"[Localization] Table not found: {tableName}");
continue;
}
foreach (var entry in stringTable.Values)
foreach (var entry in table.Values)
{
if (entry == null || string.IsNullOrEmpty(entry.Key)) continue;
@ -84,12 +78,20 @@ public LocalizedString GetLocalizedString(string key)
Debug.LogError($"[LocalizationManager] {key}값이 존재하지 않습니다.");
return null;
}
public LocalizedString GetLocalizedName(string key) => GetLocalizedString(key + Name);
public LocalizedString GetLocalizedDescription(string key) => GetLocalizedString(key + Description);
/// <summary>
/// Key값 자체를 탐색
/// </summary>
public string GetString(string key)
{
var localizedString = GetLocalizedString(key);
return LocalizationSettings.StringDatabase.GetLocalizedString(localizedString.TableReference, key, LocalizationSettings.SelectedLocale);
}
public string GetName(string key) => GetString(key + Name);
public string GetDescription(string key) => GetString(key + Description);
/// <summary>
/// 현재 사용 중인 로케일 코드 반환 (예: "ko", "en", "ja")