Software internationalization has traditionally been an unwanted hurdle for .NET developers. That's probably because they don't have the right tools to assist with routine tasks associated with this process, such as extracting strings to resource files, or making sure that different cultures have all the resource items in place.
ReSharper greatly simplifies working with resources by providing a full stack of features for resx files and resource usages in C# and VB.NET code, as well as in ASP.NET and XAML markup.
Dedicated features include Move string to resource, Find usages of resource and other navigation actions. Combined with refactoring support, inspections and fixes, you get a convenient localization environment that enables you to save up to 95% of the time you usually spend on internationalizing manually.
Highlighting Localizable Strings
ReSharper detects strings that you can localize, highlights them, and helps you move them to a resource file.
Depending on your project settings, ReSharper can highlight all hard-coded string literals, or only those explicitly marked with Localizable(true).
Move Strings to Resource Files
When ReSharper finds a localizable string, it helps you move it to a resource file as quickly as possible. You can optionally search for identical strings and refactor them to use the new resource item.
Depending on your project settings, strings that you can move to a resource file may or may not be highlighted with a curly underline. If a string is not highlighted, press Ctrl+Shift+R and select the Move to Resource refactoring. If a string is highlighted with a curly underline, as it is in the screenshot above, you can press Alt+Enter and launch the refactoring directly from the list of quick-fixes.
In addition to strings used in C# or VB.NET code, ReSharper is able to process strings from markup files in web applications and arbitrary HTML strings.
In addition to moving strings to resource files, ReSharper provides a number of other internationalization refactorings:
- Move Resource refactoring moves existing resource entries between resource files.
- Rename Resource helps change the value of the name attribute in a resource entry.
- Inline Resource deletes a resource entry from a resource file and substitutes all its usages with the original string.
- Safe Delete Resource attemps to delete a resource entry along with all its usages without breaking the code. If Resharper finds out that some usages can not be auto-deleted safely, it suggests that you edit them manually before applying the refactoring.
For details on other refactorings provided in ReSharper, see Refactorings.
Resource File Structure
ReSharper provides a specialized version of the File Structure tool window for viewing the structure of resource files. It lists all entries in a resource file, visualizing resource IDs, resource text in the current culture, and resource comments (if any). In addition, this tool window specifies whether resource entries are overridden in other cultures, and whether they contain format placeholders.
Code Inspections for Resource Files
ReSharper provides a number of code inspections that help reveal common issues with resource entries.
Specifically, ReSharper warns you whenever a specific resource value is not overridden in a specific culture, or it is overridden with the same name that is used in the culture-neutral resource file. ReSharper make you aware of duplicate resource names in a single resource file, and it's even able to detect missing or redundant format string placeholders in resource values.
ReSharper displays highlighting in the text editor when it detects issues like these. In addition, you can glance through (and navigate to) all issues in resource files using ReSharper's Find Code Issues feature:
Finally, ReSharper provides quick-fixes that you can use to resolve these issues in resource files right away.
Find Usages of Resources
ReSharper's Find Usages feature perfectly works with resources. You can search for occurrences of a resource entry both from the code and from resource files.
Navigation between Cultures and Resources
ReSharper's Go to Derived Symbols and Go to Base features help you navigate from resource entries in a culture-neutral resource file to corresponding entries in culture-specific resource files, and vice versa.
Note on shortcuts
All keyboard shortcuts provided in the "Features" section are taken from 'Visual Studio' keyboard scheme. For details on ReSharper's two default keymaps, see Documentation and Demos.