You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Deepak Dixit <de...@hotwax.co> on 2020/09/04 10:08:09 UTC

Localized Content

Hi Team,

How to create localized content using sling?

I am exploring sling cms app [1], I want to generate the localized site
using sling.

Is it possible to generate the localized site using sling?

[1] https://github.com/apache/sling-org-apache-sling-app-cms


Kind Regards,
--
Deepak Dixit

Re: Localized Content

Posted by Deepak Dixit <de...@hotwax.co>.
Hi,

Just want to update, I am able to get the localized content using
resourceBundle


Locale locale = request.getLocale();
> ResourceBundle bundle = request.getResourceBundle(locale);
> String localizedMessage = bundle.getString("The example String");
>
>

Kind Regards,
Deepak Dixit
DIRECTOR OF PRODUCT ENGINEERING
mobile: +91 9826754548
email: deepak.dixit@hotwax.co
*www.hotwax.co <http://www.hotwax.co/>*


On Fri, Sep 4, 2020 at 5:54 PM Deepak Dixit <de...@hotwax.co> wrote:

> Thanks Daniel for your detailed answer,
> Let me try with the provided approaches
>
>
> Kind Regards,
> --
> Deepak Dixit
>
> On Fri, Sep 4, 2020 at 5:44 PM Daniel Klco <dk...@apache.org> wrote:
>
>> Thanks for clarifying the use case. Sling CMS uses the Sling i18n library
>> as Robert provided.
>>
>> The Sling GET servlet which is serving the JSON response is simply reading
>> the resource value, it will not invoke i18n.
>>
>> To get your message localized, you would need to either write a script and
>> use the fmt:[1] tags in JSP or @i18n attribute[2] in HTL or write a
>> servlet
>> / Sling Model with the Exporter framework[3] and then use the i18n
>> provider
>> to retrieve the localized content as shown in the
>> HTMLValdiatorInsightProvider[4]
>>
>> Depending on your use case, you may also be interested in Sling Resource
>> SuperImposing[5] which mirrors a resource structure but allows you to
>> "superimpose" properties (such as translated values) in that structure. I
>> have gotten it to work in Sling CMS, but haven't figured out (due to time
>> constraints) how to get the Sling POST servlet to post to the
>> *Absolute* resource
>> rather than the *SuperImposed *one.
>>
>> Hope that helps!
>>
>> Regards,
>> Dan
>>
>>
>> [1] -
>>
>> https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fmt/tld-summary.html
>> [2] -
>> https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#123-i18n
>> [3] -
>>
>> https://sling.apache.org/documentation/bundles/models.html#exporter-framework-since-130-1
>> [4] -
>>
>> https://github.com/apache/sling-org-apache-sling-app-cms/blob/master/core/src/main/java/org/apache/sling/cms/core/insights/impl/providers/HTMLValdiatorInsightProvider.java
>> [5] - https://github.com/apache/sling-org-apache-sling-superimposing
>>
>> On Fri, Sep 4, 2020 at 7:55 AM Deepak Dixit <de...@hotwax.co>
>> wrote:
>>
>> > How does sling handle the i18n?
>> >
>> > I have a use case:
>> > - I created a website
>> > - Able to access its json using
>> > http://localhost:8080/content/demo/index.infinity.json
>> > - Now I want to manage the localized content for this site
>> > - I am sending Accept-Language header while calling the json url
>> >
>> > Here is the json output
>> >
>> > {
>> > "jcr:primaryType": "nt:unstructured",
>> > "jcr:title": "Demo Page",
>> > "jcr:lastModifiedBy": "admin",
>> > "sling:template": "/conf/global/site/templates/base-page",
>> > "sling:taxonomy": "/etc/taxonomy/reference/community",
>> > "jcr:lastModified": "Fri Sep 04 2020 17:22:17 GMT+0530",
>> > "sling:resourceType": "reference/components/pages/base",
>> > "published": true,
>> > "hideInSitemap": false,
>> > "container": {
>> > "jcr:primaryType": "nt:unstructured",
>> > "richtext": {
>> > "jcr:primaryType": "nt:unstructured",
>> > "_wysihtml_mode": "1",
>> > "text": "This is a test message",
>> > "sling:resourceType": "sling-cms/components/general/richtext"
>> > }
>> > }
>> > }
>> >
>> > Now I want to get the localized content for "This is a test message" .
>> >
>> >
>> >
>> > Kind Regards,
>> > --
>> > Deepak Dixit
>> >
>> >
>> > On Fri, Sep 4, 2020 at 4:52 PM Robert Munteanu <ro...@apache.org>
>> wrote:
>> >
>> > > On Fri, 2020-09-04 at 16:48 +0530, Deepak Dixit wrote:
>> > > > Thanks Robert for quick response,
>> > > >
>> > > > Yes I read it, and did some experiments but no luck
>> > > >
>> > > > I followed the instruction [1] and setup the sling cms app,
>> > > > Created new site, added i18n and/or languages but no luck
>> > >
>> > > I see. Maybe it's about the way the Sling CMS handles i18n, and that I
>> > > do not know. Maybe someone else does.
>> > >
>> > > Robert
>> > >
>> > > >
>> > > >
>> > > > [1] https://github.com/apache/sling-org-apache-sling-app-cms
>> > > > Kind Regards,
>> > > > --
>> > > > Deepak Dixit
>> > > >
>> > > > On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org>
>> > > > wrote:
>> > > >
>> > > > > Hi Deepak,
>> > > > >
>> > > > > On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
>> > > > > > Hi Team,
>> > > > > >
>> > > > > > How to create localized content using sling?
>> > > > > >
>> > > > > > I am exploring sling cms app [1], I want to generate the
>> > > > > > localized
>> > > > > > site
>> > > > > > using sling.
>> > > > > >
>> > > > > > Is it possible to generate the localized site using sling?
>> > > > >
>> > > > > Have you seen the i18n support from Sling?
>> > > > >
>> > > > >
>> > > > >
>> > >
>> >
>> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
>> > > > >
>> > > > > Thanks,
>> > > > > Robert
>> > > > >
>> > > > >
>> > >
>> > >
>> >
>>
>

