Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

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

Avatar

Level 2

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

5 Replies

Avatar

Level 10

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

Avatar

Level 10

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

Level 2

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

Avatar

Level 2

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