views:

11

answers:

2

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.
+1  A: 

There is no easy way to perform this but I recommend to have a look at this: http://www.codeproject.com/KB/WPF/WPFLocalize.aspx

Wouter Janssens - Xelos bvba
Sigh, so it was not a lame question after all :-) Thank you very much for the link, without it I would be lost.
macias
+1  A: 

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

ajay_whiz