I try to make my application multilingual. For this I have created two resource files:
- Resource.de-DE.resx
- Resource.en-US.resx
Both are set to public and contain the same keyword and translation. I can also access the keywords in the backend -> see image. Unfortunately my program does not load the files when I change the language.
My steps:
- set the default Resources.resx to public.
- copied this file twice
- renamed file to (see above)
- keywords translation entered and checked
- project created again
- included on the Button-Content by:
<Button x:Name="Home_Button" Style="{DynamicResource Menuebutton}" Content="{x:Static p:Resources.Menue_home}" Click="Home_Click"/>
- access of the object set by:
xmlns:p="clr-namespace:VS_Launcher.Properties"
- include in the MainWindow.xaml.cs by:
CultureInfo myCultureInfo = new CultureInfo("en-US");
CultureInfo.DefaultThreadCurrentCulture = myCultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = myCultureInfo;
Thread.CurrentThread.CurrentCulture = myCultureInfo;
Thread.CurrentThread.CurrentUICulture = myCultureInfo;
In another project I did the same thing. But there the solution worked. What is my error?
Resource Files Directory structure
CodePudding user response:
Are you sure the file names of alternative language resources (excluding culture-locale) are identical with default one? If the default one is Resources
.resx, alternative ones must be like:
- Resource
s
.de-DE.resx - Resource
s
.en-US.resx