Soluling home   Document home


Localizer options

Use this sheet to specify Localizer related options in ASP.NET Core and Blazor.

Localization Method

Specifies how the localization is done. Possible values are:

Value Description
Scan source code to extract strings from localizers but do not create the original .resx files Scan the source code (.cs, .cshtml and .razor) to find all the places where a localizer (IStringLocalizer, IViewLocalizer or IHtmlLocalizer) is used. Then extract the strings used in localizers and keep the string in the memory during the scan process.
Scan source code to extract strings from localizers and create the original .resx files
As above, but also create the original (e.g., neutral) .resx files containing the strings.
Note! Each time you scan the project, a new set of original .resx files will be created, and the current one will be overwritten.
Do not scan but scan only the existing resource files
Do not scan the source code but scan the existing .resx file and localize them.

If you select either the first or second value, then Soluling extracts strings from your source code files, and the following extractor related items will be visible.

Resource directory

Specifies the project directory where the resource files are stored. This is the directory that you specify in the Startup.cs file when configuring localization. This is editable only if your project does not have a Startup.cs file (e.g., a Razor class library) or have a Startup.cs file, but it does not set the ResourcesPath option. In that case, you must specify the resource directory.

Check Clear directory before the scan check box if you want that Soluling removes the current content of the resource directory before each scan. If you don't have any manually created resource file in the resource directory, it is recommended to keep this checked to avoid unused resource string remaining in the directory.

Check the file types that the extractor scans

Specifies the file types that the string extractor scan when finding strings used with localizer.

Value Description Example
Localizer strings from view files Scan localizer strings in view files (.cshtml)
Localizer strings from source code files
Localizer strings in source code files (.cs)
Message = localizer["Enter values and click Calculate."];  //loc This is a comment
Localizer strings from the startup file Localizer strings in startup file (Startup.cs)
services.AddMvc(options =>
   options.ModelBindingMessageProvider.SetAttemptedValueIsInvalidAccessor((x, y) => 
     localizer["The value '{0}' is not valid for {1}.", x, y]);  //loc SetAttemptedValueIsInvalidAccessor
Attribute strings from model files Attributes strings in model files (.cs)
[Required(ErrorMessage = "The Title field is required.")]  //loc No title value entered

Comments in the above samples are not required, but it is recommended to add a comment, especially if the string's meaning is ambiguous. Learn more about adding comments to source code strings.

Enter the type names of localizer interfaces

Specifies the type names of the localizer interfaces that are injected into page models. If you use your custom localizer, add it to this list.

Enter the names of localizer variables that your source code uses

Specifies the variable names of the localizer instances that your source code or view files use.