C# 为什么赢了';我的应用程序找不到默认的附属程序集en-US资源吗?
我正在用WPF创建一个多语言应用程序。我使用的是静态资源,即存储在.resx/res文件中的字符串,以使文本显示在用户的区域性中 以下是项目目录结构的一部分:C# 为什么赢了';我的应用程序找不到默认的附属程序集en-US资源吗?,c#,wpf,xaml,localization,resx,C#,Wpf,Xaml,Localization,Resx,我正在用WPF创建一个多语言应用程序。我使用的是静态资源,即存储在.resx/res文件中的字符串,以使文本显示在用户的区域性中 以下是项目目录结构的一部分: 资源 GreetingWindowRes.resx(对于en-US,这是默认值) 欢迎Swindowres.de-de.resx 在.csproj中,我有:en-US 在AssemblyInfo.cs:[汇编:NeutralResourcesLanguage(“en-US”,ultimateResourceCallBackLoca
- 资源
- GreetingWindowRes.resx(对于en-US,这是默认值)
- 欢迎Swindowres.de-de.resx
en-US
在AssemblyInfo.cs:[汇编:NeutralResourcesLanguage(“en-US”,ultimateResourceCallBackLocation.Satellite)]
编译后,我可以看到资源文件出现:
- en US/MyApp.resources.dll
- de de/MyApp.resources.dll
<windows:MyWindowBase x:Class="CommanderDotNET.MyApp.Windows.GreetingWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:windows="clr-namespace:MyApp.Windows"
xmlns:res="clr-namespace:MyApp.Resources">
<Label Content="{x:Static res:GreetingWindowRes.FirstGreetingText}" />
</windows:MyWindowBase>
结果令我感到困惑:
UltimateResourceAllBackLocation.Satellite
+
时,主语言需要同时具有ResxResource.resx和GreetingWindowRes.en-US.resx文件(严重重复)
但是,如果您只想使用Resx资源,而不想使用BAML本地化,那么这不是一条可行的道路,而且情况要好得多。仅使用Resx资源的正确方法:
- AssemblyInfo.cs:
[汇编:NeutralResourcesLanguage(“en-US”,UltimateResourceCallbackLocation.mainSassembly)]
- .csproj:不要添加
- 资源命名:ResxResource.resx(主语言)+ResxResource.de-de.resx(附加语言)
我认为(但我可能错了)Resources.resx用于默认区域性,或者用于PC的区域性。感谢您的解释:)