Looking at a localization solution for MVVM
In this section, we’ll look at a solution that’s not just functional but also fits well with the MVVM architectural pattern. Whether you need to localize text within your ViewModels or dynamically update language in your UI, this approach has you covered. It’s a solution that I’ve personally implemented in numerous projects over the years. While I’ve made some refinements along the way, the core concept has stood the test of time and proven its effectiveness in real-world applications.
Warning – culture settings are thread-specific
When allowing the user to switch cultures inside the app, we should be wary of the fact that when updating CultureInfo
inside async
operations, those changes will not automatically propagate to the parent thread. A localization strategy needs to be designed with this in mind to avoid inconsistencies.
In the code accompanying this chapter, two new projects have...