Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be 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)
(Replaced content with "{{ScoutPage|cat=Shared}} Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#text-provider-service")
Line 1: Line 1:
 
{{ScoutPage|cat=Shared}}
 
{{ScoutPage|cat=Shared}}
  
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 {{ScoutLink|Concepts|Shared Plug-In|Shared Plug-In}}.
+
Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#text-provider-service
 
+
* implements: {{ScoutJavadoc|ITextProviderService|I}}
+
* extends: {{ScoutJavadoc|AbstractDynamicNlsTextProviderService|C}} (default, translations are stored in properties files)
+
 
+
== 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 {{ScoutLink|Concepts|Icon_Provider_Service|Icon Provider Services}}.
+
 
+
=== Localization using .properties files ===
+
 
+
By default the internationalization mechanism relies on <tt>.properties</tt> files using a reference implementation of the TextProviderServices:
+
 
+
Service extending the {{ScoutJavadoc|AbstractDynamicNlsTextProviderService|C}} 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 <code>getDynamicNlsBaseName()</code>. Here an example:
+
<source lang="java">
+
  @Override
+
  protected String getDynamicNlsBaseName() {
+
    return "resources.texts.Texts";
+
  }
+
</source>
+
 
+
If configured like this, it means that the <tt>.properties</tt> files will be located in the same plug-in at the location:
+
* <code>/resources/texts/Texts.properties</code> (default)
+
* <code>/resources/texts/Texts_fr.properties</code> (french)
+
* <code>/resources/texts/Texts_de.properties</code> (german)
+
* ... (additional languages)
+
 
+
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 ==
+
* {{ScoutLink|Concepts|Texts}}
+
* {{ScoutLink|Concepts|Shared Plug-In|Shared Plug-In}}
+
* {{ScoutLink|SDK|NLS Editor}}
+

Revision as of 11:02, 29 June 2016

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

Moved to new Scout documentation at http://eclipsescout.github.io/6.0/technical-guide.html#text-provider-service

Back to the top