Dot-Net

中性資源語言使用

  • January 1, 2020

下面的措辭來自生成的 AssemblyInfo 文件。這是否意味著 MS 建議我手動修改 .csproj 文件?通過設置?

如果是通過設置,那麼 NeutralResourcesLanguage 屬性有什麼用?你應該如何在程式碼中訪問它。

乾杯,

貝里爾

//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)]

此屬性(不是設置)可以在項目屬性中定義,如下所示

  1. 在解決方案資源管理器中,右鍵點擊您的項目,然後點擊“屬性”。
  2. 從左側導航欄中選擇應用程序,然後點擊程序集資訊。
  3. 在“程序集資訊”對話框中,從“中性語言”下拉列表中選擇語言。
  4. 點擊確定。

在**.Net 核心**項目中,您可以在以下位置指定它csproj

<PropertyGroup>
 <TargetFramework>netcoreapp3.0</TargetFramework>
 <NeutralLanguage>fr</NeutralLanguage>
</PropertyGroup>

或使用Visual studio

  1. 在解決方案資源管理器中,右鍵點擊您的項目,然後點擊Properties
  2. 從左側導航欄中選擇Package
  3. 選擇值Assembly neutral language

引用自:https://stackoverflow.com/questions/8522035