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
- Creating I18n properties with scopes
- Creating keys for lazy lookups
- View locale values instead of keys
- Extracting text from HTML
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
Subscribe to Blog updates
Thanks, we've got you!
The RubyMine 2023.3 Early Access Program Is Open!
Hello everyone, The third RubyMine Early Access Program of 2023 is underway! The key change in the first EAP build is an important indexing optimization. By refactoring our code base, we’ve doubled RubyMine’s indexing speed compared to v2023.1. This is particularly noticeable when working wi…
Collaborative Programming in RubyMine
Hi everyone, We're back with a new how2pro blog post unveiling another cool RubyMine feature – the Code With Me plugin. When you're knee-deep in a complex task or tangling with an issue that's testing your limits, having someone by your side can make all the difference. Additionally, in an educati…
Performance Improvements in RubyMine 2023.1
Hello everybody, The new release is fast approaching, so it’s time to unveil the performance enhancements you can expect from RubyMine 2023.1. Faster code completion When developing and supporting RubyMine, we analyze a great load of anonymized usage data. A lot of recent data pointed to the fact t…
RubyMine 2023.1 EAP5 Is Out!
Hello everyone, RubyMine 2023.1 EAP5 is now available! Below you can find the most notable features in this build. We encourage you to try them out and share your feedback in the comments or in our issue tracker. Migration of Ruby code to the Symbol API In order to improve code insight actions such…