Beispiel #1
0
        /// <summary>
        /// Nastavi a vrati default hodnotu jazyka
        /// </summary>
        /// <returns>Default jazyk</returns>
        private static LanguageTypes InternalGetDefaultLanguage()
        {
            LanguageTypes language = LanguageTypes.EN_US;

            UserBase.InternalSetCurrentLanguage(language);
            return(language);
        }
Beispiel #2
0
        /// <summary>
        /// Nastavi definovany jazyk do cookie uzivatela
        /// </summary>
        /// <param name="language">Jazyk ktory chceme nastavit</param>
        private static void InternalSetCurrentLanguage(LanguageTypes language)
        {
            HttpContext current = HttpContext.Current;

            if (current != null)
            {
                HttpRequest request = current.Request;
                if (request != null)
                {
                    HttpCookie cookie = request.Cookies.Get(UserBase.LanguageCookieName);
                    if (cookie == null)
                    {
                        cookie = new HttpCookie(UserBase.LanguageCookieName);
                    }
                    cookie.Value = UserBase.GetCultureFromValue(language);
                    current.Response.SetCookie(cookie);
                    if (current.Items.Contains(UserBase.LanguageCookieName))
                    {
                        current.Items[UserBase.LanguageCookieName] = language;
                    }
                    else
                    {
                        current.Items.Add(UserBase.LanguageCookieName, language);
                    }
                }
            }
        }
Beispiel #3
0
        /**
         *
         *<div style='width: 100%;text-align: right'>دریافت متن پیام </div>
         *
         * @param type نوع پیام
         * @param  langType  نوع زبان
         * @return متن پیام
         * */
        public static string GetMessage(int type, LanguageTypes langType)
        {
            var message = "";

            switch (type)
            {
            case UserNotAccept:
                if (langType.Equals(LanguageTypes.En))
                {
                    message = "user not accept your request";
                }
                else
                {
                    message = "با درخواست شما موافقت نشده است";
                }

                break;

            case AppNotInstalled:
                if (langType.Equals(LanguageTypes.En))
                {
                    message = "app not installed.";
                }
                else
                {
                    message = "کاربر برنامه را نصب نکرده است";
                }

                break;

            case UserVersionConflict:
                if (langType.Equals(LanguageTypes.En))
                {
                    message = "user app version not update";
                }
                else
                {
                    message = "نسخه بازی کاربر مورد نظر به روز نمی باشد.";
                }

                break;

            case UserIsBusy:
                if (langType.Equals(LanguageTypes.En))
                {
                    message = "user is busy.";
                }
                else
                {
                    message = "کاربر مورد نظر مشغول انجام بازی می باشد.";
                }

                break;
            }

            return(message);
        }
Beispiel #4
0
        /// <summary>
        /// Vrati iso kod pre pozadovany typ jazyka
        /// </summary>
        /// <param name="type">LanguageTypes</param>
        /// <returns>Iso code alebo null</returns>
        public static String GetIsoCodeFromValue(LanguageTypes type)
        {
            FieldInfo fieldInfo = type.GetType().GetField(type.ToString());

            LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
            if (attributes != null && attributes.Length > 0)
            {
                foreach (LanguageAttribute attribute in attributes)
                {
                    return(attribute.IsoCode);
                }
            }
            return(String.Empty);
        }
Beispiel #5
0
        public string PropertyParameterString(LanguageTypes Language)
        {
            if (this.PropertyParameters.Count == 0 || Language == LanguageTypes.Unknown)
            {
                return(string.Empty);
            }
            var    sb = new StringBuilder(512);
            string LanguageTypeFormat = Language == LanguageTypes.VisualBasic ? "{3}{0} As {1}, " : "{3}{1} {0}, ";

            foreach (var obj in this.PropertyParameters)
            {
                sb.AppendFormat(LanguageTypeFormat, obj.ParameterName, obj.ParameterTypeName);
            }
            sb.Length = sb.Length - 2;
            return(sb.ToString());
        }
