Posts mit dem Label localization werden angezeigt. Alle Posts anzeigen
Posts mit dem Label localization werden angezeigt. Alle Posts anzeigen

Mittwoch, 6. Februar 2013

CQ5 Internationalization


To achieve the goal of a multi lingual CQ5-based application, you may use CQ I18n implementation (API) to access the translated strings from the ResourceBundle, according to your language.

In the XML definition of a component, the dialog.xml, use the key directly in the text field, e.g.
fieldLabel="app.component.key"
CQ5 will resolve the reference automatically.

<mypanel jcr:primarytype="cq:Panel" title="app.component.key" name="general"> (...) </mypanel>

In Java Script, CQ5 provides the method
CQ.I18n.get('app.component.key')

In Java we implemented a Localization service, that loads all keys from JCR.
In JSP you can use
<%= I18n.get(slingRequest.getResourceBundle(currentPage.getLanguage(true)), "app.components.custom.key") %>
after importing I18n
<%@ page import="com.day.cq.i18n.I18n" %>