diff --git a/Assets/_DDD/_Scripts/GameFramework/Localization/LocalizationManager.cs b/Assets/_DDD/_Scripts/GameFramework/Localization/LocalizationManager.cs index ce5b2c0b8..bd3d4f17d 100644 --- a/Assets/_DDD/_Scripts/GameFramework/Localization/LocalizationManager.cs +++ b/Assets/_DDD/_Scripts/GameFramework/Localization/LocalizationManager.cs @@ -7,39 +7,33 @@ namespace DDD { - public enum TableName - { - None = 0, - Item_Name, - Item_Description, - Global_Message, - } - public class LocalizationManager : Singleton, IManager { private readonly Dictionary _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); + /// + /// Key값 자체를 탐색 + /// 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); /// /// 현재 사용 중인 로케일 코드 반환 (예: "ko", "en", "ja")