.NET Tools Early Access Program How-To's Rider

Say Hello To Localization Manager In Rider 2020.2

Hello friends, or should we say こんにちは (Kon’nichiwa)? We have some excellent news for our multilingual Rider developers. Localization Manager, which previously appeared in ReSharper, is now available to all Rider users. We can build multi-cultural .NET applications, with the localizable resources using the new feature.

To get started with the Localization Manager, we first need to add a resource file. In this post, we’ll be using a  Greetings.resx file along with a  Greetings.ja-jp.resx to hold our Japanese translations.

To open the resource editor, we can use Go to Action (Ctrl+Shift+A) and search for "Localization Manager." Once open, we can see the layout. On the left-hand pane, we can see our project along with all of our resource files and their target culture. On the right-hand side, is our editor pane. In the editor pane, we can add new resources, edit existing ones, and see cultural values side by side.

Localization Manager View

Adding Resources using Localization Manager

We’ll start by adding a new localized resource to use in our code.

Add Resource Value

Great! We’ve added our first localized value using the localization manager editor.

Adding Resources from the Text Editor

Like other features in Rider, many of the same GUI actions can be performed via quick-fixes and suggestions directly from our code. When adding a string literal to our code, Rider will suggest localizing the value by adding it to our resource file.

We can use the context action to move the string literal into a resource for quick and efficient operation.

Refactor String Literal

Quick actions also allow us to open the editor window from any existing resource found in our code. With the cursor over our resource string, we can invoke the action Edit with Localization Manager to open the tool window and highlight the current value.

Edit In Resource Manager

Adding a Culture using the Localization Manager

Translations are like potato chips (or crisps if you’re British) – you can’t just have one. We can add more cultures from the editor window using the "+" icon located in the left-hand pane’s toolbar. Thankfully, Maarten is a native Belgian and agreed to help me translate my app.

Adding A New Culture

Note how we got code completion for various culture codes, and how a new resource file Labels.de-BE.resx was created.

Filtering Resources

The localization manager will help us manage our resource files, cultures, and localized values. Using the editor, We can use the filters and search to scope the editor grid to the cultures we are working with. This is especially useful as we begin to handle more cultures.

Filter and Hide Cultures

Import/Export Localized Values

Commonly, we need to lean on professional translators to get the nuances and idioms of a language correct. Translators work with tools like Google Sheets and Microsoft Excel to edit spreadsheets and are unlikely to be using a tool like Rider. Luckily for us, Rider supports importing and exporting localized values into a CSV format.

Import/Export Values

Spotting Missing Translations

From within the Localization Manager tool window, we can easily spot missing translations for localized values as the cell is highlighted with a different color.

Spot missing values

We can also use the editor toolbar to filter to missing values, show comments, and navigate to resource files.

When editing a .resx file, we can see the resource topology and whether the value is overriding a parent resource value.

Overriding in RESX file

Spotting Unused Resources

When Solution-Wide Analysis (SWA) is enabled, the Localization Manager will scan our entire solution for usages of resources. Resources that are in use are rendered in bold, while unused resources are not.

Spotting unused resources

Knowing what resources are being utilized helps us clean up resources we may no longer require. Knowing whether a resource is used is also useful for our next feature.

Refactoring Resources: Rename and Safe Delete

Adding resources can be simple, especially when using the Localization Manager. Removing and refactoring can cause breakage and hours of lost productivity… If you aren’t using Rider, that is.

The localization features in Rider allow us to Safe Delete resources. Rider will verify a resource can be deleted without breaking our existing code using the same analysis tools we all know and love.

Safe Delete Warning

We can also refactor resources from the editor, either from inside a resource file or from our code, by either using the Rename/Delete refactorings directly or using Refactor This… (Ctrl+Shift+R).

Rename Resource Action

Note that we can also move and inline resources from here.

Conclusion

Software is about changing people’s lives, and with the Localization Manager, we can reach more folks. As always, thank you for reading. ありがとうございました (Arigatōgozaimashita).

Download Rider 2020.2 now! We hope you give it a try, and we would love to hear what you think about the new Localization manager!

image description

Discover more