Project

General

Profile

I18nTaxeditor » History » Version 10

Katja Luther, 03/30/2022 11:20 AM

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