현지화 데이터 smart string 연동 처리
This commit is contained in:
parent
9944e27234
commit
2410c93607
@ -2,9 +2,11 @@
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.Localization.Tables;
|
||||
using UnityEngine.Localization.Metadata;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEditor.Localization;
|
||||
using System.Linq;
|
||||
|
||||
namespace DDD
|
||||
{
|
||||
@ -59,7 +61,16 @@ public static async void ImportAllFromSheet(string webAppUrl)
|
||||
continue;
|
||||
}
|
||||
|
||||
table.AddEntry(sharedEntry.Id, row[localeCode]);
|
||||
// Smart String 처리 정책
|
||||
// 값에 SmartFormat 구문(중괄호)이 포함되어 있는 경우에만 Smart로 간주
|
||||
string value = row[localeCode];
|
||||
bool containsSmartSyntax = ContainsSmartFormatSyntax(value);
|
||||
|
||||
var entry = table.AddEntry(sharedEntry.Id, value);
|
||||
if (entry != null)
|
||||
{
|
||||
entry.IsSmart = containsSmartSyntax;
|
||||
}
|
||||
EditorUtility.SetDirty(table);
|
||||
}
|
||||
}
|
||||
@ -69,6 +80,19 @@ public static async void ImportAllFromSheet(string webAppUrl)
|
||||
|
||||
Debug.Log("<color=green>[Localization Import]</color> 완료: Google Sheet → Unity");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SmartFormat 사용 여부를 간단히 추정합니다.
|
||||
/// 대부분의 SmartFormat 구문은 중괄호를 포함하므로 값에 '{'와 '}'가 모두 존재하는 경우 Smart로 판단합니다.
|
||||
/// </summary>
|
||||
private static bool ContainsSmartFormatSyntax(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value)) return false;
|
||||
int openIdx = value.IndexOf('{');
|
||||
if (openIdx < 0) return false;
|
||||
int closeIdx = value.IndexOf('}', openIdx + 1);
|
||||
return closeIdx >= 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user