i18n Code Style

i18n: internationalization

Any texts in MyTourbook are saved in messages.properties or plugin.properties files. Today there are many thousands of these texts and without having some kind of structure, it would be a mess to find texts and their assocciated texts.

The Messages Editor, which is helpfull to do the translations, supports the grouping and formatting of the text keys. In the preferences of the Messages Editor, the text formatting is defined how the autoformatting is performed, see the following red marks.

 

pref-settings-java-appearance-MemberSortOrder-1813

 

pref-settings-java-appearance-MemberSortOrder-1813

 

Over more than 15 years of MyTourbook development, some naming/grouping of the text keys evolved.

 

In the following screenshots, the Java constants are displayed for easier reading but they have a 1:1 text key in a .properties file.

 

Formatting In The Beginnings

This example is from the beginnings of MyTourbook and it's formatting is not applied today any more, however these text keys still exist with these formattings

  • All words are lowercase
  • Every word is separated with an separator

 

pref-settings-java-appearance-MemberSortOrder-1813

 

Todays Formatting

 These are the changes compared with the formatting in the beginnings

  • Text keys are written in Propercase
  • There is no separator between each word but between text parts

 

The text keys are structured into some parts, the first two parts are grouping the text keys together, these groups are separated with an empty line.

To show only important lines in this screenshot, some lines are removed and commented with //...

 

pref-settings-java-appearance-MemberSortOrder-1813

 

Textkey Parts

 

1st Part

These are examples for the 1st part, when a text is used in the following UI areas then it should start with this key, e.g.

  • App_... is used for common texts
  • Dialog_...
  • PrefPage_...
  • Slideout_...
  • Image__... - Image is a special name, it contains the 1st and 2nd partname by having two __ (underscores)

 

This part is sometimes combined with the 2nd part, e.g.

  • Search_View_...
  • Search_Manager_...
  • Tooltip_ValuePoint_...

 

 

2nd Part

It depends on the 1st part 

 

 

3rd Part

When the text key is for an UI control, then the control name should be the 3rd part, e.g.

  • ..._Checkbox_...
  • ..._Group_...
  • ..._Label_...
  • ..._Radio_...
  • ..._Tab_...

 

 

3rd Part

When the text key is for a dialog title or message within another UI area, then this part should be

..._Dialog_...

 

and the last part should be

  • ..._Message or
  • ..._Title

 

 

Last Part

When a text is displayed in a tooltip, then the last part should be

..._Tooltip

 

 

It is not possible to define a 100% final naming schema for text keys but this should be a guide to have better structured text keys.

 

 

 

 

 

This page is updated for version 21.3