How to pass basename for getResourceBundle(...) in case of sightly

Avatar

Avatar

mohanr80993572

Avatar

mohanr80993572

mohanr80993572

27-09-2016

In sightly, for example, we use ${'lbl.global.loginText' @ i18n} to use I18N keys. Where is "i18n" defined in this case? In jsps we use as follows:

    final ResourceBundle resourceBundle = slingRequest.getResourceBundle("basename", currentPage.getLanguage(true));
    I18n i18n = new I18n(resourceBundle);

Where/how do we do this in sightly?

Help would be greatly appreciated.

Thanks,

Mohan

Replies

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

27-09-2016

Have you looked at using this via a HTL (Sightly) Java class that extends WCMUsePojo? 

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

27-09-2016

Use WCMUsePojo to create these Objects. For example- the WCMUsePojo has this method:

SlingHttpServletRequest    getRequest() 

Using a SLingHttpServletRequest - you can invoke this method. 

ResourceBundle    getResourceBundle(Locale locale)

This is how you get a ResourceBundle    

If you are not sure how to create a HTL (Sightly) component that uses WCMUsePojo - see this artilce and video:

https://helpx.adobe.com/experience-manager/using/htl_61.html

Hope this helps.... 

Avatar

Avatar

Feike_Visser1

Employee

Avatar

Feike_Visser1

Employee

Feike_Visser1
Employee

27-09-2016

You can do this too:

${'Hello World' @ i18n, locale=request.locale}

More info here:

https://github.com/Adobe-Marketing-Cloud/htl-spec/blob/master/SPECIFICATION.md

Avatar

Avatar

mohanr80993572

Avatar

mohanr80993572

mohanr80993572

27-09-2016

Hi Mac, thanks for your response. The method getResourceBundle(Locale locale) accepts only Locale. I want to pass both basename, locale where basename would be the application/brand name. Based on brand/base name I want to load different dictionaries for different applications. I am new to HTL. Anyhow I will try using HTL as you suggested and see if I can achieve that.

Thanks,

Mohan

Avatar

Avatar

mohanr80993572

Avatar

mohanr80993572

mohanr80993572

27-09-2016

Hi Feike, thanks for your response. I want to pass both basename and locale. The one you mentioned accepts only locale but not basename.

Thanks,

Mohan