//public static Context SetAppLanguage(Context activityContext)
        //{
        //    try
        //    {
        //        var res = activityContext.Resources; // Get the string

        //        Configuration config = activityContext.Resources.Configuration;

        //        var locale = activityContext.Resources.Configuration.Locale;

        //        Configuration conf = res.Configuration;
        //        conf.SetLocale(locale);

        //        Locale.Default = locale;

        //        if ((int)Build.VERSION.SdkInt > 17)
        //            conf.SetLayoutDirection(locale);

        //        DisplayMetrics dm = res.DisplayMetrics;

        //        if (config.Locale.Language.Contains("ar"))
        //        {
        //            AppSettings.Lang = "ar";
        //            AppSettings.FlowDirectionRightToLeft = true;
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;
        //        }

        //        if ((int)Build.VERSION.SdkInt >= 24)
        //        {
        //            LocaleList localeList = new LocaleList(locale);
        //            LocaleList.Default = localeList;
        //            conf.Locales = localeList;

        //            //Locale.SetDefault(Locale.Category.Display, locale);
        //            activityContext = activityContext.CreateConfigurationContext(conf);
        //            return activityContext;
        //        }

        //        conf.Locale = locale;
        //        res.UpdateConfiguration(conf, dm);

        //        Wrap(activityContext, config.Locale.Language);

        //        return activityContext;
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        return activityContext;
        //    }
        //}

        //public static ContextWrapper Wrap(Context context, string language)
        //{
        //    try
        //    {
        //        Language = language;

        //        Configuration config = context.Resources.Configuration;

        //        var sysLocale = config.Locales.Get(0);

        //        if (!language.Equals("") && !sysLocale.Language.Equals(language))
        //        {
        //            sysLocale = new Locale(language);
        //            Locale.Default = sysLocale;
        //        }
        //        CultureInfo myCulture = new CultureInfo(language);
        //        CultureInfo.DefaultThreadCurrentCulture = myCulture;
        //        config.SetLocale(sysLocale);

        //        var ss = context.Resources.Configuration.Locale;
        //        Console.WriteLine(ss);
        //        //SharedPref.SharedData.Edit().PutString("Lang_key", language).Commit();

        //        //context = context.CreateConfigurationContext(config);
        //        context.Resources.UpdateConfiguration(config, null);

        //        return new LangController(context);
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        return new LangController(context);
        //    }
        //}

        //public static void SetDefaultAppSettings()
        //{
        //    try
        //    {
        //        //Shared_Data.Edit().PutString("Lang_key", "Auto").Commit();
        //        if (AppSettings.Lang != "")
        //        {
        //            if (AppSettings.Lang == "ar")
        //            {
        //                //SharedPref.SharedData.Edit().PutString("Lang_key", "ar").Commit();
        //                AppSettings.Lang = "ar";
        //                AppSettings.FlowDirectionRightToLeft = true;
        //            }
        //            else
        //            {
        //                // SharedPref.SharedData.Edit().PutString("Lang_key", AppSettings.Lang).Commit();
        //                AppSettings.FlowDirectionRightToLeft = false;
        //            }
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;

        //            //var Lang = SharedPref.SharedData.GetString("Lang_key", AppSettings.Lang);
        //            //if (Lang == "ar")
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", "ar").Commit();
        //            //    AppSettings.Lang = "ar";
        //            //    AppSettings.FlowDirectionRightToLeft = true;
        //            //}
        //            //else if (Lang == "Auto")
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", "Auto").Commit();
        //            //}
        //            //else
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", Lang).Commit();
        //            //}
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        Console.WriteLine(exception);
        //    }
        //}

        public static void SetApplicationLang(Context context, string language)
        {
            try
            {
                Locale newLocale = new Locale(language);
                Locale.Default = (newLocale);

                Resources     res           = context.Resources;
                Configuration configuration = res.Configuration;


                if (Build.VERSION.SdkInt >= BuildVersionCodes.N)
                {
                    configuration.SetLocale(newLocale);

                    LocaleList localeList = new LocaleList(newLocale);
                    LocaleList.Default = (localeList);
                    Locale.SetDefault(Locale.Category.Display, newLocale);
                    configuration.Locales = (localeList);
                    configuration.SetLayoutDirection(newLocale);

                    CultureInfo myCulture = new CultureInfo(language);
                    CultureInfo.DefaultThreadCurrentCulture = myCulture;

                    context = context.CreateConfigurationContext(configuration);
                }
                else if (Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1)
                {
                    #pragma warning disable CS0618 // Type or member is obsolete
                    configuration.Locale = newLocale;
                    #pragma warning restore CS0618 // Type or member is obsolete

                    configuration.SetLocale(newLocale);

                    CultureInfo myCulture = new CultureInfo(language);
                    CultureInfo.DefaultThreadCurrentCulture = myCulture;

                    context = context.CreateConfigurationContext(configuration);
                }

                #pragma warning disable 618
                configuration.Locale = newLocale;
                res.UpdateConfiguration(configuration, res.DisplayMetrics);
                #pragma warning restore 618

                // var LangName = res.Configuration.Locale.Language.ToLower();

                UserDetails.LangName = language;
                AppSettings.Lang     = language;
                AppSettings.FlowDirectionRightToLeft = language.Contains("ar");
                SetCulture(language);

                //return new LangController(context);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                //return new LangController(context);
            }
        }
    // Populate the locales and set localePointer to 0
    public void initialize()
    {
        // Get the root path of the application
        string rootPath = Application.dataPath;

        // Read the content table of directory of locale path
        string       localeContentTablePath = rootPath + "/Files/Locale/localeList.content";
        StreamReader sr         = new StreamReader(localeContentTablePath);
        LocaleList   localeList = JsonUtility.FromJson <LocaleList>(sr.ReadToEnd());

        sr.Close();

        // Read the locale files
        int numOfLocales = localeList.getLength();

        locales = new SystemLocale[numOfLocales];
        for (int i = 0; i < numOfLocales; i++)
        {
            string thisLocalePath = rootPath + localeList.getDirectory(i);
            sr = new StreamReader(thisLocalePath);
            string contentOfThisLocaleFile = sr.ReadToEnd();
            sr.Close();
            SystemLocale thisLocale = JsonUtility.FromJson <SystemLocale>(contentOfThisLocaleFile);
            locales[i] = thisLocale;
        }

        // Set the first locale as the default locale
        localePointer = 0;
    }
