多语言逻辑
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
namespace NBC
|
||||
using System.Collections.Generic;
|
||||
using FairyGUI;
|
||||
|
||||
namespace NBC
|
||||
{
|
||||
public class Lan
|
||||
public static class Lan
|
||||
{
|
||||
private static LanguageManager _inst;
|
||||
|
||||
@@ -19,18 +22,59 @@
|
||||
|
||||
public static ILanguage Text => Inst.GetLanguageModule((int)LanguageModuleType.Text);
|
||||
|
||||
public static string Get(string key)
|
||||
public static void SetLanguage(this GObject child, string key, params object[] args)
|
||||
{
|
||||
if(Text == null) return key;
|
||||
return Text.Get(key);
|
||||
if (Text == null) return;
|
||||
child.lang = key;
|
||||
|
||||
var value = Text.Get(key);
|
||||
|
||||
if (args != null && args.Length > 0)
|
||||
{
|
||||
value = string.Format(value, args);
|
||||
child.langArgs = args;
|
||||
}
|
||||
else
|
||||
{
|
||||
child.langArgs = null;
|
||||
}
|
||||
|
||||
|
||||
if (child is GRichTextField richTextField)
|
||||
{
|
||||
richTextField.text = value;
|
||||
}
|
||||
else if (child is GButton button)
|
||||
{
|
||||
button.title = value;
|
||||
}
|
||||
else if (child is GLabel label)
|
||||
{
|
||||
label.title = value;
|
||||
}
|
||||
else if (child is GTextField gtextField)
|
||||
{
|
||||
gtextField.text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static string Get(string key, params object[] args)
|
||||
public static void SetLanguageImage(this GObject obj, string key)
|
||||
{
|
||||
var format = string.Format(Text.Get(key), args);
|
||||
return format;
|
||||
}
|
||||
|
||||
// public static string Get(string key)
|
||||
// {
|
||||
// if(Text == null) return key;
|
||||
// return Text.Get(key);
|
||||
// }
|
||||
//
|
||||
// public static string Get(string key, params object[] args)
|
||||
// {
|
||||
// var format = string.Format(Text.Get(key), args);
|
||||
// return format;
|
||||
// }
|
||||
|
||||
|
||||
public static string GetLanImagePath(string key)
|
||||
{
|
||||
return Inst.GetLanguageModule((int)LanguageModuleType.Image).Get(key);
|
||||
|
||||
Reference in New Issue
Block a user