Beispiel #1
0
        private async Task GetLangData()
        {
            SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            // First time users logs in, set the language to their culture if we support it, or English.
            if (Session.ActiveUser.AppLang == 0)
            {
                var currentMobileLang = Localise.GetCurrentCultureInfo().TwoLetterISOLanguageName;
                var isSupportedLang   = SupportedLanguages.FirstOrDefault((lang) => lang.Code == currentMobileLang);
                Session.ActiveUser.AppLang = isSupportedLang != null ? isSupportedLang.Id : 1;
                // This will save the choice for future: reopening app, other activities, etc.
                Queries.SaveActiveUser();
            }

            var found = SupportedLanguages.Find((lang) => lang.Id == Session.ActiveUser.AppLang);

            StringResources.Culture = new CultureInfo(found.Code);
            Localise.SetLocale(StringResources.Culture);

            SetLayoutDirection();

            nav = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);
            LoadNavigationTitles();
            nav.NavigationItemSelected += NavigationItemSelected;

            LanguageChoiceManager.RefreshIfNeeded();
        }