Example #3
0
        public void Constructor()
        {
            LocaleList locales;

            locales = new LocaleList();
            Assert.IsNotNull(locales);
        }
Example #4
0
 private LocaleList GetLocales(Boolean refresh)
 {
     if (_locales.IsNull() || refresh)
     {
         _locales = CoreData.LocaleManager.GetLocales(GetUserContext());
     }
     return(_locales);
 }
Example #5
0
 public TabLocale GetLocaleProperty(string CultureCode)
 {
     if (LocaleList != null && LocaleList.Count > 0)
     {
         return(LocaleList.FirstOrDefault(x => x.CultureCode == CultureCode));
     }
     return(null);
 }
        /// <summary>
        /// Get locales from web locales.
        /// </summary>
        /// <param name="userContext">User context.</param>
        /// <param name="webLocales">Web locales.</param>
        /// <returns>Locales.</returns>
        private LocaleList GetLocales(IUserContext userContext,
                                      List <WebLocale> webLocales)
        {
            LocaleList locales;

            locales = new LocaleList();
            foreach (WebLocale webLocale in webLocales)
            {
                locales.Add(GetLocale(webLocale));
            }
            return(locales);
        }
Example #7
0
        public static LocaleList GetList(IWhere whereClause, IOrderBy orderByClause)
        {
            SqlDataReader dataReader = GetListReader(DatabaseEnum.ORDERDB, TABLE, whereClause, orderByClause, true);
            LocaleList    list       = new LocaleList();

            while (dataReader.Read())
            {
                list.Add(GetDataObjectFromReader(dataReader));
            }
            dataReader.Close();
            return(list);
        }
