Class Library Localization in Windows Universal / Store App


I have a solution with a Windows Store app project and a Class Library project and I want to add Localization support.
How can I add the all the Resource files to my Class Library and use them in both my App and Class Library?

In order to avoid writing a lot of boilerplate and error prone code when you add a new resource string like:

  1. Add it to .resw file
  2. Add it to your Static class that provides access to the resource
  3. Add it to each language specific .resw file (ex: en, fr, pt, etc)

You can use the following approach:

  1. Create "Strings" folder and add there just one folder for default language (for example "en-US") in your Class Library
  2. Add Resources.resw file to "en-US" folder with required keys/values
  3. Install Multilingual App Toolkit
  4. Enable MAT in VS for your Class Library (VS->Tools->Enable Multilingual App Toolkit)
  5. Add required languages to your Class Library (VS->Project->Add Translation languages...)
  6. Install ResW File Code Generator VS extension
  7. Go to Resources.resw file properties and set Custom Tool to "ReswFileCodeGenerator" (you can also specify namespace in Custom Tool Namespace)
  8. To solve issue with supported languages detection(currently generated manifest contains supported languages according to folder structure "Strings/en-US") you need to add folders for all required languages in your App library ("fr-FR", "bg-BG", etc) and put Resources.resw file with only one fake key.
  9. Build your solution and enjoy!

With this approach all your resources are available via static class generated by ReswFileCodeGenerator and all of them work with x:uid in XAML. You don't need to care about keys synchronization between different languages. Also MAT can translate your resources for you.