NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/HotUpdate/UI/TempUIText.cs

59 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Collections.Generic;
using UnityEngine;
public class LocalizeTextData
{
private Dictionary<string, string> TexDic;
public string GetString(string key)
{
if (TexDic.TryGetValue(key, out var text))
{
return text;
}
Debug.LogError($"AOT部分文本配置缺少Key:{key}");
return "";
}
/// <summary>
/// 多语言索引索引值参考Localize脚本, 0默认 1中文2繁中3英文
/// </summary>
/// <param name="index"></param>
public LocalizeTextData(int index)
{
switch (index)
{
case 1: //简体中文
TexDic = TextLocalizeDic.CN;
break;
case 2: //繁体中文
TexDic = TextLocalizeDic.TW;
break;
case 3: //英文
TexDic = TextLocalizeDic.EN;
break;
default: //默认
TexDic = TextLocalizeDic.CN;
break;
}
}
}
public static class TextLocalizeDic
{
public static Dictionary<string, string> CN = new()
{
["key_0"] = "简中文本1",
};
public static Dictionary<string, string> TW = new()
{
["key_0"] = "繁中文本1",
};
public static Dictionary<string, string> EN = new()
{
["key_0"] = "Text 1",
};
}