RubyMine 7.0.0 Web Help

RubyMine suggests RailsI18nInspection inspection that detects hard coded string literals in the source code, and intention action that enables you to extract them into properties files, and replace with property keys.

RubyMine recognizes string literals in the files of the various types, in particular:

  • In Ruby and Rails scripts.
  • In views.
  • In HAML files, where string literals can appear without quotes.
  • Inside tags (for example, <p>some text</p>) of HTML files.
  • In Cucumber step definitions.
To extract a hard-coded string
  1. Make sure that locale file to be used as the target, is created.
  2. Open the desired file in the editor, click the string to be extracted, press Alt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+EnterAlt+Enter, Shift+Alt+J or Ctrl+Shift+MAlt+EnterAlt EnterAlt EnterCommand 1Alt Enter, and in the list of available intention actions choose I18n string value:

    ruby_i18nExtractHardCodedString1.png

  3. In the Create Property dialog box, select the target locale file, and specify the new property key and value.

    ruby_extractHardCodedStringToProperty.png

    A key-value pair is created in the specified target locale, and the hard-coded string in question is replaced with reference:

    ruby_i18nExtractHardCodedString.png

See Also

Concepts:

Procedures:

Reference:

Web Resources: