Esempio n. 1
0
        public void MultiLanguageAliasNameTest()
        {
            string webRootPath = _hostingEnvironment;

            var langUSFilePath = webRootPath + @"\en-US.mo";
            var langCNFilePath = webRootPath + @"\zh-CN.mo";

            string cultureCode = "en-US";
            string msgid       = "仅自选时用户地址不能为空";



            List <string> aliasName = new List <string>();

            aliasName.Add("测试英语");
            aliasName.Add("我的英语");

            SingleLanguage langEn = new SingleLanguage("en-US", langUSFilePath, aliasName);
            SingleLanguage langZh = new SingleLanguage("zh-CN", langCNFilePath, null);

            List <SingleLanguage> langs = new List <SingleLanguage>();

            langs.Add(langEn);
            langs.Add(langZh);

            _adpter.InitLanguageManager(langs);

            string cultureCodeAlias = "我的英语";

            var manager = _adpter.GetLanguageManager();
            var result  = manager.GetTranslate(cultureCodeAlias, msgid);

            Assert.Equal(result.Result, "Parameter 'userAddress' can not be null or whitespace when 'onlyUserMarked' is true.");
        }
Esempio n. 2
0
    public void addLanguageToList(string newLanguageName)
    {
        if (newLanguageName == null || newLanguageName == "")
        {
            return;
        }

        // make sure doesnt exist
        foreach (var l in languageList)
        {
            if (l.languageName == newLanguageName)
            {
                return;
            }
        }

        SingleLanguage newLanguage = new SingleLanguage();

        newLanguage.languageName = newLanguageName;
        foreach (var l in keyList)
        {
            newLanguage.languageItems.Add(new DictionaryItems(l.key, l.value));
        }
        languageList.Add(newLanguage);
    }
Esempio n. 3
0
        public void MultiLanguageTest()
        {
            string webRootPath = _hostingEnvironment;

            var langUSFilePath = webRootPath + @"\en-US.mo";
            var langCNFilePath = webRootPath + @"\zh-CN.mo";

            string cultureCode = "en-US";
            string msgid       = "仅自选时用户地址不能为空";

            List <string> parms = new List <string>();

            parms.Add("test1");
            parms.Add("test2");

            SingleLanguage langEn = new SingleLanguage("en-US", langUSFilePath, null);
            SingleLanguage langZh = new SingleLanguage("zh-CN", langCNFilePath, null);

            List <SingleLanguage> langs = new List <SingleLanguage>();

            langs.Add(langEn);
            langs.Add(langZh);

            _adpter.InitLanguageManager(langs);

            var manager = _adpter.GetLanguageManager();
            var result  = manager.GetTranslate(cultureCode, msgid);

            msgid = "paramsErrorResult";


            result = manager.GetTranslate(cultureCode, msgid, parms);



            Assert.Equal(result.Result, "Incorrect Parameter 'test1'.");

            List <string> cultureCodes = new List <string>();
            List <string> Msgid        = new List <string>();

            cultureCodes.Add("zh-CN");
            cultureCodes.Add("en-US");

            Msgid.Add("propertyManageName");
            Msgid.Add("propertyManageArr1");
            Msgid.Add("propertyManageArr2");


            var resultPartLoad = manager.GetLanguageShowDataParts(cultureCodes, Msgid, false);

            Assert.Equal(resultPartLoad.Count.ToString(), "2");
        }
Esempio n. 4
0
        /// <summary>
        /// 在_languageManager未完成初始化的时候,调用此方法创建语言对象,并在构造函数里初始化_languageManger
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        private List <SingleLanguage> CreateSingleLanguageList(string path)
        {
            DirectoryInfo         root            = new DirectoryInfo(path);
            List <SingleLanguage> singleLanguages = new List <SingleLanguage>();

            foreach (FileInfo f in root.GetFiles())
            {
                if (f.Name.Substring(f.Name.Length - 3) == ".mo")
                {
                    var            cultureCode    = f.Name.Replace(".mo", "");
                    var            moUrl          = f.FullName;
                    SingleLanguage singleLanguage = new SingleLanguage(cultureCode, moUrl);
                    singleLanguages.Add(singleLanguage);
                }
            }

            return(singleLanguages);
        }
Esempio n. 5
0
 public LannguageIndex(string index, string indexType, SingleLanguage singleLanguage)
 {
     Index          = index;
     IndexType      = indexType;
     SingleLanguage = singleLanguage;
 }