Okay, so the overall goal of this prototype is to create a GUI window using WPF in C# that allows the user to change languages from a menu. At the moment I am trying to switch some of the components of my window from English to German using an App.config file. I know that will not allow the assets to change using a button, but it's a start.
I have 3 resource files. One is a default (English), another is English as well, labelled en-US, and the last one is German, labelled de-DE. They are all PUBLIC.
I have used these two videos as guide lines:
http://www.youtube.com/watch?v=5MuN6VOw9r4
http://www.youtube.com/watch?v=BK7jp3snwCQ
I set the content of a label and two buttons in the XAML
section:
<Label Content="{x:Static properties:Resources.Label1}" Height="28" Margin="6,6,79,0" Name="Label1" VerticalAlignment="Top"></Label>
<Button Content="{x:Static properties:Resources.Button1}" Height="23" HorizontalAlignment="Left" Margin="6,40,0,0" Name="Button1" VerticalAlignment="Top" Width="75"></Button>
<Button Content="{x:Static properties:Resources.Button2}" Height="23" HorizontalAlignment="Left" Margin="6,69,0,0" Name="Button2" VerticalAlignment="Top" Width="75"></Button>
This is what I have in my App.config file (de-DE) should change the edited content to German:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Culture" value="de-DE" />
</appSettings>
</configuration>
Lastly, my xaml.cs file has the following in it:
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Globalization;
using System.Configuration;
namespace WPF_Prototype1
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
/// This line should allow the program to read the App.config file!
Properties.Resources.Culture = new CultureInfo(ConfigurationManager.AppSettings["Culture"]);
}
}
}
Why is my program still not changing these icons to German? What can I do to fix it?
Thank you
Copyright Notice:Content Author:「Eric after dark」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/17452094/xaml-c-sharp-localization-problems