Igoris
Igoris

Reputation: 1650

External .resx files during runtime

What options do i have, if i want to localize WPF applications. I would like to have option to fill .resx files for languages, and that works. But I need to get language during runtime from files.

So my question is: Is it possible to get external .resx in WPF apps. And change language during runtime? Or am I looking at this issue at bad angle?

Upvotes: 1

Views: 1977

Answers (2)

si618
si618

Reputation: 16858

Why not just compile your resx files along with your default resources?

Set Thread.CurrentThread.CurrentUICulture to your desired culture, then call ResourceManager.GetString() to set your localized properties.

If you wanted to get another culture, use the overload. Something like:

    public static string GetStringForCurrentUICulture(string name)
    {
        var value = _resourceManager.GetString(name, CultureInfo.CurrentUICulture);
        return value;
    }

To add a resource dynamically, use the appropriate ResourceManager constructor, which allows you to specify the resource and the assembly it is contained within.

Upvotes: 1

Shebin
Shebin

Reputation: 3468

You can Localize the wpf application using the LocBaml Tool This helps to create the resx files and make mapping to xaml

Upvotes: 1

Related Questions