WPF extension for resources localization.
Added simple example of mouse over event using localized image.
The sample application shows how to use most of the features.
To localize a string resource in a WPF application:
-
Create a default resource file (ex.
resources.resx) in your solution. -
Add a string resource to it (ex. MyString = "Hello World!")
-
Add another resource file for a specific culture (ex. fr) using the same name with the culture as a suffix (ex.
resources.fr.resx) -
Add the localized string to this second resource file (ex. MyString = "Bonjour le monde!")
-
In a XAML file, add the
Localize.DefaultResourceattribute to the root element (usually on a Window or UserControl) and set it to the name (including namespace) of your default resource file without the extension. For example, an application having the namespace "MyApplication" would look like:<Window ... Localize.DefaultResource="MyApplication.resources" > -
Now declare a
TextBlockcontrol in your XAML and set itsTextproperty using theLocalizeextension:<TextBlock Text="{Localize MyString}"/>This is equivalent to:
<TextBlock Text="{Localize MyString, Resource=MyApplication.resources}"/>Since a default resource was previously set on the root element, there is no need to specify a Resource attribute explicitly on a child element (unless the resources file differs).
-
To switch culture at runtime, set the
CultureManager.CurrentCultureproperty to one of your defined resource culture, for example:CultureManager.CurrentCulture = new CultureInfo("fr");
The MIT License (MIT)

