Creating a Universal Locale Switcher
Every internationalized application needs to have some solution for switching the
current locale, and it would be nice to have a universal component for this purpose.
Let's try to define what such a component should do:
It should find out which locales are supported by the application.
It should display a drop-down box with an option for each supported locale.
It should also display a flag image for the currently selected locale.
In a way, the logic of this component will be opposite of the logic of the English/
German locale switcher we created in the previous chapter, because it will display
the flag and the label for the currently selected locale, not for the alternative one (as
there potentially can be more than one alternative locale). The following is what we
want to achieve:
??? ??? ???
Chapter 8
[ 223 ]
At the first stage, let us simplify our task and pass a list of supported locales to the
new component as a parameter. Later we shall see what it will take to obtain this list
from the application automatically.
First of all, as we are going to have a Select component working with locale objects,
we need to provide an appropriate SelectModel implementation.
Pages:
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279