Beispiel #6
0
        public static LanguageTypes GetLanguageType(string lang)
        {
            LanguageTypes languageType = LanguageTypes.Romanian;

            switch (lang)
            {
            case "ru":
                languageType = LanguageTypes.Russian;
                break;

            case "en":
                languageType = LanguageTypes.English;
                break;
            }

            return(languageType);
        }
Beispiel #7
0
        /// <summary>
        /// Vrati aktualnu kulturu requestu
        /// </summary>
        /// <param name="language">Jazyk ktoreho kulturu chceme ziskat</param>
        /// <returns>Kultura alebo null</returns>
        private CultureInfo InternalGetCurrentCulture(LanguageTypes language)
        {
            FieldInfo fieldInfo = language.GetType().GetField(language.ToString());

            LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
            if (attributes != null && attributes.Length > 0)
            {
                foreach (LanguageAttribute attribute in attributes)
                {
                    if (!String.IsNullOrWhiteSpace(attribute.Culture))
                    {
                        return(new CultureInfo(attribute.Culture));
                    }
                }
            }
            return(null);
        }
 /// <summary>
 /// Vrati iso kod pre pozadovany typ jazyka
 /// </summary>
 /// <param name="type">LanguageTypes</param>
 /// <returns>Iso code alebo null</returns>
 public static String GetIsoCodeFromValue(LanguageTypes type)
 {
     FieldInfo fieldInfo = type.GetType().GetField(type.ToString());
     LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
     if (attributes != null && attributes.Length > 0)
     {
         foreach (LanguageAttribute attribute in attributes)
         {
             return attribute.IsoCode;
         }
     }
     return String.Empty;
 }
 /// <summary>
 /// Nastavi definovany jazyk do cookie uzivatela
 /// </summary>
 /// <param name="language">Jazyk ktory chceme nastavit</param>
 private static void InternalSetCurrentLanguage(LanguageTypes language)
 {
     HttpContext current = HttpContext.Current;
     if (current != null)
     {
         HttpRequest request = current.Request;
         if (request != null)
         {
             HttpCookie cookie = request.Cookies.Get(UserBase.LanguageCookieName);
             if (cookie == null)
             {
                 cookie = new HttpCookie(UserBase.LanguageCookieName);
             }
             cookie.Value = UserBase.GetCultureFromValue(language);
             current.Response.SetCookie(cookie);
             if (current.Items.Contains(UserBase.LanguageCookieName))
             {
                 current.Items[UserBase.LanguageCookieName] = language;
             }
             else
             {
                 current.Items.Add(UserBase.LanguageCookieName, language);
             }
         }
     }
 }
 public StringToWPFViewConverter(LanguageTypes languageTypes = LanguageTypes.CSharp)
 {
     _LanguageTypes = languageTypes;
 }
Beispiel #11
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 public LanguageVM()
 {
     languageType = LanguageTypes.Other;
 }
 /// <summary>
 /// Vrati aktualnu kulturu requestu
 /// </summary>
 /// <param name="language">Jazyk ktoreho kulturu chceme ziskat</param>
 /// <returns>Kultura alebo null</returns>
 private CultureInfo InternalGetCurrentCulture(LanguageTypes language)
 {
     FieldInfo fieldInfo = language.GetType().GetField(language.ToString());
     LanguageAttribute[] attributes = (LanguageAttribute[])fieldInfo.GetCustomAttributes(typeof(LanguageAttribute), false);
     if (attributes != null && attributes.Length > 0)
     {
         foreach (LanguageAttribute attribute in attributes)
         {
             if (!String.IsNullOrWhiteSpace(attribute.Culture))
             {
                 return new CultureInfo(attribute.Culture);
             }
         }
     }
     return null;
 }
 public LanguageData(long id, string name, LanguageTypes type) : base(id, name)
 {
     Type           = type;
     _preConversion = new List <LanguageConversionData>();
     _conversion    = new List <LanguageConversionData>();
 }