Globalization and localization - Provide resources

In this article

SupportedCultures and SupportedUICultures

Resource files

Nested contextual menu: In Solution Explorer, a contextual menu is open for Resources. A second contextual menu is open for Add showing the New Item command highlighted.!

Add New Item dialog!

Visual Studio shows the Welcome.es.resx file.

Welcome.es.resx file (the Welcome resource file for Spanish) with the word Hello in the Name column and the word Hola (Hello in Spanish) in the Value column!

Solution Explorer showing the Welcome Spanish (es) resource file!

Resource file naming

Resource name Dot or path naming
Resources/Controllers.HomeController.fr.resx Dot
Resources/Controllers/HomeController.fr.resx Path

RootNamespaceAttribute

Warning This can occur when a project's name is not a valid .NET identifier. For instance my-project-name.csproj will use the root namespace my_project_name and the assembly name my-project-name leading to this error.

using System.Reflection;
using Microsoft.Extensions.Localization;

[assembly: ResourceLocation("Resource Folder Name")]
[assembly: RootNamespace("App Root Namespace")]

Culture fallback behavior

Generate resource files with Visual Studio

Add other cultures

Next steps

Additional resources

Ref: Provide localized resources for languages and cultures in an ASP.NET Core app