IntelliJ IDEA 2018.1 Help

Resource Bundle

A resource bundle is a set of properties files with the same base name and a language-specific suffix. For example, if you create file_en.properties and file_de.properties, IntelliJ IDEA will recognize and combine them into a resource bundle.

IntelliJ IDEA marks resource bundles with the icon The resource bundle icon.

To create a new resource bundle:

  1. In the Project tool window, select the directory where the new resource bundle should be created.
  2. Do one of the following:
    • Press Alt+Insert and click Resource Bundle.
    • On the context menu of the selection, choose New | Resource Bundle
    • On the main menu, choose File | New | Resource Bundle
  3. In the dialog box that opens, do the following:
    • Specify the base name of the resource bundle.
    • If necessary, select the checkbox Use XML-based properties files.
    • Add the required locales. To do that, click new and type the comma-separated suffixes of the required locales.
    • Click OK when ready.

The new node Resource Bundle '<base_name>' appears in the Project Tool Window:

Resource bundle

By default, the bundle contains properties files for all specified locales. You can dissociate it and show only the properties files, without the bundle.

To dissociate a resource bundle:

  1. Right-click the resource bundle you want to dissociate.
  2. On the context menu, click Dissociate Resource Bundle <base_name>.

To combine several properties files into a resource bundle:

  1. Select the properties files to be combined.
  2. Right-click the selection.
  3. On the context menu, click Combine to Resource Bundle.
  4. Specify the base name of the resource bundle.

Editing resource bundles

Once you create several properties files with the same name, differing by locale suffix, IntelliJ IDEA automatically recognizes them and groups them in the Project view into a resource bundle.

Resource bundle

IntelliJ IDEA includes a Resource Bundle editor for convenient editing of localizable strings in properties files.

To open the Resource Bundle editor, do one of the following:

  • In the Project tool window, right-click a resource bundle and choose Jump to Source.
  • Select a resource bundle in the Project tool window, and press F4.
  • Open a properties file that is a part of a bundle and click the Resource Bundle tab at the bottom of the editor:
    Resource bundle editor tab

To edit property keys:

  1. Open a properties file.
  2. Add, change, or delete keys as required. The changes are reflected in the Resource Bundle editor.

Use the Resource Bundle editor to change property values, which will ensure that you edit the entire set of property files simultaneously. IntelliJ IDEA takes care of creating respective records in each file of the bundle.

To edit property values:

  1. Select the property key in the left pane of the resource bundle editor.
  2. In the target locale frame, edit the value as required. The respective properties file is updated accordingly.
    Resource bundle editor

When editing a resource bundle, keep the following in mind:

  • Properties with no values or that are omitted in one of the properties files are highlighted in red.
  • To convert between escape sequences (for example, \u00df) and unicode literals (corresponding national characters, such as ß) in properties files and in the Resource Bundle editor, select the Transparent native-to-ascii conversion check box on the File Encoding page of the Settings/Preferences dialog.
  • It is possible to encode non-ASCII symbols using both uppercase and lowercase hex sequences (for example, \u00E3 and \u00e3). By default, only uppercase sequences are enabled. To use lowercase hex sequences, set the idea.native2ascii.lowercase property in the idea.properties file to true.

    For more information, see Tuning IntelliJ IDEA.

Last modified: 4 April 2018