Early Access Program Features Learn RubyMine Tutorials

I18n Features in RubyMine

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!

Cheers,

Your RubyMine Team

image description