예제 #1
0
        public static string GetCurrentLanguageId(Context context)
        {
            string languageId = null;

            try
            {
                languageId = PrefUtil.Get(context, PrefUtil.KEY_CURRENT_LANGUAGE_ID, null);
                languageId = null;
                if (languageId == null)
                {
                    languageId = Java.Util.Locale.Default.Language.ToLower();
                }
                if (!SUPPORT_LANG.Contains(languageId))
                {
                    languageId = LANG_EN_ID;
                }
            }
            catch (Exception e)
            {
                Log.Error(TAG, e.ToString());
            }
            finally
            {
                if (TextUtils.IsEmpty(languageId))
                {
                    languageId = LANG_EN_ID;
                }
            }
            return(languageId);
        }
예제 #2
0
        public static void SetLocale(Context context, string languageId)
        {
            var config = new Configuration();

            PrefUtil.Put(context, PrefUtil.KEY_CURRENT_LANGUAGE_ID, languageId);
            config.Locale = new Locale(languageId);
            context.Resources.UpdateConfiguration(config, context.Resources.DisplayMetrics);
        }