为什么在应用程序中无法使用区域设置的实际“国家/地区"属性? [英] Why isn't the actual Country property of the regional settings available within apps?

查看:81
本文介绍了为什么在应用程序中无法使用区域设置的实际“国家/地区"属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是常见的(如何从设备获取国家/地区)问题,我已经找到了几个问题,但这实际上有些不同.

This could be the common (how to get country from device) question which I've already found several questions about, but this is actually something slightly different.

在Windows Phone中,可以在语言区域设置页面中明确指定国家(地区).我可以作为用户确定我的电话使用的是瑞典语言和瑞典的区域格式,但仍然居住在挪威或丹麦.因此我可以 在此设置页面中指定.但是看来它并没有以任何方式真正影响平台(或者至少我不知道如何).

In Windows Phone there's an opportunity to specify Country explicitly in the language-region settings page. I could as a user decide that my phone is using the Swedish language and Swedish regional format, but still live in Norway or Denmark. Hence I could specify that within this settings page. But it appears it doesn't really impact the platform in any way (or at least I don't realize how).

特别是,我希望能够在我的应用程序中读取此设置,而不必实施用户必须明确设置的特定于应用程序的设置(即使他或她已经进行了设置).

Especially I'd like to be able to read this setting within my apps instead of having to implement an application specific setting which the user has to explicitly set (even though he or she already have made that setting).

有人吗?

推荐答案

您需要调整应用程序中的设置:
WMAppmanifest->打包标签->支持的语言
应用程序设置->应用程序标签->支持的区域性

您还需要具有正确的资源文件,例如:

you need to adjust settings in you app:
WMAppmanifest->Packaging tab->Supported languages
Application settings->Application tab->Supported cultures

You also need to have the proper Resource files, example:

对于英语(美国)(App/Resources/AppResources.resx)
AppResources.resx

for English (US) (App/Resources/AppResources.resx)
AppResources.resx

,并且如果您使用瑞典语(App/Resources/AppResources.sv.resx)
AppResources.sv.resx

and if you use Swedish (App/Resources/AppResources.sv.resx)
AppResources.sv.resx

您需要在核心(App.xaml.cs)中更改应用程序,但是以后仍然可以更改它,但是我没有对此进行测试,无论如何,您应该添加以下内容:

The you need to change the application in the core (App.xaml.cs) but you can still change this later, but I didn't test that, anyway you should add this:

//Add to top of document (where you have using)
using System.Threading;
using System.Globalization;

//then add this Before RootFrame.Language line in InitializeLanguage() function
//instead of use switch you can force language by set CurrentCulture and CurrentUICulture to what you like.
switch (CultureInfo.CurrentCulture.Name)
{
   case "sv-SE":
      Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE");
      Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE");
      break;
   default:
      Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
      Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
      break;
}



这篇关于为什么在应用程序中无法使用区域设置的实际“国家/地区"属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