#1,080 – Command Text for Preexisting Commands Is Automatically Localized
May 26, 2014 1 Comment
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.
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.