| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System; |
| | | using UnityEngine; |
| | | using TableConfig; |
| | | |
| | | 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 = ConfigManager.Instance.GetTemplate<LanguageConfig>(_id); |
| | | if (languageInfo == null) |
| | | { |
| | | DesignDebug.LogFormat("缺少语言表配置,id: {0}", _id); |
| | | return string.Empty; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(languageInfo.content)) |
| | | { |
| | | DesignDebug.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) |
| | | { |
| | | DesignDebug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | public static string GetFromLocal(int _id) |
| | | { |
| | | var languageInfo = ConfigManager.Instance.GetTemplate<PriorLanguageConfig>(_id); |
| | | if (languageInfo == null) |
| | | { |
| | | DesignDebug.LogFormat("缺少语言表配置,id: {0}", _id); |
| | | return string.Empty; |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(languageInfo.Content)) |
| | | { |
| | | DesignDebug.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) |
| | | { |
| | | DesignDebug.LogFormat("语言内容格式错误,id: {0}", _id); |
| | | return content; |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System;
|
| | | using UnityEngine;
|
| | | using TableConfig;
|
| | |
|
| | | 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 = Config.Instance.Get<LanguageConfig>(_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 = Config.Instance.Get<PriorLanguageConfig>(_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;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | }
|