在Windows Phone 8.1通用应用程序中更改语言

时间:2015-02-19 06:44:32

标签: windows-phone-8.1 globalization win-universal-app

        if (LanguageComboBox.SelectedIndex == 0)
        {
            var culture = new CultureInfo("en-US");
            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
            CultureInfo.DefaultThreadCurrentCulture = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;
            (Window.Current.Content as Frame).FlowDirection = Windows.UI.Xaml.FlowDirection.LeftToRight;
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            HeadingTextBlock.Text = loader.GetString("Setting");
        }
        else if (LanguageComboBox.SelectedIndex == 1)
        {
            var culture = new CultureInfo("ar-SA");
            Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = culture.Name;
            CultureInfo.DefaultThreadCurrentCulture = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;
            (Window.Current.Content as Frame).FlowDirection = Windows.UI.Xaml.FlowDirection.RightToLeft;
            var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
            HeadingTextBlock.Text = loader.GetString("Setting");
        }

这是我在应用程序内的设置页面中使用的代码。设置页面后,我还设置了flow =从右到左,并在代码中手动更改标题。

问题:问题是,在设置语言并返回后,每个页面都更改了语言,但我的主屏幕仍然显示英语,除非我完全终止应用程序并再次打开它然后它在主屏幕上显示阿拉伯语。

问如果你不明白这个问题。

1 个答案:

答案 0 :(得分:0)

资源加载程序缓存资源,因此您在更改语言时必须手动删除该缓存。有关详细信息,请参阅this answer