Internationalization (i18n) using JSF Facelets: Messages in Java-classes

柔情痞子 提交于 2019-12-01 23:00:41

You need to use the same way as JSF is under the covers using to load resource bundles: using the ResourceBundle API. Here's an example assuming that the base name is com.example.i18n.base (exactly the value as you'd use in <f:loadBundle> in view or <resource-bundle> in faces-config.xml)

ResourceBundle bundle = ResourceBundle.getBundle("com.example.i18n.base",
    FacesContext.getCurrentInstance().getViewRoot().getLocale());
String pageTitle = bundle.getString("page.title");
// ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!