Example #8
0
        public static void SetApplicationLang(Context activityContext, string lang)
        {
            try
            {
                var res = activityContext.Resources; // Get the string

                Configuration config = activityContext.Resources.Configuration;

                AppSettings.Lang = lang;

                var locale = new Locale(lang);

                Configuration conf = res.Configuration;
                conf.SetLocale(locale);

                Locale.Default = locale;

                if ((int)Build.VERSION.SdkInt > 17)
                {
                    conf.SetLayoutDirection(locale);
                }

                DisplayMetrics dm = res.DisplayMetrics;

                UserDetails.LangName = lang;
                AppSettings.Lang     = lang;
                AppSettings.FlowDirectionRightToLeft = config.Locale.Language.Contains("ar");

                if ((int)Build.VERSION.SdkInt >= 24)
                {
                    LocaleList localeList = new LocaleList(locale);
                    LocaleList.Default = localeList;
                    conf.Locales       = localeList;

                    //Locale.SetDefault(Locale.Category.Display, locale);
                    activityContext = activityContext.CreateConfigurationContext(conf);
                    //return activityContext;
                }

                conf.Locale = locale;
#pragma warning disable 618
                res.UpdateConfiguration(conf, dm);
#pragma warning restore 618

                //SetDefaultAppSettings();
                Wrap(activityContext, config.Locale.Language);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Example #9
0
        public void SquareBracketOperator()
        {
            LocaleList newLocaleList, oldLocaleList;
            Int32      localeIndex;

            oldLocaleList = GetLocales(true);
            newLocaleList = new LocaleList();
            for (localeIndex = 0; localeIndex < oldLocaleList.Count; localeIndex++)
            {
                newLocaleList.Add(oldLocaleList[oldLocaleList.Count - localeIndex - 1]);
            }
            for (localeIndex = 0; localeIndex < oldLocaleList.Count; localeIndex++)
            {
                Assert.AreEqual(newLocaleList[localeIndex], oldLocaleList[oldLocaleList.Count - localeIndex - 1]);
            }
        }
        //public static Context SetAppLanguage(Context activityContext)
        //{
        //    try
        //    {
        //        var res = activityContext.Resources; // Get the string

        //        Configuration config = activityContext.Resources.Configuration;

        //        var locale = activityContext.Resources.Configuration.Locale;

        //        Configuration conf = res.Configuration;
        //        conf.SetLocale(locale);

        //        Locale.Default = locale;

        //        if ((int)Build.VERSION.SdkInt > 17)
        //            conf.SetLayoutDirection(locale);

        //        DisplayMetrics dm = res.DisplayMetrics;

        //        if (config.Locale.Language.Contains("ar"))
        //        {
        //            AppSettings.Lang = "ar";
        //            AppSettings.FlowDirectionRightToLeft = true;
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;
        //        }

        //        if ((int)Build.VERSION.SdkInt >= 24)
        //        {
        //            LocaleList localeList = new LocaleList(locale);
        //            LocaleList.Default = localeList;
        //            conf.Locales = localeList;

        //            //Locale.SetDefault(Locale.Category.Display, locale);
        //            activityContext = activityContext.CreateConfigurationContext(conf);
        //            return activityContext;
        //        }

        //        conf.Locale = locale;
        //        res.UpdateConfiguration(conf, dm);

        //        Wrap(activityContext, config.Locale.Language);

        //        return activityContext;
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        return activityContext;
        //    }
        //}

        //public static ContextWrapper Wrap(Context context, string language)
        //{
        //    try
        //    {
        //        Language = language;

        //        Configuration config = context.Resources.Configuration;

        //        var sysLocale = config.Locales.Get(0);

        //        if (!language.Equals("") && !sysLocale.Language.Equals(language))
        //        {
        //            sysLocale = new Locale(language);
        //            Locale.Default = sysLocale;
        //        }
        //        CultureInfo myCulture = new CultureInfo(language);
        //        CultureInfo.DefaultThreadCurrentCulture = myCulture;
        //        config.SetLocale(sysLocale);

        //        var ss = context.Resources.Configuration.Locale;
        //        Console.WriteLine(ss);
        //        //SharedPref.SharedData.Edit().PutString("Lang_key", language).Commit();

        //        //context = context.CreateConfigurationContext(config);
        //        context.Resources.UpdateConfiguration(config, null);

        //        return new LangController(context);
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        return new LangController(context);
        //    }
        //}

        //public static void SetDefaultAppSettings()
        //{
        //    try
        //    {
        //        //Shared_Data.Edit().PutString("Lang_key", "Auto").Commit();
        //        if (AppSettings.Lang != "")
        //        {
        //            if (AppSettings.Lang == "ar")
        //            {
        //                //SharedPref.SharedData.Edit().PutString("Lang_key", "ar").Commit();
        //                AppSettings.Lang = "ar";
        //                AppSettings.FlowDirectionRightToLeft = true;
        //            }
        //            else
        //            {
        //                // SharedPref.SharedData.Edit().PutString("Lang_key", AppSettings.Lang).Commit();
        //                AppSettings.FlowDirectionRightToLeft = false;
        //            }
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;

        //            //var Lang = SharedPref.SharedData.GetString("Lang_key", AppSettings.Lang);
        //            //if (Lang == "ar")
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", "ar").Commit();
        //            //    AppSettings.Lang = "ar";
        //            //    AppSettings.FlowDirectionRightToLeft = true;
        //            //}
        //            //else if (Lang == "Auto")
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", "Auto").Commit();
        //            //}
        //            //else
        //            //{
        //            //    SharedPref.SharedData.Edit().PutString("Lang_key", Lang).Commit();
        //            //}
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        Console.WriteLine(exception);
        //    }
        //}

        public static ContextWrapper SetApplicationLang(Context context, string language)
        {
            try
            {
                Locale locale = new Locale(language);
                Locale.SetDefault(Locale.Category.Display, locale);

                LocaleList localeList = new LocaleList(locale);
                LocaleList.Default = localeList;

                Resources     res    = context.Resources;
                Configuration config = new Configuration(res.Configuration);
                if ((int)Build.VERSION.SdkInt > 17)
                {
                    config.SetLocale(locale);
                    config.Locale = locale;
                    config.SetLayoutDirection(locale);

                    CultureInfo myCulture = new CultureInfo(language);
                    CultureInfo.DefaultThreadCurrentCulture = myCulture;

                    context = context.CreateConfigurationContext(config);

#pragma warning disable 618
                    res.UpdateConfiguration(config, res.DisplayMetrics);
#pragma warning restore 618
                }

                //var lang = context.Resources.Configuration.Locale.DisplayLanguage.ToLower();

                UserDetails.LangName = language;
                AppSettings.Lang     = language;
                AppSettings.FlowDirectionRightToLeft = config.Locale.Language.Contains("ar");
                SetCulture(config.Locale.Language);

                return(new LangController(context));
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                return(new LangController(context));
            }
        }
        private void StubDataSourceAndManagerData()
        {
            int testRoleId            = 3333;
            int testApplicationRoleId = 4444;

            UserDataSource userDataSource = new ArtDatabanken.WebService.Client.UserService.Fakes.StubUserDataSource()
            {
            };


            IUserManager testUserManager = new ArtDatabanken.Data.Fakes.StubIUserManager()
            {
                LoginStringStringStringBoolean =
                    (userName,
                     password,
                     applicationIdentifier,
                     isActivationRequired) =>
                {
                    return(this.userContext);
                },
                LoginStringStringString =
                    (userName,
                     password,
                     applicationIdentifier) =>
                {
                    return
                        (this.applicationUserContext);
                }
            };

            CoreData.UserManager            = testUserManager;
            CoreData.UserManager.DataSource = userDataSource;
            // CoreData.UserManager.DataSource = userDataSource;
            CoreData.OrganizationManager.DataSource = userDataSource;

            CountryDataSource countryDataSource = new ArtDatabanken.WebService.Client.UserService.Fakes.StubCountryDataSource();

            CoreData.CountryManager.DataSource = countryDataSource;

            LocaleDataSource localeDataSource = new ArtDatabanken.WebService.Client.UserService.Fakes.StubLocaleDataSource();
            {
            }

            ApplicationDataSource applicationDataSource =
                new ArtDatabanken.WebService.Client.UserService.Fakes.StubApplicationDataSource();

            CoreData.ApplicationManager.DataSource = applicationDataSource;

            ReferenceDataSource referenceDataSource = new ArtDatabanken.WebService.Client.ReferenceService.Fakes.StubReferenceDataSource();

            CoreData.ReferenceManager.DataSource = referenceDataSource;

            TaxonDataSource taxonDataSource = new ArtDatabanken.WebService.Client.TaxonService.Fakes.StubTaxonDataSource();

            ITaxonManager testTaxonManager = new ArtDatabanken.Data.Fakes.StubITaxonManager()
            {
            };

            CoreData.TaxonManager = testTaxonManager;

            CoreData.TaxonManager.DataSource = taxonDataSource;

            SpeciesObservationDataProviderList dataProviders = new SpeciesObservationDataProviderList();

            dataProviders.Add(new SpeciesObservationDataProvider());
            SpeciesObservationDataSource speciesObservationDataSource =
                new ArtDatabanken.WebService.Client.SpeciesObservationService.Fakes.StubSpeciesObservationDataSource()
            {
                //  public SpeciesObservationFieldDescriptionList GetSpeciesObservationFieldDescriptions(IUserContext userContext)
            };
            SpeciesObservationManager testSpeciesObservationManager =
                new ArtDatabanken.Data.Fakes.StubSpeciesObservationManager()
            {
                GetSpeciesObservationDataProvidersIUserContext
                    = (context) => { return(dataProviders); }
            };

            CoreData.SpeciesObservationManager = testSpeciesObservationManager;

            CoreData.SpeciesObservationManager.DataSource         = speciesObservationDataSource;
            CoreData.MetadataManager.SpeciesObservationDataSource = speciesObservationDataSource;

            RegionDataSource regionDataSource =
                new ArtDatabanken.WebService.Client.GeoReferenceService.Fakes.StubRegionDataSource();

            CoreData.RegionManager.DataSource = regionDataSource;

            AnalysisDataSource analysisDataSource =
                new ArtDatabanken.WebService.Client.AnalysisService.Fakes.StubAnalysisDataSource();

            CoreData.AnalysisManager.DataSource = analysisDataSource;



            this.StubApplicationUserContex(testApplicationRoleId);

            this.StubUserContext(testRoleId);

            LocaleList usedLocales  = new LocaleList();
            ILocale    testSvLocale = new Locale(
                AnalysisPortalTestSettings.Default.SwedishLocaleId,
                AnalysisPortalTestSettings.Default.SwedishLocale,
                AnalysisPortalTestSettings.Default.SwedishNameString,
                AnalysisPortalTestSettings.Default.SvenskNameString,
                new DataContext(this.userContext));

            usedLocales.Add(testSvLocale);

            LocaleManager testLocaleManager = new ArtDatabanken.Data.Fakes.StubLocaleManager()
            {
                GetUsedLocalesIUserContext =
                    (context) =>
                {
                    return(usedLocales);
                },
                GetDefaultLocaleIUserContext
                    =
                        (context) =>
                    {
                    return
                        (testSvLocale);
                    }
            };

            CoreData.LocaleManager            = testLocaleManager;
            CoreData.LocaleManager.DataSource = localeDataSource;
        }
Example #12
0
 public LocaleListTest()
 {
     _locales = null;
 }
        //public static Context SetAppLanguage(Context activityContext)
        //{
        //    try
        //    {
        //        var res = activityContext.Resources; // Get the string

        //        Configuration config = activityContext.Resources?.Configuration;

        //        var locale = activityContext.Resources?.Configuration?.Locale;

        //        Configuration conf = res.Configuration;
        //        conf.SetLocale(locale);

        //        Locale.Default = locale;

        //        if ((int)Build.VERSION.SdkInt > 17)
        //            conf.SetLayoutDirection(locale);

        //        DisplayMetrics dm = res.DisplayMetrics;

        //        if (config.Locale.Language.Contains("ar"))
        //        {
        //            AppSettings.Lang = "ar";
        //            AppSettings.FlowDirectionRightToLeft = true;
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;
        //        }

        //        if ((int)Build.VERSION.SdkInt >= 24)
        //        {
        //            LocaleList localeList = new LocaleList(locale);
        //            LocaleList.Default = localeList;
        //            conf.Locales = localeList;

        //            //Locale.SetDefault(Locale.Category.Display, locale);
        //            activityContext = activityContext.CreateConfigurationContext(conf);
        //            return activityContext;
        //        }

        //        conf.Locale = locale;
        //        res.UpdateConfiguration(conf, dm);

        //        Wrap(activityContext, config.Locale.Language);

        //        return activityContext;
        //    }
        //    catch (Exception e)
        //    {
        //        Methods.DisplayReportResultTrack(e);
        //        return activityContext;
        //    }
        //}

        //public static ContextWrapper Wrap(Context context, string language)
        //{
        //    try
        //    {
        //        Language = language;

        //        Configuration config = context.Resources?.Configuration;

        //        var sysLocale = config.Locales.Get(0);

        //        if (!language.Equals("") && !sysLocale.Language.Equals(language))
        //        {
        //            sysLocale = new Locale(language);
        //            Locale.Default = sysLocale;
        //        }
        //        CultureInfo myCulture = new CultureInfo(language);
        //        CultureInfo.DefaultThreadCurrentCulture = myCulture;
        //        config.SetLocale(sysLocale);

        //        var ss = context.Resources?.Configuration?.Locale;
        //        Console.WriteLine(ss);
        //        //SharedPref.SharedData.Edit()?.PutString("Lang_key", language)?.Commit();

        //        //context = context.CreateConfigurationContext(config);
        //        context.Resources?.UpdateConfiguration(config, null);

        //        return new LangController(context);
        //    }
        //    catch (Exception e)
        //    {
        //        Methods.DisplayReportResultTrack(e);
        //        return new LangController(context);
        //    }
        //}

        //public static void SetDefaultAppSettings()
        //{
        //    try
        //    {
        //        //Shared_Data.Edit().PutString("Lang_key", "Auto")?.Commit();
        //        if (AppSettings.Lang != "")
        //        {
        //            if (AppSettings.Lang == "ar")
        //            {
        //                //SharedPref.SharedData.Edit()?.PutString("Lang_key", "ar")?.Commit();
        //                AppSettings.Lang = "ar";
        //                AppSettings.FlowDirectionRightToLeft = true;
        //            }
        //            else
        //            {
        //                // SharedPref.SharedData.Edit()?.PutString("Lang_key", AppSettings.Lang)?.Commit();
        //                AppSettings.FlowDirectionRightToLeft = false;
        //            }
        //        }
        //        else
        //        {
        //            AppSettings.FlowDirectionRightToLeft = false;

        //            //var Lang = SharedPref.SharedData.GetString("Lang_key", AppSettings.Lang);
        //            //if (Lang == "ar")
        //            //{
        //            //    SharedPref.SharedData.Edit()?.PutString("Lang_key", "ar")?.Commit();
        //            //    AppSettings.Lang = "ar";
        //            //    AppSettings.FlowDirectionRightToLeft = true;
        //            //}
        //            //else if (Lang == "Auto")
        //            //{
        //            //    SharedPref.SharedData.Edit()?.PutString("Lang_key", "Auto")?.Commit();
        //            //}
        //            //else
        //            //{
        //            //    SharedPref.SharedData.Edit()?.PutString("Lang_key", Lang)?.Commit();
        //            //}
        //        }
        //    }
        //    catch (Exception exception)
        //    {
        //        Methods.DisplayReportResultTrack(exception);
        //    }
        //}

        public static LangController SetApplicationLang(Context context, string language)
        {
            try
            {
                Locale newLocale = new Locale(language);

                Locale locale = newLocale;
                Locale.Default = locale;

                Resources     res           = context.Resources;
                Configuration configuration = res.Configuration;


                switch (Build.VERSION.SdkInt)
                {
                case >= BuildVersionCodes.N:
                {
                    configuration.SetLocale(newLocale);

                    LocaleList localeList = new LocaleList(newLocale);
                    LocaleList.Default = localeList;
                    Locale.SetDefault(Locale.Category.Display, newLocale);
                    configuration.Locales = localeList;
                    configuration.SetLayoutDirection(newLocale);

                    CultureInfo myCulture = new CultureInfo(language);
                    CultureInfo.DefaultThreadCurrentCulture = myCulture;

                    context = context.CreateConfigurationContext(configuration);
                    break;
                }

                case >= BuildVersionCodes.JellyBeanMr1:
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    configuration.Locale = newLocale;
#pragma warning restore CS0618 // Type or member is obsolete

                    configuration.SetLocale(newLocale);

                    CultureInfo myCulture = new CultureInfo(language);
                    CultureInfo.DefaultThreadCurrentCulture = myCulture;

                    context = context.CreateConfigurationContext(configuration);

#pragma warning disable 618
                    res.UpdateConfiguration(configuration, res.DisplayMetrics);
#pragma warning restore 618
                    break;
                }

                default:
#pragma warning disable 618
                    configuration.Locale = newLocale;
                    res.UpdateConfiguration(configuration, res.DisplayMetrics);
#pragma warning restore 618
                    break;
                }

                UserDetails.LangName = language;
                AppSettings.Lang     = language;
                AppSettings.FlowDirectionRightToLeft = language.Contains("ar");
                SetCulture(language);

                return(new LangController(context));
            }
            catch (Exception exception)
            {
                Methods.DisplayReportResultTrack(exception);
                return(new LangController(context));
            }
        }