Example #1
0
    /// <summary>
    /// 从配置表中获取字符串
    /// </summary>
    /// <param name="Term">id</param>
    /// <param name="applyParameters">是否要解析参数</param>
    /// <param name="localParametersRoot">局部参数根节点</param>
    /// <param name="FixForRTL">是否修正R2L的布局</param>
    /// <param name="maxLineLengthForRTL">R2L单行的字数</param>
    /// <param name="ignoreRTLnumbers">忽略R2L中的数字</param>
    /// <param name="overrideLanguage"></param>
    /// <returns>本地化后的文字</returns>
    public string GetStringFromCfg(string Term, bool applyParameters = false, GameObject localParametersRoot = null, bool FixForRTL = true, int maxLineLengthForRTL = 0, bool ignoreRTLnumbers = true, string overrideLanguage = null)
    {
        CfgEternityProxy proxy = Facade.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;

        Language?language = proxy.GetLanguage(Term);

        string text = null;

        if (language.HasValue)
        {
            string currentLanguage = string.IsNullOrEmpty(overrideLanguage) ? LocalizationManager.CurrentLanguage : overrideLanguage;
            switch (currentLanguage)
            {
            case "Chinese": text = language.Value.Chs; break;

            case "English": text = language.Value.EnUs; break;

            default: text = language.Value.EnUs; break;
            }

            if (text != null)
            {
                if (applyParameters)
                {
                    LocalizationManager.ApplyLocalizationParams(ref text, localParametersRoot);
                }

                if (LocalizationManager.IsRight2Left && FixForRTL)
                {
                    text = LocalizationManager.ApplyRTLfix(text, maxLineLengthForRTL, ignoreRTLnumbers);
                }
            }
        }

        return(text);
    }