Key settings that are required to implement centralize localization library used in multiple projects. I faced this issue and doing lot of research didn't find anything fruitful. So I decided to just write these bullet settings that are useful for developers who may get some help from my post.
Though below implementation approach can be implement in any project, my example is based on WPF MVVM.
Initially create a WPF library in which I created a separate folder of Localization resources with different language files.
Keep below two things in mind when we add new resource file:
- When you open file designer.cs you are able to see by default access modifier in the file is “INTERNAL” replace it to “PUBLIC”.
Below steps describes that how we are going to use our above created localization library in other projects:
- create a new project i.e. where you wan to consume your above created localized library.
Open App.Xaml.cs file and do the changes suggested in below image:
***For testing purposes inn constructor I have forcefully given the language CULTURE
- open your MainWindow.Xaml file and do the below changes in files: Important thing to remember when you use the below code always specify the x:UID with every control
- Another important point when you get the resources sets you have to point the assembly of “Localization project” i.e. your separate library you have created.
That's it!. Hope it gives you understanding on centralized library based localization implementation.