Localization Becomes easier with the Localization Manager in ReSharper 2019.3

Maarten Balliauw

In the latest ReSharper 2019.3 Early Access Preview (EAP), we have added a new Localization Manager to assist you in localizing applications. It lets you view and edit localizable resources in a single grid, helping you add/edit/rename localizable strings and spot missing localized values.

More than enough for a blog post, so let’s dive in!

We can open the Localization Manager from the Extensions | ReSharper | Windows | Localization Manager menu, or use Go to Action (Ctrl+Shift+A and search for “Localization Manager”).

From here, we can see our solution’s resource files (.resx) and their contents – all in one grid. If we have multiple resource files, their resources will be merged into this grid as well, helping us speed up the localization process.

First look at the localization manager in ReSharper to help translate ResX files

Granted, the above screenshot doesn’t show a lot yet, so let’s make things more interesting!

Adding resources using the Localization Manager

We’ll start with adding a new localized resource and use it in our code.

Add new localized resource

Great! We now know how we can add and edit existing localized values from the toolbar.

Adding resources from the editor

How can we convert existing string literals into resources? Well, once we have a resource file in our project, ReSharper will show a suggestion for string literals in our code base, informing us they can be localized.

String can be localized

We can use the context actions (Alt+Enter) to move this string literal into a resource, or use the Move to Resource refactoring (Ctrl+R, O) to quickly convert a string literal into a resource!

Move string literal to resource

We can also use the context action Edit with Localization Manager (Alt+Enter) to open the tool window and select the current resource and its localized versions.

Edit with Localization Manager

Adding a culture using the Localization Manager

Back in the Localization Manager, let’s add a new culture, say nl-BE, which happens to be my mother tongue. We can do this from the toolbar.

Add new culture using Localization Manager

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

Filtering resources

The Localization Manager will display all of our resource files, cultures, and localized values. We can use the filters and search to scope the editor grid to what we want to work with. This ranges from the various resource files in our solution to the cultures to show, which is especially useful if there are a lot of supported cultures in your application.

Choose ResX cultures to work with

Import/Export localized values

In case other people are providing translations, resources from the Localization Manager can be imported and exported using CSV files, and copy/pasting from Google Sheets or Microsoft Excel is possible as well.

Spotting missing translations

From the Localization Manager tool window, we can easily spot missing translations and localized values: they will be displayed in a different color.

Warnings for missing localized values

Note that by clicking the warning icon in the toolbar, we can filter the grid to only show missing localized values.

As a reminder, we can also use ReSharper’s context actions (Alt+Enter) while editing a .resx file to override a resource in a different culture, as well as inspect which cultures already override the selected resource.

Context action in ResX file to override resource value in different culture

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.

Unused resources become visible using Solution-Wide Analysis

Having this information allows us to clean-up resources we may have used in the past but aren’t using anymore. If would like to double check whether a resource can be removed safely, there’s the Safe Delete refactoring which we will cover next.

Refactoring resources: Rename and Safe Delete

So far, we have seen how we can add and edit resource values. But how can we rename a resource? And how do we safely delete a resource, making sure it’s no longer being used in our application? The Localization Manager comes with two refactorings that do exactly that!

From the toolbar, we can click the Rename resource button and provide a new name. When we continue, ReSharper will rename our resource across all cultures (and .resx files), and update all usages in the code in one go.

Refactoring - Rename a resource with ReSharper

With Safe Delete, ReSharper will verify a resource can be deleted without breaking existing code. It will tell us when there are usages left, so we can take action.

Safe Delete a resource using ReSharper

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).

Refactor This on resources in ReSharper

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

 

Download ReSharper 2019.3 EAP now! We would love to hear what you think about the new Localization Manager!

Comments below can no longer be edited.

18 Responses to Localization Becomes easier with the Localization Manager in ReSharper 2019.3

  1. Chris Woodruff says:

    December 9, 2019

    Finally!! Great stuff and thank the team for me!

  2. David says:

    December 9, 2019

    Perfect, I’m looking forward. Good job guys.

  3. Ben says:

    December 9, 2019

    Awesome! Will this be available for Rider as well?

    • Alexander Kurakin says:

      December 9, 2019

      Yes, it will, in one of the future releases next year.

  4. Michael says:

    December 12, 2019

    This is absolutely beautiful! Seriously!

    Per chance, is there the possibility of JSON support for localizing web assets on the product roadmap?

    • Andrew Vasilyev says:

      December 12, 2019

      Yes, we plan to fully support asp.net localization scenarios including JSON 🙂

  5. Dmitri Peredera says:

    December 12, 2019

    Hello,
    I am working with WinForms and it thinks that I should translate images as well.
    Those are also project resources, but should probably be excluded.

    • Andrew Vasilyev says:

      December 12, 2019

      Hello,

      Yep, we already implemented additional filter, and we will release it in 2019.3.1 with some other fixes.

  6. David says:

    December 12, 2019

    Yes, I agree with Dmitri. Please add some filter so we would able to include only text.

  7. Maxence DELANNOY says:

    December 12, 2019

    Nice addition. If the Move to Resource could allow input for all the cultures, it would be useful. It would allow to enter the translations as there are created.

  8. Taylor Buchanan says:

    December 17, 2019

    Can it sort the RESX file alphabetically by key? Our team currently uses the ResX Manager VS extension for this but I would love to jump ship.

    • Andrew Vasilyev says:

      December 18, 2019

      Do you mean file group key or resource name?
      Now it sorting resources by name, but we plan to add “Sort by Group” mode in one of future bugfix releases.

  9. Eric Bonin says:

    December 19, 2019

    Great addition to the ReSharper toolset! I love it so far, but I’ve noticed a small downside to it. For big resource files, the manager becomes really slow (while it tries to read resources, Visual Studio freezes completely).
    Is there any plan to “page” the resources shown in the manager? It would be very useful to show something like 200 entries at a time and change pages when needed while still being able to make a global search.

    • Andrew Vasilyev says:

      December 19, 2019

      Hi, Eric!

      It already uses paging and data virtualization, but has bug which can cause such freezes.
      We already fixed it and will ship it in one of next bugfix releases of 2019.3.

      If you want to test fixed version with your resource files feel free to contact me (andrew.vasilyev[at]jetbrains[dot]com) and i will send you private build.

  10. Ian Powell says:

    December 31, 2019

    A really useful feature – Thanks

    For any missing cultures could you get it to fetch the translation from Google or others? That would be the icing on the cake so to speak 🙂

  11. Joseph Atherton says:

    May 1, 2020

    Hi. Is there a way to add a comment for each entry for the translation Team to give some context to the string?

Subscribe

Subscribe to .NET Tools updates