#1,080 – Command Text for Preexisting Commands Is Automatically Localized

If you use any of the preexisting RoutedUICommand objects in your application, the Text property of the command is automatically localized to match the language of the operating system that you’re running on.

Assume that you wire a Button up to an Open command:

        <Button Content="{Binding RelativeSource={RelativeSource Self}, Path=Command.Text}"
                Command="ApplicationCommands.Open" />

If we run the application, the button text is in English.

1080-001

If we run the application on a French version of Windows, the text on the button will be localized.  Assuming that we have the proper language pack installed, we can also just override the CurrentUICulture of the current thread.

    public partial class App : Application
    {
        public App()
        {
           Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
        }
    }

Now when we run the application, the word “Open” is translated to French.
1080-002

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #1,080 – Command Text for Preexisting Commands Is Automatically Localized

  1. Pingback: Dew Drop – May 27, 2014 (#1784) | Morning Dew

Leave a comment