GERMAN))
{
persistentLocale.set(Locale.ENGLISH);
}
else
{
persistentLocale.set(Locale.GERMAN);
}
}
Please note that to compare locale objects, you will need to use the
equals method. Something like currentLocale == Locale.GERMAN
will not work for you.
Internationalization and Localization
[ 184 ]
Now, running the application, you should see the already familiar page, plus the
new link on it:
Click on the Switch Locale link, and the language of the application will change:
Chapter 7
[ 185 ]
We have just internationalized our first Tapestry page! And it was easy, wasn't
it? What happened here is that when the locale of the application was switched to
German, Tapestry looked for a German message catalog for the page, and found
the Start_de.properties file. So it took the labels from it, except for the one,
with celebrity-collector key. It kept looking for a German root message
catalog that would look like app_de.properties, but couldn't find any. So it
took the default root catalog, app.properties, and retrieved the value for the
celebrity-collector key from there.
Everything works now, but there is still a space for an enhancement. Wouldn't it be
better if the text of the link for switching the locale was more informative? Imagine
that a German-speaking user came to the application and cannot understand
anything because it is displayed in English.
Pages:
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237