Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Which should look something like this:

You can also use properties files to capture language strings. Using the LablesBundle.properties, LablesBundle.properties_de and LablesBundle_fr.properties files from this tutorial. We can then use this code:

Code Block

def locales = [Locale.FRENCH, Locale.GERMAN, Locale.ENGLISH]
def keys = ["s1", "s2", "s3", "s4"]
[locales, keys].combinations().each{ loc, key ->
    def labels = ResourceBundle.getBundle("LabelsBundle", loc)
    println "Locale = ${loc.toString()}, key = $key, value = ${labels.getString(key)}"
}

To produce this result:

Code Block
none
none

Locale = fr, key = s1, value = Ordinateur
Locale = de, key = s1, value = Computer
Locale = en, key = s1, value = computer
Locale = fr, key = s2, value = Disque dur
Locale = de, key = s2, value = Platte
Locale = en, key = s2, value = disk
Locale = fr, key = s3, value = Moniteur
Locale = de, key = s3, value = Monitor
Locale = en, key = s3, value = monitor
Locale = fr, key = s4, value = Clavier
Locale = de, key = s4, value = Tastatur
Locale = en, key = s4, value = keyboard