Cantiga Project
Adding internationalization
When a new project is created with ROMA a set of files *.properties are generated under the package /i18n. The files domain_messages.properties and default_messages.properties with the messages used by the application are used by default. If you want to add a new language all you have to do is to create the files domain_messages_xx.properties and default_messages_xx.properties where xx is the prefix of your country. For example es for Spain, it for Italy etc.
Copy the content of domain_messages.properties into domain_messages_xx.properties and the content of default_messages.properties into default_messages_xx.properties and traduce the strings. Here is a snippet of the content of these files.
-default_messages.properties
Application.DateTimeFormat dd/MM/yyyy HH:mm:ss
Application.DateFormat dd/MM/yyyy
Application.TimeFormat HH:mm:ss
Application.RequiredText *
Message.Title Error on validation input data
Message.Warning Warning!
Message.Validation.error <center><b>Error in validation. One or more fields contain errors. Please check the content of the fields listed below.</b></center>
-default_messages_it.properties
Application.DateTimeFormat dd/MM/yyyy HH:mm:ss
Application.DateFormat dd/MM/yyyy
Application.TimeFormat HH:mm:ss
Application.RequiredText *
Message.Title Errore in validazione dei dati
Message.Warning Attenzione!
Message.Validation.error <center><b>Errore di validazione. Uno o pi� campi contengono errori. Per favore controlla il contenuto dei campi sotto elencati.</b></center>
Once these files have been created the application will detect the language configuration of the browser and the messages will be displayed in its language.
To internazionalice Strings in the java code they must be externalized. IDEs like Eclipse or Netbeans provides facilities to externalize Strings. In Eclipse, just right clik in the code, select source/externalize Strings and a wizard will appear. In it we can select the Strings to externalize to a properties file. This file is automatically created in the directory of the source with the name messages.properties and also the file Messages.java is created. This java file simply resolve the string to the correct text in the properties files. After finishing the wizard it must be created a new properties file with each new idiom in which we want to display the Strings.
For example, in Cantiga's class UploadPage under com.germinus.cantiga.view.domain package the different types of sources to upload must be displayed in different idioms. To achieve this, it can be used the eclipse wizard as explained in the previous paragraph and (selecting the Strings: Document, Conference, Master Class, Music Performance) the messages.properties should look like this
UploadPage.2=Document
UploadPage.3=Conference
UploadPage.4=Master Class
UploadPage.5=Music
Performance So for the spanish version of this file it must be created the file messages_es.properties with the content:
UploadPage.2=Documento
UploadPage.3=Conferencia
UploadPage.4=Clase Maestra
UploadPage.5=Interpretación Musical
Last Update: 2008-08-13