Re: Localized Content

Posted by Deepak Dixit <de...@hotwax.co>.
Thanks Daniel for your detailed answer,
Let me try with the provided approaches


Kind Regards,
--
Deepak Dixit

On Fri, Sep 4, 2020 at 5:44 PM Daniel Klco <dk...@apache.org> wrote:

> Thanks for clarifying the use case. Sling CMS uses the Sling i18n library
> as Robert provided.
>
> The Sling GET servlet which is serving the JSON response is simply reading
> the resource value, it will not invoke i18n.
>
> To get your message localized, you would need to either write a script and
> use the fmt:[1] tags in JSP or @i18n attribute[2] in HTL or write a servlet
> / Sling Model with the Exporter framework[3] and then use the i18n provider
> to retrieve the localized content as shown in the
> HTMLValdiatorInsightProvider[4]
>
> Depending on your use case, you may also be interested in Sling Resource
> SuperImposing[5] which mirrors a resource structure but allows you to
> "superimpose" properties (such as translated values) in that structure. I
> have gotten it to work in Sling CMS, but haven't figured out (due to time
> constraints) how to get the Sling POST servlet to post to the
> *Absolute* resource
> rather than the *SuperImposed *one.
>
> Hope that helps!
>
> Regards,
> Dan
>
>
> [1] -
> https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fmt/tld-summary.html
> [2] -
> https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#123-i18n
> [3] -
>
> https://sling.apache.org/documentation/bundles/models.html#exporter-framework-since-130-1
> [4] -
>
> https://github.com/apache/sling-org-apache-sling-app-cms/blob/master/core/src/main/java/org/apache/sling/cms/core/insights/impl/providers/HTMLValdiatorInsightProvider.java
> [5] - https://github.com/apache/sling-org-apache-sling-superimposing
>
> On Fri, Sep 4, 2020 at 7:55 AM Deepak Dixit <de...@hotwax.co>
> wrote:
>
> > How does sling handle the i18n?
> >
> > I have a use case:
> > - I created a website
> > - Able to access its json using
> > http://localhost:8080/content/demo/index.infinity.json
> > - Now I want to manage the localized content for this site
> > - I am sending Accept-Language header while calling the json url
> >
> > Here is the json output
> >
> > {
> > "jcr:primaryType": "nt:unstructured",
> > "jcr:title": "Demo Page",
> > "jcr:lastModifiedBy": "admin",
> > "sling:template": "/conf/global/site/templates/base-page",
> > "sling:taxonomy": "/etc/taxonomy/reference/community",
> > "jcr:lastModified": "Fri Sep 04 2020 17:22:17 GMT+0530",
> > "sling:resourceType": "reference/components/pages/base",
> > "published": true,
> > "hideInSitemap": false,
> > "container": {
> > "jcr:primaryType": "nt:unstructured",
> > "richtext": {
> > "jcr:primaryType": "nt:unstructured",
> > "_wysihtml_mode": "1",
> > "text": "This is a test message",
> > "sling:resourceType": "sling-cms/components/general/richtext"
> > }
> > }
> > }
> >
> > Now I want to get the localized content for "This is a test message" .
> >
> >
> >
> > Kind Regards,
> > --
> > Deepak Dixit
> >
> >
> > On Fri, Sep 4, 2020 at 4:52 PM Robert Munteanu <ro...@apache.org>
> wrote:
> >
> > > On Fri, 2020-09-04 at 16:48 +0530, Deepak Dixit wrote:
> > > > Thanks Robert for quick response,
> > > >
> > > > Yes I read it, and did some experiments but no luck
> > > >
> > > > I followed the instruction [1] and setup the sling cms app,
> > > > Created new site, added i18n and/or languages but no luck
> > >
> > > I see. Maybe it's about the way the Sling CMS handles i18n, and that I
> > > do not know. Maybe someone else does.
> > >
> > > Robert
> > >
> > > >
> > > >
> > > > [1] https://github.com/apache/sling-org-apache-sling-app-cms
> > > > Kind Regards,
> > > > --
> > > > Deepak Dixit
> > > >
> > > > On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org>
> > > > wrote:
> > > >
> > > > > Hi Deepak,
> > > > >
> > > > > On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> > > > > > Hi Team,
> > > > > >
> > > > > > How to create localized content using sling?
> > > > > >
> > > > > > I am exploring sling cms app [1], I want to generate the
> > > > > > localized
> > > > > > site
> > > > > > using sling.
> > > > > >
> > > > > > Is it possible to generate the localized site using sling?
> > > > >
> > > > > Have you seen the i18n support from Sling?
> > > > >
> > > > >
> > > > >
> > >
> >
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> > > > >
> > > > > Thanks,
> > > > > Robert
> > > > >
> > > > >
> > >
> > >
> >
>

