using UnityEngine.Localization.Settings; using System.Linq; namespace DDD { public enum TableName { None = 0, Item_Name, Item_Description, } public static class LocalizationManager { /// /// 현재 선택된 로케일 기준으로 로컬라이징 텍스트를 가져옵니다. /// public static string GetString(TableName table, string key) { if (table == TableName.None || string.IsNullOrEmpty(key)) return $"[Invalid:{table}/{key}]"; var locale = LocalizationSettings.SelectedLocale; var tableName = table.ToString(); var stringTable = LocalizationSettings.StringDatabase.GetTable(tableName, locale); if (stringTable == null) return $"[Missing Table:{tableName}]"; var entry = stringTable.GetEntry(key); if (entry == null) return $"[Missing Key:{key}]"; return entry.GetLocalizedString(); } /// /// 현재 사용 중인 로케일 코드 반환 (예: "ko", "en", "ja") /// public static string GetCurrentLocaleCode() { return LocalizationSettings.SelectedLocale.Identifier.Code; } /// /// 로케일 코드로 현재 언어를 설정합니다. (예: "ko", "en", "ja") /// public static void SetLocale(string code) { var locale = LocalizationSettings.AvailableLocales.Locales .FirstOrDefault(l => l.Identifier.Code == code); if (locale != null) LocalizationSettings.SelectedLocale = locale; } } }