Пример #1
0
        /// <summary>
        /// 查找HTML中的key值
        /// </summary>
        /// <param name="html"></param>
        private void RenderMultilanguage4HTML(string html)
        {
            MatchCollection matchList = Regex.Matches(html, "lang(\\s)*=(\\s)*(\"|\')[a-zA-Z0-9_]*(\"|\')");

            foreach (Match match in matchList)
            {
                string langKeyHtmlStr = match.Value;
                string langKey        = Regex.Matches(langKeyHtmlStr, "(\"|\')[a-zA-Z0-9_]*(\"|\')")[0].Value.TrimStart('\'').TrimStart('\"').TrimEnd('\'').TrimEnd('\"');
                if (!MultiLanguageKeyList.Contains(langKey) && !string.IsNullOrWhiteSpace(langKey))
                {
                    MultiLanguageKeyList.Add(langKey);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 页面多语言处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void InitMultilanguage(object sender, EventArgs e)
        {
            Page page = sender as Page;

            if (_Page is IMultiLanguage)
            {
                this.MultiLanguageKeyList = ((IMultiLanguage)_Page).GetFormMultiLanguageKeyList();
            }
            MultiLanguageKeyList = MultiLanguageKeyList ?? new List <string>();

            MultiLanguageKeyList.Add("lang_add");
            MultiLanguageKeyList.Add("lang_create");
            MultiLanguageKeyList.Add("lang_edit");
            MultiLanguageKeyList.Add("lang_delete");
            MultiLanguageKeyList.Add("lang_inquiry");
            MultiLanguageKeyList.Add("lang_save");
            MultiLanguageKeyList.Add("lang_cancel");
            MultiLanguageKeyList.Add("lang_confirm");
            MultiLanguageKeyList.Add("lang_close");
            MultiLanguageKeyList.Add("lang_test");
            MultiLanguageKeyList.Add("lang_export");
            MultiLanguageKeyList.Add("lang_import");
            MultiLanguageKeyList.Add("lang_send");
            MultiLanguageKeyList.Add("lang_mail");
            MultiLanguageKeyList.Add("lang_detail");
            MultiLanguageKeyList.Add("lang_info");
            MultiLanguageKeyList.Add("lang_print");
            MultiLanguageKeyList.Add("lang_config");
            MultiLanguageKeyList.Add("lang_message");
            MultiLanguageKeyList.Add("lang_warnning");
            //获得DB中已维护的多语言数据
            List <Mc_Language> dbLangCollections = GetLanguageData();

            //(1)提取HTML中的lang Key值
            GetHTMLKeys(page);

            //(2)TODO:提取JS中的lang Key值

            //组装多语言JSON
            string multilanguageJSON = AssemblyLanguagePackages(MultiLanguageKeyList, dbLangCollections);

            //注入多语言JSON
            RegisterLanguagePackages(page, multilanguageJSON);
        }