开发者

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 possibl开发者_开发问答e to get external .resx in WPF apps. And change language during runtime? Or am I looking at this issue at bad angle?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