Feature: Globalization & Localization - Pixely-Studios/NStart GitHub Wiki

Helpful links

How do we Localize?

NStart is localized using ASP.NET's localization provider. In order to keep it simple we have used a setup abstraction class. This class holds two important values: supported cultures and default culture.

This class configures the default & supported cultures using the previous important values and registers a provider that will localize the application according to the Accept-Language header in the user's browser. This means that the user doesn't has to accept any cookies at all and changing the language that the application shows is as simple as editing the settings of the browser.

How do I add a new supported culture?

You will first add it to the abstraction class under the supported cultures. You can see how we added how we structured the example cultures and add yours. If you only want to target a language, you will put the ISO code of the language (es for Spanish for example), but if you want to specially target a culture and a language, you will introduce the language code, followed by a hyphen and the culture ISO code (es-ES for Spanish (Spain)). We recommend that you first target the language and then the culture.

In the resource folder is where all the strings of the application go to sleep and where you must put your targeted language's resources. In this folder you must comply to this pattern:

Pages\{PageFolder}\{PageName}.{CultureInformation.}resx

  • PageFolder: Name of the folder that contains the page. For our Awards page the folder's name is Company.
  • PageName: Name of the page to contain the strings.
  • CultureInformation: Language and Globalization code. You can ignore this if you don't want to localize the page or just are testing a new page.

To implement the localization in a view, you must perform the following operations

  • Inject a IViewLocalizer to the Razor Page
  • Use the injected IViewLocalizer to search the resource using squared brackets (IE: Localizer["TestString"])