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
BedrockMission!

Learn More

View all

Sign in to view all badges

reading i18n from servlet

Avatar

Avatar
Validate 10
Level 3
gargsahil099
Level 3

Likes

13 likes

Total Posts

57 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 10
Level 3
gargsahil099
Level 3

Likes

13 likes

Total Posts

57 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
gargsahil099
Level 3

03-05-2019

Hi All,

We have use case where we are reading the i18n (sling:message and sling:key) from servlet. For chinese and ru-ru languages we are not able to read values properly like below

Servlet Returning Value :-

"Banner Abstract": "???????",

Actual Value :-

"Banner Abstract": "横幅摘要",

using the value map to read the JCR properties.

vm.get("sling:message", String.class);

Can someone please help on this.

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 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,408 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

03-05-2019

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

04-05-2019

can you show the code you are using? If you use a valueMap to read it (I assume that becaus of the "vm.get(...)", you basically implemented what the system can already do:

SlingHttpServletRequest request = ...

String bannerAbstractLabel = request.getResourceBundle(null).get("Banner Abstract");

(this uses the locale from the request, but you can override and ask for any locale.)

Towards your problem: For me it seems that some part of the system is not using UTF-8 (maybe your browser or the declared charset/locale in the website, maybe something else); an additional problem could be the font you use for display.

Avatar

Avatar
Validate 10
Level 3
gargsahil099
Level 3

Likes

13 likes

Total Posts

57 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 10
Level 3
gargsahil099
Level 3

Likes

13 likes

Total Posts

57 posts

Correct Reply

4 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 5
View profile
gargsahil099
Level 3

04-05-2019

Hi joerg,

Is there any way that i can fetch particular locale fir eg "ar-ae" from 1 specific project for eg /apps/project/i18n.

By default in AEM it creates the dict.en_us.json file for all the dictionaries not the project specific.

Thanks

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,112 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

05-05-2019

In that case you should proceed a bit different.

you should provide a basename to your i18n library and then use

request.getResourceBundle("my-basename",new Locale ("ar-ae")).get("Banner Abstract");

(see Apache Sling :: Internationalization Support (i18n)  for the details).