Message Ui에서 사용될 현지화 테이블 추가 및 Importer 저장 문제 해결

This commit is contained in:
NTG_Lenovo 2025-07-21 16:56:58 +09:00
parent 5bd780214a
commit d02af59100
2 changed files with 25 additions and 7 deletions

View File

@ -13,9 +13,19 @@ public static class LocalizationImporter
public static async void ImportAllFromSheet(string webAppUrl) public static async void ImportAllFromSheet(string webAppUrl)
{ {
string json = await GoogleSheetWebClient.Get(webAppUrl); string json = await GoogleSheetWebClient.Get(webAppUrl);
if (string.IsNullOrEmpty(json)) return; if (string.IsNullOrEmpty(json))
{
Debug.LogError("[Localization Import] Google Sheet로부터 데이터를 가져오지 못했습니다.");
return;
}
var payload = JsonConvert.DeserializeObject<SheetDownloadPayload>(json); var payload = JsonConvert.DeserializeObject<SheetDownloadPayload>(json);
if (payload == null || payload.Tables == null || payload.Tables.Count == 0)
{
Debug.LogWarning("[Localization Import] 불러온 데이터가 비어있습니다.");
return;
}
foreach (var kv in payload.Tables) foreach (var kv in payload.Tables)
{ {
string tableName = kv.Key; string tableName = kv.Key;
@ -29,27 +39,34 @@ public static async void ImportAllFromSheet(string webAppUrl)
} }
var shared = collection.SharedData; var shared = collection.SharedData;
EditorUtility.SetDirty(shared); // ✅ SharedData 저장 대상 표시
foreach (var row in rows) foreach (var row in rows)
{ {
if (!row.TryGetValue("Key", out var key)) continue; if (!row.TryGetValue("Key", out var key) || string.IsNullOrEmpty(key)) continue;
var sharedEntry = shared.GetEntry(key) ?? shared.AddKey(key); var sharedEntry = shared.GetEntry(key) ?? shared.AddKey(key);
foreach (var localeCode in row.Keys) foreach (var localeCode in row.Keys)
{ {
if (localeCode == "Key") continue; if (localeCode == "Key") continue;
var table = collection.GetTable(localeCode) as StringTable; var table = collection.GetTable(localeCode) as StringTable;
if (table == null) continue; if (table == null)
{
Debug.LogWarning($"[Localization] Table '{tableName}'의 로케일 '{localeCode}' 테이블이 존재하지 않습니다.");
continue;
}
table.AddEntry(sharedEntry.Id, row[localeCode]); table.AddEntry(sharedEntry.Id, row[localeCode]);
EditorUtility.SetDirty(table); EditorUtility.SetDirty(table); // ✅ StringTable 저장 대상 표시
} }
} }
AssetDatabase.SaveAssets();
} }
Debug.Log("<color=green>[Localization Import]</color> 완료"); AssetDatabase.SaveAssets(); // ✅ 변경사항 저장
Debug.Log("<color=green>[Localization Import]</color> 완료: Google Sheet → Unity");
} }
} }
} }

View File

@ -8,6 +8,7 @@ public enum TableName
None = 0, None = 0,
Item_Name, Item_Name,
Item_Description, Item_Description,
Global_Message,
} }
public static class LocalizationManager public static class LocalizationManager