현지화 방식 변경
This commit is contained in:
parent
441964bb68
commit
5dde8020ba
@ -7,39 +7,33 @@
|
|||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public enum TableName
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Item_Name,
|
|
||||||
Item_Description,
|
|
||||||
Global_Message,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LocalizationManager : Singleton<LocalizationManager>, IManager
|
public class LocalizationManager : Singleton<LocalizationManager>, IManager
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, LocalizedString> _localizedCache = new();
|
private readonly Dictionary<string, LocalizedString> _localizedCache = new();
|
||||||
private string _currentLocaleCode;
|
private string _currentLocaleCode;
|
||||||
private bool _isInitialized;
|
private bool _isInitialized;
|
||||||
|
|
||||||
public void PreInit()
|
private const string Name = "_name";
|
||||||
|
private const string Description = "_description";
|
||||||
|
|
||||||
|
public async void PreInit()
|
||||||
{
|
{
|
||||||
_localizedCache.Clear();
|
_localizedCache.Clear();
|
||||||
_currentLocaleCode = GetCurrentLocaleCode();
|
_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();
|
if (table == null)
|
||||||
var stringTable = LocalizationSettings.StringDatabase.GetTable(tableName);
|
|
||||||
|
|
||||||
if (stringTable == null)
|
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"[Localization] Table not found: {tableName}");
|
Debug.LogWarning($"[Localization] Table not found: {tableName}");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var entry in stringTable.Values)
|
foreach (var entry in table.Values)
|
||||||
{
|
{
|
||||||
if (entry == null || string.IsNullOrEmpty(entry.Key)) continue;
|
if (entry == null || string.IsNullOrEmpty(entry.Key)) continue;
|
||||||
|
|
||||||
@ -85,11 +79,19 @@ public LocalizedString GetLocalizedString(string key)
|
|||||||
return null;
|
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)
|
public string GetString(string key)
|
||||||
{
|
{
|
||||||
var localizedString = GetLocalizedString(key);
|
var localizedString = GetLocalizedString(key);
|
||||||
return LocalizationSettings.StringDatabase.GetLocalizedString(localizedString.TableReference, key, LocalizationSettings.SelectedLocale);
|
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>
|
/// <summary>
|
||||||
/// 현재 사용 중인 로케일 코드 반환 (예: "ko", "en", "ja")
|
/// 현재 사용 중인 로케일 코드 반환 (예: "ko", "en", "ja")
|
||||||
|
Loading…
Reference in New Issue
Block a user