Code Inspection: Element is localizable
This inspection detects hard-coded string literals and suggests moving them to resource files. If the same string is already defined in resources, ReSharper will suggest replacing the literal with the existing resource entry.
As not every string needs to be moved to resources and localized, ReSharper provides several ways to configure this inspection. When the 'Element is localizable' inspection is enabled, it works according to the flow chart below. Each step in the algorithm is explained under the chart.
Verbatim strings are prefixed with
@, for example
By default, verbatim strings are ignored by the localization inspection, but you can change it using the Don't analyze verbatim strings option on the page of ReSharper options (Alt+R, O) .
The Localizable project property defines how to treat strings in the project. To change this property, right-click the project in the Solution Explorer, select Edit project item properties from the context menu, and then choose Localizable > [Default | Yes | No].
If the project contains at least one resource file (.resx) ReSharper will consider the project as localizable by default.
Further configuration is possible for specific functions and properties that can consume sting values by marking them with
LocalizableAttribute, which lets you explicitly enable
[Localizable(false)]the localization inspection on the consumed strings.
Note that symbols could be marked with this attribute via External Annotations. For example, external annotations are used to mark
The Localizable Inspector project property defines how to treat sting literals that are not consumed by any member marked with
LocalizableAttribute—Optimistic algorithm will ignore such strings, Pessimistic will flag them as localizable.
To change this project property, right-click the project in the Solution Explorer, select Edit project item properties from the context menu, and then choose Localizable Inspector > [Optimistic | Pessimistic].
The easiest way to disable localization inspection for the current project is to press Alt+Enter over a highlighted string in the editor and use the corresponding command in the action list: This command sets the Localizable property in the current project to No.