Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Scout/Concepts/Text Provider Service

< Scout‎ | Concepts
Revision as of 14:05, 24 July 2014 by Unnamed Poltroon (Talk) (Localization using .properties files)

The Scout documentation has been moved to https://eclipsescout.github.io/.

Text Provider Services are services responsible to provide localization for texts in the user interface. A typical application contains a such service contributed by the The Scout documentation has been moved to https://eclipsescout.github.io/..

Description

Using Text Provider Services developers can decide to store the translations in a custom container like a database or XML files. Furthermore using TextProviderServices it is very easy to overwrite any translated text in the application (also texts used in Scout itself) using the service ranking.

The mechanism is aligned with the icon retrieval which is also managed using The Scout documentation has been moved to https://eclipsescout.github.io/..

Localization using .properties files

By default the internationalization mechanism relies on .properties files using a reference implementation of the TextProviderServices:

Service extending the The Scout documentation has been moved to https://eclipsescout.github.io/. class.

A Text Provider Service working with the default implementation need to define where the properties files are located. This is realized by overriding the getter getDynamicNlsBaseName(). Here an example:

  @Override
  protected String getDynamicNlsBaseName() {
    return "resources.texts.Texts";
  }

If configured like this, it means that the .properties files will be located in the same plug-in at the location:

  • /resources/texts/Texts.properties (default)
  • /resources/texts/Texts_fr.properties (french)
  • /resources/texts/Texts_de.properties (german)
  • ... (additional languages)

If you decide to store your translated texts in .properties files, you migth want to use the The Scout documentation has been moved to https://eclipsescout.github.io/. to edit them.

You need to respect the format defined by the Java Properties class. In particular the encoding of a .properties file is ISO-8859-1 (also known as Latin-1). All non-Latin-1 characters must be encoded. Examples:

 'à' => "\u00E0"
 'ç' => "\u00E7"
 'ß' => "\u00DF"

The encoding is the "Unicode escape characters": \uXXXX where XXXX is a hexadecimal id of the character in the Unicode character table. Read more on the .properties File on wikipedia.

See Also

Back to the top