using System.Collections;
|
using System.Collections.Generic;
|
using System;
|
using UnityEngine;
|
|
[XLua.LuaCallCSharp]
|
public static class Language
|
{
|
public static int languageNumber {
|
get;
|
set;
|
}
|
|
public static event Action languageChangeEvent;
|
|
public static void ChangeLanguage(int _number)
|
{
|
if (languageChangeEvent != null)
|
{
|
languageChangeEvent();
|
}
|
}
|
|
public static string Get(string _id)
|
{
|
var languageInfo = LanguageConfig.Get(_id);
|
if (languageInfo == null)
|
{
|
DebugEx.LogFormat("缺少语言表配置,id: {0}", _id);
|
return string.Empty;
|
}
|
|
if (string.IsNullOrEmpty(languageInfo.content))
|
{
|
DebugEx.LogFormat("语言内容为空,id: {0}", _id);
|
}
|
|
return languageInfo.content;
|
}
|
|
public static string Get(string _id, params object[] _objects)
|
{
|
var content = Get(_id);
|
try
|
{
|
return string.Format(content, _objects);
|
}
|
catch (Exception ex)
|
{
|
DebugEx.LogFormat("语言内容格式错误,id: {0}", _id);
|
return content;
|
}
|
}
|
|
public static string GetFromLocal(int _id)
|
{
|
var languageInfo = PriorLanguageConfig.Get(_id);
|
if (languageInfo == null)
|
{
|
DebugEx.LogFormat("缺少语言表配置,id: {0}", _id);
|
return string.Empty;
|
}
|
|
if (string.IsNullOrEmpty(languageInfo.Content))
|
{
|
DebugEx.LogFormat("语言内容为空,id: {0}", _id);
|
}
|
|
return languageInfo.Content;
|
}
|
|
public static string GetFromLocal(int _id, params object[] _objects)
|
{
|
var content = GetFromLocal(_id);
|
try
|
{
|
return string.Format(content, _objects);
|
}
|
catch (Exception ex)
|
{
|
DebugEx.LogFormat("语言内容格式错误,id: {0}", _id);
|
return content;
|
}
|
}
|
|
|
}
|