ubik
ubik

Reputation:

How do you implement Localization in Windows Presentation Foundation (WPF)?

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.

Upvotes: 2

Views: 890

Answers (3)

cjbarth
cjbarth

Reputation: 4489

I just localized my WPF application successfully using ResourceDictionary. The method I used allows for dynamic changing of languages, easy translation, design-time support, and even allows for partial translations. I based my work on http://www.geektieguy.com/2006/12/12/localizing-an-xbap-application-without-using-locbaml/

You can see my efforts in part at: ResourceDictionary Source Binding to Module (for Localization)

Upvotes: 0

Robert Macnee
Robert Macnee

Reputation: 11850

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);
}

Upvotes: 3

ubik
ubik

Reputation:

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.

Upvotes: 0

Related Questions