Localization
Overview

Localisation and internationalisation are techniques to make creation of multilingual programs easier and safer.

Oracle Java Tutorial links

Exercises

Work through the internationalisation of the sample program given in the Oracle Java tutorial here. As an extension, extend the program to handle one more language.

Putting the components together

Create a class LocalInfo in package localization containing the following static method:

public static String getLocalInfo(String language, String region, Calendar currentTime)

This method should accept a calendar instance for the current date and time, a language and region code. The method should produce the following output translated and formatted for the supplied language and region. The sample below is for language 'en' and region 'GB'.

Welcome
The current locale is en_GB
The date is 16 February 2016
The time is 22:37:12 GMT
Number formatting: 1,234,567.89
Currency formatting: £1,234,567.89

You should make use of the following classes at minimum:

java.text.DateFormat;
java.text.NumberFormat;
java.util.Locale;
java.util.ResourceBundle;

You will also likely need to create a properties file with the localised strings.

Extending to other languages

Make the required modifications to handle the locales fr_FR and de_DE. The expected output for French is:

Bienvenue
La localisation actuelle est fr_FR
La date est le 16 février 2016
L'heure est 22:37:12 GMT
Format nombre: 1 234 567,89
Format devise: 1 234 567,89 €

Note that in French, the character separating thousands in numbers is a non-breaking space (Unicode character '\u00A0')

The expected output for German is:

Herzlich Willkommen
Aktueller Standort de_DE
Das Datum ist 16. Februar 2016
Es ist 22:37:12 GMT
Zahlenformatierung: 1.234.567,89
Währungsformatierung: 1.234.567,89 €
Finally, make the modifications to handle your own locale.
Using the default locale

If null language and region codes are supplied to your method, the default locale for your system should be used.

An automated test has been created for this exercise: LocalInfoTest.java.

Note that this test method will require extension to handle non en_GB default locales.