20.1.3 Message and I18N

Special care in the use of messages is required for programmes for which you have provided translations into at least one other language. On the one hand, you must ensure that the texts in the messages are translated and, on the other hand, the intended design should be preserved. This is not easy, as you can see in the picture on the right:

de en fr

You have to test the design for each of the target languages and make sure that you have the target languages installed on your system. Chapter 3.5 Multilingual programmes therefore introduces you to a programme that can do just that for the tests:

i18n

Figure 20.1.3.1: Test program I18N

In the project properties you have to indicate under the options whether the project contains translations and possibly select the default language. For the project translation, you will then find the entry Translate in the menu and in the toolbar the symbol Translate will appear as a small blue flag, while you can call up the project translation directly with [CTRL +T] (→ Chapter 3.5).

In the source text of your internationalised programmes, you must mark up the strings to be translated - but only for strings whose text is visible - by enclosing these strings in round brackets:

PUBLIC SUB btnFileSave_Click()
 
'-- sDatei ist eine globale Variable: "filelist.txt"
'-- Originale MessageBox für ein Programm in deutscher Sprache
'-- Message.Question("Soll die Datei " & sDatei & " gespeichert werden?", "Ja", "Nein")
    Message.Question("<b>" & sDatei & "</b><br>" & ("Datei speichern?"), ("Ja"), ("Nein"))
 
END

original

Figure 20.1.3.2: Message window (original)

After translating all the strings in the project translation in the Gambas IDE, you will get the following messages in a MessageBox in the language you selected in the language test program, for example:

Figure 20.1.3.3: German - Figure 20.1.3.4: French - Figure 20.1.3.5: English

Reference:
You do not have to mark the identifiers on the two buttons because they are automatically in the list of strings to be translated.

20.1.3 Download