[英]Why VS2012 doesn't create new language file for me?
What I want: 我想要的是:
add new languages support for my windows phone app 为我的Windows Phone应用添加新语言支持
What I refer: 我指的是:
MSDN: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff637520(v=vs.105).aspx MSDN: http : //msdn.microsoft.com/zh-CN/library/windowsphone/develop/ff637520( v= vs.105).aspx
The Document say: 该文件说:
Visual Studio has created a new resource file for each supported language that is a copy of the neutral resource file (AppResources.resx) and renamed it to include the locale code that reflects the new resource file's Culture.
Visual Studio已为每种受支持的语言创建了一个新的资源文件,该文件是中性资源文件(AppResources.resx)的副本,并将其重命名为包含反映新资源文件的区域性的语言环境代码。
What happened? 发生了什么?
After I add new languages in the project properties windows,and I save and build the solution. 在项目属性窗口中添加新语言之后,我保存并构建了解决方案。 Nothing happened.....
没啥事儿.....
Why and how to solve it? 为什么以及如何解决?
Unfortunatly the automatic generation of the AppResources.resx files only seems to work for Windows Phone 8 apps. 不幸的是,AppResources.resx文件的自动生成似乎仅适用于Windows Phone 8应用程序。 For Windows Phone 7 apps you have to do it all manually.
对于Windows Phone 7应用程序,您必须手动完成所有操作。 This is how to localize your app in Windows Phone 7:
这是在Windows Phone 7中本地化应用程序的方法:
Step 1: Choose languages in "Supported Cultures" in project properties (same as for WP8) 步骤1:在项目属性的“支持的文化”中选择语言(与WP8相同)
Step 2: Right click on project in solution explorer -> Add -> New Item... 步骤2:在解决方案资源管理器中的项目上单击鼠标右键->添加->新建项目...
Step 3: Select the type Resources File
and name it AppResources.resx
步骤3:选择类型
Resources File
并将其命名为AppResources.resx
Step 4: Open the AppResources.resx
file and change the Access Modifier
to Public
: 步骤4:打开
AppResources.resx
文件,然后将Access Modifier
更改为Public
:
Step 5: Repeat step 2, 3, and 4 for every other language you want to use, naming the file AppResources.<culture>.resx
, for example AppResources.sv.resx
for Swedish. 步骤5:对要使用的其他每种语言重复步骤2、3和4,将文件命名为
AppResources.<culture>.resx
,例如瑞典语的AppResources.sv.resx
。
Step 6: Create a class named "LocalizedStrings.cs" with the following code: 步骤6:使用以下代码创建一个名为“ LocalizedStrings.cs”的类:
public class LocalizedStrings
{
private static AppResources _localizedResources = new AppResources();
public AppResources AppResources
{
get { return _localizedResources; }
}
}
Step 7: Open App.xaml, and add the following to <Appllication.Resources>
: 步骤7:打开App.xaml,并将以下内容添加到
<Appllication.Resources>
:
<Application.Resources>
<local:LocalizedStrings x:Key="LocalizedStrings" />
</Application.Resources>
Step 8: You can now use the translations in the following way: 步骤8:您现在可以通过以下方式使用翻译:
<TextBlock Text="{Binding AppResources.Title, Source={StaticResource LocalizedStrings}}" />
Where Title
is the Name
column in the AppResources.resx files. 其中“
Title
是AppResources.resx文件中的“ Name
列。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.