...

/

Views Localization

Views Localization

In this lesson, we will learn how to localize view content with translation services and resource files.

When a view contains a few strings to localize, or when the HTML structure is too complex to be duplicated in several culture-dependent views, we can use resource files that furnish the translations of the view strings.

Enabling resource files based localization

Resource-file-based localization associates each view culture-specific resource to files containing the translations in all supported cultures. The names of these resource files are composed of the name of the view, a culture name suffix, and the .resx extension that characterizes all resource files.

Thus, the resource files associated with the _Layout.cshtml view might be:

Press + to interact
_Layout.es.resx
_Layout.fr.resx
_Layout.it.resx

Usually, there is no resource file associated with the default culture, since the text of the default culture is placed directly in the view. When the translation service doesn’t find a resource for the current request UICulture it returns the ...