What's your usecase? Do you want to have your "static" strings translated?
Please check also the official documentation on i18n with CQ5: http://dev.day.com/docs/en/cq/current/developing/cq5-translator.html
Thanks I will have a look at the translator
The use case is actually because we have a native iOS app that they want to use the same messages. They are not using content sync - the client wants to request a JSON file of messages from the existing system.
This would require the content to be served anonymously (which I am not sure is a good idea, but anyway).
What do you think is the best approach?
Message was edited by: TGNZ1234
Instead of using /apps/i18n/de.2.json (for which you would need to have anonymous read access to that tree, correct) you could build a dedicated servlet, which serves the same content under a different path. And -- of course -- you can think of granting read access to anonymous for this path. There shouldn't be any confidential stuff there, so from a security point of view it should be acceptable.
Yes - that 's exactly what I was trying to do. I was having a problem with the query as it was failing when querying in the /apps/myapp/i18n location.
I was trying to run the query as runAsAdministratative, but it still seemed to fail unless I had read permissions set on /apps/myapp/i18n. Was there something else I needed to do? Or do you think I was on the right track.
That would be perfect ... except, we need to use a basename selector within the Jcr Resource Bundle
Is there a way to include the basename selector in the dictionary e.g.
Is the dictionary servlet source code available? Can I override or overlay it??
Sorry I solved the administrative issue. It runs fine anonymously in the Publish instance.
Problem was in my code - trying to use request.getResource().adaptTo(Node.class)
Should have used
Session adminSession = repository.loginAdministrative(null);
No, that servlet does not support the basename. The servlet and code behind it is not exported in the OSGi bundle (com.adobe.granite.i18n in CQ 5.5), so you'd have to write your own. But that's fairly simple: call request.getResourceBundle(basename, locale), then iterate over the elements in the ResourceBundle (getKeys() and getObject(key)) and write the json using the org.apache.sling.commons.json.io.JSONWriter.