开发者

Localize WP7 application

I was looking into ways to localize an application. I saw this example: http://msdn.microsoft.com/en-us/library/ff637520(v=vs.92).aspx but I was wondering if it would be possible to use a different language than the one the user sets on his phone. Let's say that the user sets his language to English, but I want my app to display an inte开发者_JAVA百科rface in spanish if the user chooses so using some listbox. Do you have any articles regarding this?

Thanks!


It is possible and I do it with my Google Reader client gReadie using the following code, which I call on application start and resume.

public static void SetLanguage() {
    CultureInfo c = null;
    switch (ViewModel.UserSettings.Language) {
    case Language.Default:
        break;
    case Language.English:
        c = new CultureInfo("en-US");
        break;
    case Language.Chinese:
        c = new CultureInfo("zh-CN");
        break;
    case Language.French:
        c = new CultureInfo("fr-FR");
        break;
    case Language.German:
        c = new CultureInfo("de-DE");
        break;
    }

    if (c != null) {
        Thread.CurrentThread.CurrentUICulture = c;
        ApplicationStrings.Culture = c;
    }
}

So basically I have a dropdown in my settings which is bound to a languge enum and allows the user to choose their phone language (default) or one of the supported lanaguages. Then on app start I set the language of the UI thread and of my ApplicationStrings resource file to match their selection.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