views:

343

answers:

3

Please share you experiences regarding how you localized your WPF applications to support multiple languages and any resources that helped you in it?

Thanks for your feedbacks.

A: 

Sorry if it is vague (above question),basically it about how you implemented it in your application and what you felt was the best way.It is basically to understand scenarios.

+3  A: 

For our WPF application, all of our strings are localized as resources in a ResourceDictionary that we put in a .xaml file named after the language (like en-US.xaml, ja-JP.xaml, etc).

For example, somewhere in the application a button might look like this:

<Button Content="{StaticResource Strings.FooDialog.BarButtonText}"/>

Each ResourceDictionary for the different languages would contain a version of it:

<sys:String x:Key="Strings.FooDialog.BarButtonText">Bar!</sys:String>

The ResourceDictionary is dynamically connected to the Application.Resources at runtime like this:

private static void LoadLocalizedStrings(CultureInfo uiCulture)
{
   ResourceDictionary stringsResourceDictionary = new ResourceDictionary();
   stringsResourceDictionary.Source = new Uri(@"pack://application:,,,/Resources/Strings/" + uiCulture.Name + ".xaml");
   Application.Current.Resources.MergedDictionaries.Add(stringsResourceDictionary);
}
Robert Macnee
A: 

You might be interested in this article about WPF localization with the "old" stable ResX files:

Best Practices: Localize a WPF application

jbe