지역화할 수 있는 응용 프로그램 WPF-Ui 설정을 리드하는 리소스의 문제
-
08-09-2020 - |
문제
를 만들고 싶은데 aa 지역화할 수 있는 응용 프로그램 WPF.나의 지침에 따라 의견의 첫 번째 절차를 수행하여 소스.cs file:
//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.
후에는 내가 이것을 했,내 응용 프로그램을 시작하고 있지 않다.내가 사용하는 사용자 정의 응용 프로그램 클래스:
namespace Namespace
{
public partial class App : Application
{
[STAThread()]
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Main()
{
var app = new App();
app.InitializeComponent();
app.Run();
}
[DebuggerNonUserCode()]
public void InitializeComponent()
{
this.StartupUri = new Uri("MainWindow.xaml", UriKind.Relative);
}
}
}
<ns:App
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ns="clr-namespace:Namespace">
</ns:App>
모든 것을 일하기 전에.나는 가정의 어떤 종류의 간 불일치를 구성한 Ui 설정하고 그 지정에 대한 MainWindow.xaml,but I don't 을 어떻게 해결해야 하는지 알고 있습니다.
해결책
나는 유사한 효과가있었습니다.AssemblyInfo.cs에서 NeutralResourcesLanguage
속성은 UltimateResourceFallbackLocation.Satellite
매개 변수가 필요했습니다.
// Uncommenting the following line --> OK
[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
// Uncommenting the following line --> IOException: Cannot locate resource 'app.xaml'.
// [assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
// Uncommenting the following line --> IOException: Cannot locate resource 'app.xaml'.
// [assembly: NeutralResourcesLanguage("en-US")]
. 다른 팁
모범 사례에 대한 WPF 현지화
- 설정
UltimateResourceFallback
위에서 어셈블리 정보.* 하기 지정한 해당하는 언어로 대체(예를 들어,[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
). - 로 결정한 경우를 포함하는 원어에서는 주로 어셈블리
생략
<UICulture>
태그 프로젝트에서 파일 설정UltimateResourceFallback
위치 주립 대신 위성(예를 들어,[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.MainAssembly)]
)
.
제휴하지 않습니다 StackOverflow