You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Swapnil Mane <sw...@hotwax.co> on 2020/08/31 10:47:36 UTC

Use and Access the i18n content in JSON output

Hello team,
Hope you are doing well.

While working with i18n support in Sling, I refer this document
https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html

As per the document, I have created a dictionary at apps/myApp

==============
/apps/myApp
           +-- English (nt:folder, mix:language)
           |    +-- jcr:language = en
           |    +-- mx (sling:MessageEntry)
           |         +-- sling:key = "msg1"
           |         +-- sling:message = "An Application Text"
           +-- Deutsch (nt:folder, mix:language)
                +-- jcr:language = de
                +-- mx (sling:MessageEntry)
                     +-- sling:key = "msg1"
                     +-- sling:message = "Ein Anwendungstext"
==============

We are consuming the JSON data of site using Sling.
e.g. https://localhost:8080/content/sites/demo/index.infinity.json

Now my question is how to use this key ("msg1") for any node so that
when I access the JSON content, than based on locale the appropriate
message is returned.
For e.g. I create a node for the title and I want, the value of this
title should be ${msg1}, so that based on locale proper value of the
title is returned.

Thank you in advance!

P.S. One thing I would like to mention here, it seems I will be unable
to use the JSP pattern like this <fmt:message key="${msg1}" /> because
the I want the data of node in JSON format.

Best Regards,
Swapnil M Mane