Re: Localized Content

Posted by Daniel Klco <dk...@apache.org>.
Thanks for clarifying the use case. Sling CMS uses the Sling i18n library
as Robert provided.

The Sling GET servlet which is serving the JSON response is simply reading
the resource value, it will not invoke i18n.

To get your message localized, you would need to either write a script and
use the fmt:[1] tags in JSP or @i18n attribute[2] in HTL or write a servlet
/ Sling Model with the Exporter framework[3] and then use the i18n provider
to retrieve the localized content as shown in the
HTMLValdiatorInsightProvider[4]

Depending on your use case, you may also be interested in Sling Resource
SuperImposing[5] which mirrors a resource structure but allows you to
"superimpose" properties (such as translated values) in that structure. I
have gotten it to work in Sling CMS, but haven't figured out (due to time
constraints) how to get the Sling POST servlet to post to the
*Absolute* resource
rather than the *SuperImposed *one.

Hope that helps!

Regards,
Dan


[1] -
https://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/fmt/tld-summary.html
[2] -
https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#123-i18n
[3] -
https://sling.apache.org/documentation/bundles/models.html#exporter-framework-since-130-1
[4] -
https://github.com/apache/sling-org-apache-sling-app-cms/blob/master/core/src/main/java/org/apache/sling/cms/core/insights/impl/providers/HTMLValdiatorInsightProvider.java
[5] - https://github.com/apache/sling-org-apache-sling-superimposing

