Java Reference
In-Depth Information
Download email_20/res/StripesResources_fr.properties
stripesbook.action.LoginActionBean.username=Courriel principal
stripesbook.action.LoginActionBean.password=Mot de passe
stripesbook.action.LoginActionBean.login=Envoyer
The nice thing about the resource bundle keys that Stripes uses is that
we can keep your keys organized with the action bean class name prefix
and use keys without the prefix for text that is the same across more
than one action bean. For example, the following resource bundle entry:
cancel=Cancel
would label all <s:submit name="cancel"/> buttons with “Cancel.” If all
these buttons will be labeled “Cancel,” why repeat the same text as
many times as there are action beans? Furthermore, we can still over-
ride this and use a different label in a specific page. If we wanted to use
“Abort” instead of “Cancel” on the Register page, we would add this:
stripesbook.action.RegisterActionBean.cancel=Abort
since this key has priority over the previous, nonprefixed key.
Translating Error and Information Messages
For error and information messages, Stripes looks in the error message
bundle for the text to be displayed, which is also in StripesResources by
default. The classes involved in creating localized messages are Local-
izableMessage , LocalizableError , and ScopedLocalizableError , as shown in
Figure 11.2 , on the following page, with their relationship to the other
Stripes message classes.
We've seen how LocalizableError and ScopedLocalizableError work in Sec-
tion 6.3 , Changing the Error Message Text, on page 134 . Both classes
look for messages in the resource bundle with a series of keys based on
the action bean and the nature of the error. We already have key-value
pairs for these messages in StripesResources.properties , so we just have to
use the same keys and translate the text in StripesResources_fr.properties .
Here are some examples:
Download email_20/res/StripesResources.properties
validation.required.valueNotPresent={0} is a required field
contact.lastName.valueTooShort=\
The last name must be at least {2} characters.
contact.birthDate.invalidDate=The birth date is not valid.
contact.birthDate.valueFailedExpression=\
The birth date is in the future.
 
 
Search WWH ::




Custom Search