From 5dde8020ba0de7e42111fe821b6d6c6eb64050ad Mon Sep 17 00:00:00 2001 From: NTG_Lenovo Date: Mon, 28 Jul 2025 18:50:50 +0900 Subject: [PATCH] =?UTF-8?q?=ED=98=84=EC=A7=80=ED=99=94=20=EB=B0=A9?= =?UTF-8?q?=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Localization/LocalizationManager.cs | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) 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")