On Fri, Sep 4, 2020 at 7:55 AM Deepak Dixit <de...@hotwax.co> wrote:

> How does sling handle the i18n?
>
> I have a use case:
> - I created a website
> - Able to access its json using
> http://localhost:8080/content/demo/index.infinity.json
> - Now I want to manage the localized content for this site
> - I am sending Accept-Language header while calling the json url
>
> Here is the json output
>
> {
> "jcr:primaryType": "nt:unstructured",
> "jcr:title": "Demo Page",
> "jcr:lastModifiedBy": "admin",
> "sling:template": "/conf/global/site/templates/base-page",
> "sling:taxonomy": "/etc/taxonomy/reference/community",
> "jcr:lastModified": "Fri Sep 04 2020 17:22:17 GMT+0530",
> "sling:resourceType": "reference/components/pages/base",
> "published": true,
> "hideInSitemap": false,
> "container": {
> "jcr:primaryType": "nt:unstructured",
> "richtext": {
> "jcr:primaryType": "nt:unstructured",
> "_wysihtml_mode": "1",
> "text": "This is a test message",
> "sling:resourceType": "sling-cms/components/general/richtext"
> }
> }
> }
>
> Now I want to get the localized content for "This is a test message" .
>
>
>
> Kind Regards,
> --
> Deepak Dixit
>
>
> On Fri, Sep 4, 2020 at 4:52 PM Robert Munteanu <ro...@apache.org> wrote:
>
> > On Fri, 2020-09-04 at 16:48 +0530, Deepak Dixit wrote:
> > > Thanks Robert for quick response,
> > >
> > > Yes I read it, and did some experiments but no luck
> > >
> > > I followed the instruction [1] and setup the sling cms app,
> > > Created new site, added i18n and/or languages but no luck
> >
> > I see. Maybe it's about the way the Sling CMS handles i18n, and that I
> > do not know. Maybe someone else does.
> >
> > Robert
> >
> > >
> > >
> > > [1] https://github.com/apache/sling-org-apache-sling-app-cms
> > > Kind Regards,
> > > --
> > > Deepak Dixit
> > >
> > > On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org>
> > > wrote:
> > >
> > > > Hi Deepak,
> > > >
> > > > On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> > > > > Hi Team,
> > > > >
> > > > > How to create localized content using sling?
> > > > >
> > > > > I am exploring sling cms app [1], I want to generate the
> > > > > localized
> > > > > site
> > > > > using sling.
> > > > >
> > > > > Is it possible to generate the localized site using sling?
> > > >
> > > > Have you seen the i18n support from Sling?
> > > >
> > > >
> > > >
> >
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> > > >
> > > > Thanks,
> > > > Robert
> > > >
> > > >
> >
> >
>

Re: Localized Content

Posted by Deepak Dixit <de...@hotwax.co>.
How does sling handle the i18n?

I have a use case:
- I created a website
- Able to access its json using
http://localhost:8080/content/demo/index.infinity.json
- Now I want to manage the localized content for this site
- I am sending Accept-Language header while calling the json url

Here is the json output

{
"jcr:primaryType": "nt:unstructured",
"jcr:title": "Demo Page",
"jcr:lastModifiedBy": "admin",
"sling:template": "/conf/global/site/templates/base-page",
"sling:taxonomy": "/etc/taxonomy/reference/community",
"jcr:lastModified": "Fri Sep 04 2020 17:22:17 GMT+0530",
"sling:resourceType": "reference/components/pages/base",
"published": true,
"hideInSitemap": false,
"container": {
"jcr:primaryType": "nt:unstructured",
"richtext": {
"jcr:primaryType": "nt:unstructured",
"_wysihtml_mode": "1",
"text": "This is a test message",
"sling:resourceType": "sling-cms/components/general/richtext"
}
}
}

