 |
 |
 |
 |
TurbineServices.getInstance().getService(LocalizationService.LOCALIZATION)
.getString("DISPLAYPROJECTS_TITLE");
|
 |
 |
 |
 |
Wow. That is a lot of typing. That could be easily shortened to this:
 |
 |
 |
 |
Localization.getString("DISPLAYPROJECTS_TITLE");
|
 |
 |
 |
 |
The hard example above was given as an example of using Services. The easy
example is the one that you really should be using. Another cool feature
of the Localization class is that you can pass in a RunData object like
this:
 |
 |
 |
 |
Localization.getString(data, "DISPLAYPROJECTS_TITLE");
|
 |
 |
 |
 |
This has the added effect of using the Accept-Language HTTP header to determine
which language to display based on what setting the user has defined in
the browser. Can you say Dynamic Localization? ;-)
For creating the file where you get the value of the String, please
see the java.util.ListResourceBundle and
java.util.ResourceBundle classes for more information.
Jyve also contains example usage
of this code because that was the first place where this code was originally
developed.