Sven
Sven

Reputation: 6338

JSF2 Internationalization property-file

I am trying to implement following example into my jsf2 app:

http://www.mkyong.com/jsf2/jsf-2-internationalization-example/

But I don't understand how the app knows what property-file belongs to what language.

May you pls explain :-)

Upvotes: 0

Views: 498

Answers (1)

BalusC
BalusC

Reputation: 1109875

That's done by ResourceBundle API, not by JSF. The resource bundle filename should adhere the following pattern name_ll_CC.properties. The _ll part should be the lowercase ISO 693-1 language code. It is optional and only required whenever the _CC part is present. The _CC part should be the uppercase ISO 3166-1 Alpha-2 country code. It is optional and often only used to distinguish between country-specific language dialects, like American English (_en_US) and British English (_en_UK).

The right file is determined based on the Locale of the current request. JSF will pass the one of UIViewRoot#getLocale() to ResourceBundle. If the name_ll_CC.properties file is absent, then the ResourceBundle will scan for name_ll.properties file. If it is absent as well, then the ResourceBundle will fallback to the default properties file whose locale you can specify as <default-locale> entry in faces-config.xml. If an entry is absent as well, then it will finally scan for name.properties instead.

See also:

Upvotes: 3

Related Questions