예제 #1
0
        /// <summary>
        /// 设置新的本地化字典管理器以供后续使用。
        /// </summary>
        /// <param name="localizationManager">新的本地化字典管理器对象</param>
        /// <exception cref="System.ArgumentNullException">localizationManager是null</exception>
        public static void SetLocalizationDictionaryManager(ILocalizationDictionaryManager localizationManager)
        {
            if (localizationManager == null)
            {
                throw new ArgumentNullException("localizationManager");
            }

            currentLocalMngr = localizationManager;
        }
예제 #2
0
        /// <summary>
        /// 根据指定的参数,获取key对应的本地化文本。
        /// </summary>
        /// <param name="mngr"></param>
        /// <param name="key">本地化文本的key</param>
        /// <param name="scope">用于区分词条的限定域参数</param>
        /// <param name="cultureName">语言文化名称,例如zh-CN,en-US</param>
        /// <returns>如果存在对应的本地化文本则返回其值,其他情况返回key</returns>
        public static string GetString(this ILocalizationDictionaryManager mngr, string key, string scope, string cultureName)
        {
            if (mngr == null)
            {
                throw new ArgumentNullException(nameof(mngr));
            }

            var dict = mngr.Get(cultureName);

            return(dict == null ? key : dict.Get(key, scope));
        }