If you’re developing applications that target multiple languages and cultures, you probably know how challenging it can be to manage the resources for each localization. You need to keep track of all the strings, images, icons, and other assets that are specific to each culture, and make sure they are consistent and up to date across your project.
Fortunately, Visual Studio has a solution for you: the revamped Resource Explorer. This new feature lets you view, edit, and manage all your resources in one place, with a sleek and intuitive interface that is designed for the modern .NET developer.
In this blog post, we’ll show you how to use the Resource Explorer UI to improve your productivity and quality when working with resources in .NET apps. We’ll cover how to:
- Load multiple files and view all localizations at once
- Search and filter resources by name, value, or comment
- Add comments to each translation of a resource
- Validate placeholders and detect missing translations
- Customize the accessibility and settings
Ready to explore? Let’s get started!
Load multiple files and view all localizations at once
One of the main advantages of the new Resource Explorer is that it allows you to load multiple files and view all the localizations for each resource in the same view. This makes it easy to compare and edit resources across different cultures, without having to switch between tabs or windows.
To use the new Resource Explorer, you need to have a .NET project that contains one or more resource files (.resx). To open a resource file with the Resource Explorer, right-click on any resource file in the Solution Explorer and select Open With > Resource Explorer. Resource files in the Solution Explorer can also be opened with a double click. Alternatively, you can navigate to the Resource Explorer and view any number of resource files included in the solution by navigating the Visual Studio toolbar via View > Other Windows > Resource Explorer.
Once you open the Resource Explorer, you’ll see a data grid that shows all the resources in the selected file(s), along with their values for the default culture and other cultures. The localizations in the default culture, usually the language used by the developer in Visual Studio, are displayed as neutral values. To add more resources, click on the Create Resource button on the toolbar and configure the resource you want to include.
You can use the checkbox selections on the left side of the screen to configure which of the solution’s resource files will be visible in the data grid.
For resources localized in multiple languages, you can change which translation columns are visible in the grid by configuring the columns in the Columns button in the Resource Explorer toolbar.
You can now see all the resources and their translations in a single view, with each column representing a different file or culture. You can resize, reorder, or hide columns as you wish, and use the horizontal scroll bar to navigate through the grid.
Search resources by name, value, or comment
If you have a large solution with many resources, you might want to search for a specific resource or filter out the ones you don’t need. The new Resource Explorer makes this easy with the search and filter functionality.
To search for a resource, type in the search box on the toolbar and press Enter. The data grid will show only the resources that match your query in their name, value, or comment.
Note that the search functionality will only search the files and resource groups that have been selected to be visible in the data grid. To include more files in your search, you must select the checkboxes for the corresponding resource groups in the left pane of the UI before searching. This selection can be used to filter for specific files or resource groups, helpful for when you want to only view resources in a particular resource group, or you don’t want certain resources to be visible in the grid.
Add comments to each translation of a resource
Comments are a useful way to provide more information or context for a resource, such as the meaning, usage, or tone of a string. In the Resource Explorer UI, you can add comments to each translation of a resource and view them all at once in the data grid.
To add a comment to a resource, right click on the cell that corresponds to the translation you want to comment on and click on the “Edit Comment” button on the dropdown. A comment box will appear beside the cell, where you can type in your comment. Press Enter to save the comment or navigate away from the comment box without hitting enter to discard it.
You can also edit or delete existing comments by right clicking on the comment box. To view all the comments for a resource, look for the small comment icon in the corner of each cell that has a comment. You can hover over the icon to see a tooltip with the comment text or click on it to open the comment box.
Validate placeholders and detect missing translations
Another benefit of the Resource Explorer UI is that it helps you ensure the quality and consistency of your resources, by validating placeholders and detecting missing translations.
Placeholders are special tokens that are replaced by dynamic values at runtime, such as {0}, {1}, or {name}. If you use placeholders in your resources, you need to make sure they are consistent across all localizations, otherwise you might see errors or unexpected behavior in your app.
The new Resource Explorer automatically validates placeholders for each resource and shows a warning icon if there is a mismatch between the default culture and any other localization. For example, if the default value of a resource is “Hello {0}, how are you {1}?” and the Spanish value is “Hola {0}!”, you’ll see a warning icon because the {1} placeholder is missing in the Spanish value. You can hover over the icon to see a tooltip with the details of the mismatch.
Missing translations are another common issue that can affect the user experience of your app. If you don’t provide a translation for a resource in a certain culture, the app will fall back to the default culture, which might not be proper or desirable for some users.
The Resource Explorer UI helps you avoid this problem by showing a warning icon if there is no value for a resource in a certain culture. For example, if you have a resource with a default value of Main text viewer and no value for the Czech culture, you’ll see a warning icon showing that the translation is missing. You can hover over the icon to see a tooltip with the message “Missing resource in cultures: [all cultures for which you are missing a translation]”. In future versions of the Resource Explorer, these warnings will be configurable.
Customize the accessibility and settings
The last feature we want to highlight is the accessibility of the UI and the ability to customize the UI settings of the Resource Explorer to suit your preferences and needs.
We have improved the compatibility of the Resource Explorer UI with screen readers and assistive technology, to make it more accessible for developers with visual impairments or disabilities. You can use keyboard shortcuts to navigate through the data grid, edit values and comments, and perform common actions. You can also use the narrator to read each cell’s contents, as well as the tooltips and warnings.
We also have several supported keyboard shortcuts for the new Resource Explorer as follows:
Shortcut | Action | Supported |
Control + A | Selects all cells | ✅ |
Shift + right arrow | Extends selection one cell to the right | ✅ |
Shift + left arrow | Extends selection one cell to the left | ✅ |
Shift + down arrow | Extends selection one cell down | ✅ |
Shift + up arrow | Extends selection one cell up | ✅ |
F2 | Places focus on text inside a cell (enter edit mode) | ✅ |
A subsequent press of F2 restores focus to the cell and restores grid navigation functions (exit edit mode) | ✅ | |
Control + Shift + R | Add a resource | ✅ |
Control + Del | Delete a resource* | ✅ |
Control + D | Duplicate a resource* | ✅ |
Control + Shift + M | Move resource to a different file* | ✅ |
Control + X | Cut* | ✅ |
Control + C | Copy* | ✅ |
Control + P | Paste* | ✅ |
Shift + F2 | Add or edit a comment | ✅ |
Shift + Alt + F2 | Delete a comment | ✅ |
Control + Shift + V | Replace file
This applies for non-string resources, like an image |
✅ |
Control + Shift + L | Open visible Columns menu | ✅ |
Control + Shift + C | Toggle neutral comment column | ✅ |
Enter | Moves focus to the next cell below | ✅ |
Tab | Moves focus to the next cell to the right or the first one in the next row | ✅ |
Shift + Tab | Moves focus to the next cell to the left or the last one in the row above | ✅ |
Shift + Space | Select the row that contains focus | ✅ |
Control + I | Go to search bar | ✅ |
Control + Alt + left arrow | Move focus from grid to tree view | 🔨 |
Control + Alt + right arrow | Move focus from tree view to grid | 🔨 |
*Indicates that the operation is currently only supported when you have an entire row selected
We have also added zoom functionality to the data grid to allow you to adjust the size of the text and icons according to your liking. Use Ctrl + your mouse wheel to zoom the grid and make the text size bigger.
Finally, we have enabled theming for the Resource Explorer UI to make it consistent with the rest of the Visual Studio environment. The Resource Explorer will now pick up your theme and font styling from the rest of the IDE. You can choose between light, dark, or blue Visual Studio themes via Tools > Theme and the Resource Explorer UI will adapt accordingly, just like you expect for the rest of Visual Studio. You can also change the font and colors of the data grid, by using the Tools > Options > Environment > Fonts and Colors dialog.
Conclusion
We hope this blog post has given you a good overview of the new features and improvements of the Resource Explorer UI in Visual Studio. We think this feature will make your life easier and more productive when working with resources in .NET apps, and we’d love to hear your feedback and suggestions.
We want to thank you for your continuous feedback and support, which helps us make Visual Studio better and better. Please keep it coming by using the Report a Problem tool in Visual Studio, or by sharing your ideas on the Developer Community website.
Happy coding!