I18n Features in RubyMine

Artem Sarkisov

This post will cover a number of handy options that RubyMine provides to help you internationalize your application, including the newest ones added in the recently announced RubyMine 2018.3.

Creating I18n translations

First of all, you can create an I18n property from a string for all existing dictionaries. To do this, simply put the caret on the desired string, press Alt+Enter to invoke Intention Actions, and Choose I18n string value. This will open a dialog where you can create a property key and provide translations for every locale:

RubyMine will create a key-value pair in related translation files. Now you can easily navigate between your I18n keys and their source files (⌘+Click | Ctrl+Click):

Likewise, you can find key usages (Alt+F7) and quickly rename them (Shift+F6):

Now let’s check out the new I18n features and improvements made in v2018.3:

Creating I18n properties with scopes

RubyMine correctly recognizes namespaced keys and allows you to create them together with their values for the existing dictionaries:

This will also work with other scope styles.

Creating keys for lazy lookups

When you add lazy lookups on the go, you can quickly create a translation for every existing dictionary in the same manner:

View locale values instead of keys

Another hidden goodie is how RubyMine can show you actual values instead of I18n keys. To take advantage of this, put the caret on the I18n key and simply fold it (⌘. | Ctrl+.):

To show the key again, press the same shortcut. This works for regular keys, scoped keys and lazy lookups in views, controllers and mailers.

You can also change the preview locale to any other existing language, by invoking the (same) intention actions (Alt + Enter):

By the way, as an alternative to this feature, you can press F1 (Quick Documentation) while on an I18n key to see all available translations:

Extracting text from HTML

Finally, you can use RubyMine to quickly extract text from HTML and move it to a locale. Use the exact same intention action (Alt+Enter):

Get the latest RubyMine 2018.3 build to try the renewed I18n support.

While we are adding more I18n improvements, let us know what you think about the existing capabilities, and please report any issues you encounter. Thanks!


Your RubyMine Team

Comments below can no longer be edited.

5 Responses to I18n Features in RubyMine

  1. Intention Actions in RubyMine | RubyMine Blog says:

    September 27, 2018

    […] that can help you to quickly fix code smells, convert statements for better code style, add strings to locale dictionaries, use language injections, and do other handy things simply by pressing Alt+Enter. Let’s […]

  2. RubyMine 2018.3 Goes Beta | RubyMine Blog says:

    November 2, 2018

    […] The IDE now correctly detects lazy lookups and scopes. Learn more about I18n improvements in a detailed post. […]

  3. Muhammet says:

    July 22, 2019

    How to set custom localization path?

    • Artem Sarkisov says:

      July 22, 2019

      Hi Muhammet,

      Go to `Preferences/Settings | Project Structure | I18n folders`.


      • Muhammet says:

        July 22, 2019

        Thanks! 🙂


Subscribe for updates