1
votes

I followed the instructions on this page (http://docs.adobe.com/docs/en/cq/current/developing/cq5-translator.html) in order to try to give my component access to a translatable string bundle. I followed these instructions (http://www.wemblog.com/2011/12/how-to-use-multi-language-translation.html) to setup the component's JSP file to use the translated strings. However, it's not working; the default value is always used. I'm not sure where it is attempting to pull the resource bundle from, but I would like it to pull from the i18n folder I've created directly under the component node. Any ideas what I am doing wrong?

Relevant JSP code:

<cq:setContentBundle language="se" source="static" /><%
Locale pageLocale = currentPage.getLanguage(false); 
ResourceBundle resourceBundle = slingRequest.getResourceBundle("hello-world-strings", pageLocale);
    I18n i18n = new I18n(resourceBundle);
%>

<div style="margin:1em;padding:.8em;box-shadow:inset 0px 0px .5em #ddd;border:solid 1px #aaa;">
    <h1>Translation Testing Output</h1>
    OUT: <%= i18n.get("name") %>
</div>
1

1 Answers

0
votes

Adding a comment in CQ's translator changes the key. For debugging, try spitting the keys out:

<%= slingRequest.getResourceBundle(slingRequest.getLocale()).keySet()%><br>

If you see keys in the list that have unexpected double parentheses, those are the translator comments. If this is the case, you may not be getting messages because the keys aren't what you think they should be. Try deleting the comments. You can't do this in the translator, but you can use a tool like crxde to edit the sling:key property directly.