开发者

JSF2 Internationalization property-file

开发者 https://www.devze.com 2023-02-03 15:17 出处:网络
I am trying to implement following example into my jsf2 app: http://www.mkyong.com/jsf2/jsf-2-in开发者_JAVA技巧ternationalization-example/

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

http://www.mkyong.com/jsf2/jsf-2-in开发者_JAVA技巧ternationalization-example/

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

May you pls explain :-)


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:

  • Java tutorial - ResourceBundle
  • How to internationalize a JSP/JSTL web application?
  • How to internationalize a JSF 2.0 web application using UTF-8 properties files without native2ascii?
0

精彩评论

暂无评论...
验证码 换一张
取 消