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

Avatar

Avatar
Validate 1
Level 2
mohanr80993572
Level 2

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
mohanr80993572
Level 2

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mohanr80993572
Level 2

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
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

27-09-2016

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

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 likes

Total Posts

12,671 posts

Correct reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

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
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
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
Validate 1
Level 2
mohanr80993572
Level 2

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
mohanr80993572
Level 2

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mohanr80993572
Level 2

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

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
mohanr80993572
Level 2

Likes

2 likes

Total Posts

24 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mohanr80993572
Level 2

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