greenoldman
greenoldman

Reputation: 21072

How to update windows on localization switch?

When I switch the language (localization) it only affects newly created windows. How to update localized texts for currently opened windows? I mean, smart way, so let's say if I have textbox and button, and I already entered some data the localization switch should not affect it:

[ 5 ___ ] cancel

--> switch to polish (for example)

[ 5 ___ ] anuluj

SOLVED

Thanks to article pointed out by Wouter Janssens - Xelos (thank you again) I was able to solve this. In case somebody reads several years later :-) those are the essential steps (read the mentioned article first):

  1. Add to your App.xaml ObjectDataProvider tag
  2. In App.xaml.cs add minimal provider wrapper -- getter of ObjectDataProvider from xaml and resource getter method
  3. In xamls refer to all your localized texts not via

    "{x:Static loc:Resources.MyStringKey}" 
    

    (where loc is Properties namespace of your project) but

    "{Binding Path=MyStringKey, Source={StaticResource CultureProvider}}" 
    

    (where CultureProvider is the name of the ObjectDataProvider object created in step 1)

  4. On localization switch refresh the provider.

Upvotes: 0

Views: 973

Answers (1)

ajay_whiz
ajay_whiz

Reputation: 17931

How about having a dependency property bind to button text. so when the property value changes the binding also updates

Upvotes: 1

Related Questions