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

Difference between revisions of "Scout/Concepts/Text Provider Service"

(Localization using .properties files)
(Localization using .properties files)
Line 17: Line 17:
 
Service extending the {{ScoutJavadoc|AbstractDynamicNlsTextProviderService|C}} class.
 
Service extending the {{ScoutJavadoc|AbstractDynamicNlsTextProviderService|C}} class.
  
In this case, you need to provide the path to your translations properties file by overriding the getter <code>getDynamicNlsBaseName()</code>.
+
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 <code>getDynamicNlsBaseName()</code>. Here an example:
 
<source lang="java">
 
<source lang="java">
 
   @Override
 
   @Override
Line 32: Line 32:
  
 
If you decide to store your translated texts in <tt>.properties</tt> files, you migth want to use the {{ScoutLink|SDK|NLS Editor}} to edit them.
 
If you decide to store your translated texts in <tt>.properties</tt> files, you migth want to use the {{ScoutLink|SDK|NLS Editor}} to edit them.
 +
 +
You need to respect the format defined by the Java [http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html Properties class]. In particular the encoding of a <tt>.properties</tt> 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": <tt>\uXXXX</tt> where <tt>XXXX</tt> is a hexadecimal id of the character in the [http://en.wikipedia.org/wiki/List_of_Unicode_characters Unicode character table]. Read more on the [http://en.wikipedia.org/wiki/.properties .properties File] on wikipedia.
  
 
== See Also ==
 
== See Also ==

Revision as of 14:05, 24 July 2014

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