0

I using multilanguage solution from this thread Multilanguage in WPF But i have problem with automaticaly Resource refreshing after language was changed. Old strings stay in old language, new is traversed propertly.

What is easiest solution to solve this problem, for example refresh all resources in application?

Community
  • 1
  • 1
Svisstack
  • 16,203
  • 6
  • 66
  • 100

2 Answers2

2

I've worked with localization as well. The problem with it is the changes you make in culture info while your app is running, isn't going to be shown in the UI. The values for the controls do change, but the change isn't notified to the ui of the control. For as far as i've been googling this, i haven't found a reasonable solution for offline applications. Even InitializeComponents isn't doing the trick.

The only solution, allthough i don't like that one very much, is to change the culture, then start up a batch which will close and restart the app with the chosen cultureinfo.

The reason why i don't like this is because you rely on an external file (the batch) and not all applications can just be restarted like that. But it might do the trick.

Terry
  • 5,132
  • 4
  • 33
  • 66
0

The easiest solution I've found is to simply reopen the window - if you work with MVVM all the state (or the important state anyway) is preserved in the ViewModel(s) and only the view is refreshed.

I haven't used the extension you linked to, but any of these more advanced systems should handle refresh automatically. In my case, I just used {x:Static res:ResourceName} references to the resources, and refreshed the view when the language changed. Granted, I don't allow changing the language in the more complicated screens... :)

Svisstack
  • 16,203
  • 6
  • 66
  • 100
Alex Paven
  • 5,539
  • 2
  • 21
  • 35
  • 1. i can't reopen windows; 2. i have same problem in tray menu; your solution going to reopen application. – Svisstack Mar 10 '11 at 20:32
  • My solution is suitable in my case, of course; the extension you linked to says in its codeplex page "switching of the language to runtime affects NO timeslice", but I don't speak that language, can't really tell if it's supposed to support changing the language dynamically. I did use a similar product before switching to static resource references, and changing language did work, but it was poorly implemented and I gave it up. You should take it with the authors of that product, since they should be in a position to suggest a solution - actually that should have been my answer all along. – Alex Paven Mar 10 '11 at 20:42