Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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

mohanr80993572
Level 2
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

0 Replies
smacdonald2008
Level 10
Level 10

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

smacdonald2008
Level 10
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.... 

mohanr80993572
Level 2
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

mohanr80993572
Level 2
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