Exemplo n.º 1
0
        //--------------------------------------------------------------------

        /// <summary>
        /// 获取当前语言字符(比如 zh-cn,或 en-us)
        /// </summary>
        /// <returns></returns>
        public static String getLangString()
        {
            String defaultLang = "zh-cn";

            String langCookie = CurrentRequest.getLangCookie();

            if (strUtil.HasText(langCookie) && langLocaleAll.ContainsKey(langCookie))
            {
                return(langCookie);
            }

            if (CurrentRequest.getUserLanguages() == null)
            {
                return(defaultLang);
            }
            String[] reqLangs = CurrentRequest.getUserLanguages();
            if (reqLangs.Length == 0)
            {
                return(defaultLang);
            }
            if (langLocaleAll.ContainsKey(reqLangs[0]))
            {
                return(reqLangs[0]);
            }

            return(defaultLang);
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------

        /// <summary>
        /// 获取当前语言字符(比如 zh-cn,或 en-us)
        /// </summary>
        /// <returns></returns>
        public static String getLangString()
        {
            Object ret = CurrentRequest.getItem("__lang_name");

            if (ret == null)
            {
                String langCookie = CurrentRequest.getLangCookie();
                logger.Info("lang cookie: " + ret);
                ret = getLangNamePrivate(langCookie);
                CurrentRequest.setItem("__lang_name", ret);
            }

            return(ret.ToString());
        }