中性资源语言的使用

7
下面的文本来自一个生成的AssemblyInfo文件。这是否意味着微软建议我手动修改.csproj文件?通过某个设置?
如果是通过某个设置进行修改,那么NeutralResourcesLanguage属性还有什么用?在代码中该如何访问它。
谢谢, Berryl
//In order to begin building localizable applications, set 
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>.  For example, if you are using US english
//in your source files, set the <UICulture> to en-US.  Then uncomment
//the NeutralResourceLanguage attribute below.  Update the "en-US" in
//the line below to match the UICulture setting in the project file.

//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
3个回答

10

这个属性(不是设置)可以在项目属性中定义,如下所示:

  1. 在“解决方案资源管理器”中,右键单击你的项目,然后选择属性。
  2. 从左侧导航栏中选择“应用程序”,然后点击“程序集信息”。
  3. 在“程序集信息”对话框中,从“中性语言”下拉列表中选择语言。
  4. 点击“确定”。

谢谢,但是VS Express不会添加 ,UltimateResourceFallbackLocation.Satellite。因此,您必须打开AssemblyInfo.cs并手动添加突出显示的文本。 - Dmitriy

8
在 .Net Core 项目中,您可以在 csproj 文件中指定它:
<PropertyGroup>
  <TargetFramework>netcoreapp3.0</TargetFramework>
  <NeutralLanguage>fr</NeutralLanguage>
</PropertyGroup>

或者使用Visual Studio

  1. 在“解决方案资源管理器”中,右键点击您的项目,然后单击属性
  2. 从左侧导航栏选择
  3. 选择程序集中性语言的值。

0

将此内容放入项目的 csproj 文件中:

<ItemGroup>
    <AssemblyAttribute Include="System.Resources.NeutralResourcesLanguageAttribute">
        <_Parameter1>"en-US"</_Parameter1>
        <_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
        <_Parameter2>System.Resources.UltimateResourceFallbackLocation.Satellite</_Parameter2>
        <_Parameter2_IsLiteral>true</_Parameter2_IsLiteral>
    </AssemblyAttribute>
</ItemGroup>

1
根据目前的写法,你的回答不够清晰。请编辑以添加更多细节,帮助其他人理解这如何回答所提出的问题。你可以在帮助中心找到关于如何撰写好回答的更多信息。 - Community

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接