Now I want to get the localized content for "This is a test message" .



Kind Regards,
--
Deepak Dixit


On Fri, Sep 4, 2020 at 4:52 PM Robert Munteanu <ro...@apache.org> wrote:

> On Fri, 2020-09-04 at 16:48 +0530, Deepak Dixit wrote:
> > Thanks Robert for quick response,
> >
> > Yes I read it, and did some experiments but no luck
> >
> > I followed the instruction [1] and setup the sling cms app,
> > Created new site, added i18n and/or languages but no luck
>
> I see. Maybe it's about the way the Sling CMS handles i18n, and that I
> do not know. Maybe someone else does.
>
> Robert
>
> >
> >
> > [1] https://github.com/apache/sling-org-apache-sling-app-cms
> > Kind Regards,
> > --
> > Deepak Dixit
> >
> > On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org>
> > wrote:
> >
> > > Hi Deepak,
> > >
> > > On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> > > > Hi Team,
> > > >
> > > > How to create localized content using sling?
> > > >
> > > > I am exploring sling cms app [1], I want to generate the
> > > > localized
> > > > site
> > > > using sling.
> > > >
> > > > Is it possible to generate the localized site using sling?
> > >
> > > Have you seen the i18n support from Sling?
> > >
> > >
> > >
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> > >
> > > Thanks,
> > > Robert
> > >
> > >
>
>

Re: Localized Content

Posted by Robert Munteanu <ro...@apache.org>.
On Fri, 2020-09-04 at 16:48 +0530, Deepak Dixit wrote:
> Thanks Robert for quick response,
> 
> Yes I read it, and did some experiments but no luck
> 
> I followed the instruction [1] and setup the sling cms app,
> Created new site, added i18n and/or languages but no luck

I see. Maybe it's about the way the Sling CMS handles i18n, and that I
do not know. Maybe someone else does.

Robert

> 
> 
> [1] https://github.com/apache/sling-org-apache-sling-app-cms
> Kind Regards,
> --
> Deepak Dixit
> 
> On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org>
> wrote:
> 
> > Hi Deepak,
> > 
> > On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> > > Hi Team,
> > > 
> > > How to create localized content using sling?
> > > 
> > > I am exploring sling cms app [1], I want to generate the
> > > localized
> > > site
> > > using sling.
> > > 
> > > Is it possible to generate the localized site using sling?
> > 
> > Have you seen the i18n support from Sling?
> > 
> > 
> > https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
> > 
> > Thanks,
> > Robert
> > 
> > 


Re: Localized Content

Posted by Deepak Dixit <de...@hotwax.co>.
Thanks Robert for quick response,

Yes I read it, and did some experiments but no luck

I followed the instruction [1] and setup the sling cms app,
Created new site, added i18n and/or languages but no luck


[1] https://github.com/apache/sling-org-apache-sling-app-cms
Kind Regards,
--
Deepak Dixit

On Fri, Sep 4, 2020 at 4:27 PM Robert Munteanu <ro...@apache.org> wrote:

> Hi Deepak,
>
> On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> > Hi Team,
> >
> > How to create localized content using sling?
> >
> > I am exploring sling cms app [1], I want to generate the localized
> > site
> > using sling.
> >
> > Is it possible to generate the localized site using sling?
>
> Have you seen the i18n support from Sling?
>
>
> https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html
>
> Thanks,
> Robert
>
>

Re: Localized Content

Posted by Robert Munteanu <ro...@apache.org>.
Hi Deepak,

On Fri, 2020-09-04 at 15:38 +0530, Deepak Dixit wrote:
> Hi Team,
> 
> How to create localized content using sling?
> 
> I am exploring sling cms app [1], I want to generate the localized
> site
> using sling.
> 
> Is it possible to generate the localized site using sling?

Have you seen the i18n support from Sling?

  https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html

Thanks,
Robert