Project

General

Profile

I18nTaxeditor » History » Version 8

Patrick Plitzner, 02/23/2017 05:35 PM

1 1 Patrick Plitzner
2
# Internationalization / Localization
3
4 5 Patrick Plitzner
This site describes the conventions for i18n and L10n of our projects.
5 1 Patrick Plitzner
6
7
## Taxonomic Editor
8
9
10
### Project structure
11
12
Each plugin has the following structure:
13
14 4 Patrick Plitzner
~~~
15 1 Patrick Plitzner
16
<plugin_root>
17 8 Patrick Plitzner
 |-src/main/java
18
 | \-eu.etaxonomy.taxeditor.xyz
19
 |  \-l10n
20 7 Patrick Plitzner
 |   \-Messages.java
21
 |    |-messages_xx.properties
22
 |    |-messages_yy.properties
23
 |    \-messages.properties
24
 \-OSGI-INF
25
   \-l10n
26
    |-bundle_xx.properties
27
    |-bundle_yy.properties
28
    \-bundle.properties
29 5 Patrick Plitzner
    
30 1 Patrick Plitzner
~~~
31
32
* xx, yy, etc. stand for the single country codes
33
* the .properties files without country code are the default files used if no locale is specified
34 5 Patrick Plitzner
* bundle.properties are for externalized string from the plugin.xml (mostly labels for menus, toolbar, context-menus)
35
* messages.properties are for Java classes (mostly exception texts and user interaction, dialogs, etc.)
36
* Messages.java is used to access the externalized strings in Java classes. It "connects" the messages.properties files to the Java code
37
* **Note:** When externalizing Java classes with Eclipse (right-click->Source->Externalize Strings) you have to adapt the path to Messages.java and the properties file or Eclipse will create a new Messages.java and messages.properties file in the current package
38
39
### Conventions
40
* For sustainable future updates it is always recommended to keep the language specific .properties files in sync with the default one
41
 * Try to do the translation directly if you know the language
42
 * If you don't know the language at least copy the newly created key-value pairs into the language specific .properties file
43
* For comparison it is much easier if the .properties files all have the same order of key-value pairs
44
* Do not include technical strings into the externalization process like e.g. "; " or exception messages like "IEditorInput received a null selection"
45
 * even if this is displayed to the user, translating it would probably make it worse
46
 * if it is shown via the MessagingUtils the user can just copy the message and send it to us
47
* Use some meaningful suffixes for the externalized string
48
 * Eclipse automatically starts every variable with the class name and then just appends numbers (`CdmDataSourceViewPart_2`)
49
 * if the string would be "Confirm deletion" call it <class_name>_CONFIRM_DELETE or something similar. This improves the readability of the code a lot.
50
* Before starting the automatic externalization look for:
51
 * repeated strings and try to refactor them to constants in that class
52
 * unify string that are split to several string because of line breaks
53
 * use `String.format()` if the string contains variables