async Task setSystemOrDefaultLanguage(bool isToggled)
        {
            try {
                if (!_isSystemToggleActive || isToggled == (
                        _services.Preferences.LanguageCode == Languages.SYSTEM.LangCode))
                {
                    _isSystemToggleActive = true;
                    return;
                }

                if (!await changeLanguageConfirmation())
                {
                    IsSystemLanguage = !isToggled;
                    return;
                }

                if (isToggled)
                {
                    CrossLocalization.SetLanguage(Languages.SYSTEM.LangCode);
                    toggleLanguages(Languages.SYSTEM.LangCode);
                }
                else
                {
                    CrossLocalization.SetLanguage(Languages.EN.LangCode);
                    toggleLanguages(Languages.EN.LangCode);
                }
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }
        public void SetUp()
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;

            CrossLocalization.Initialize(
                assembly,
                GlobalConsts.RunNamespace,
                GlobalConsts.LocalizationDirectory);

            CrossLocalization.AddLanguageSupport(Languages.EN);
            CrossLocalization.SetDefaultLanguage(Languages.EN.LangCode);
            CrossLocalization.SetLanguage(Languages.EN.LangCode);
        }
        /// <summary>
        /// Configure localization package.
        /// </summary>
        static void setupLocalization()
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;

            CrossLocalization.Initialize(
                assembly,
                GlobalConsts.RunNamespace,
                GlobalConsts.LocalizationDirectory);

            CrossLocalization.AddLanguageSupport(Languages.EN);
            CrossLocalization.AddLanguageSupport(Languages.RU);
            CrossLocalization.SetDefaultLanguage(Languages.EN.LangCode);
            CrossLocalization.SetLanguage(_services.Preferences.LanguageCode);
        }
Beispiel #4
0
        public void SetUp()
        {
            _mockedOffline   = Mock.Of <IPlatformServices>(ps => ps.Device.CheckConnectivity() == false);
            _mockedConnected = Mock.Of <IPlatformServices>(ps => ps.Device.CheckConnectivity() == true);

            var assembly = typeof(App).GetTypeInfo().Assembly;

            CrossLocalization.Initialize(
                assembly,
                GlobalConsts.RunNamespace,
                GlobalConsts.LocalizationDirectory);

            CrossLocalization.AddLanguageSupport(Languages.EN);
            CrossLocalization.SetDefaultLanguage(Languages.EN.LangCode);
            CrossLocalization.SetLanguage(Languages.EN.LangCode);

            Barrel.ApplicationId = GlobalConsts.AppId;
        }
        async Task selectLanguage(object selectedObject)
        {
            try {
                if (selectedObject == null && !(selectedObject is LanguagePageModel))
                {
                    return;
                }

                SelectedItem = null;
                var language = selectedObject as LanguagePageModel;

                if (await changeLanguageConfirmation())
                {
                    CrossLocalization.SetLanguage(language.LanguageCode);
                    toggleLanguage(language);
                }
            } catch (Exception ex) {
                AppLogs.Log(ex);
            }
        }