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

SOLVED

How to get country and language codes in OSGI service

Avatar

Community Advisor

Hi All, 

 

I want to get all available language codes in AEM.

Is there anyway we can get country and language codes in 2 digits? Currently I'm using all the codes by creating enum.Is this correct way of using language codes in AEM OSGI services

ArunaSurukunta_0-1632329989298.png

Thanks,

Aruna

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Thanks for the inputs @Aruna_surukunta_ 

Every enum constant is an instance of an enum class. Given the list of languages to consider, you can use the one from OOTB location that I shared accordingly. 

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @Aruna_surukunta_,

List of languages are available at this location - /libs/wcm/core/resources/languages

(Used as part of Translation/Translation projects)

Could you please elaborate your requirement/need for the availability of all language codes in OSGi service. 

Avatar

Community Advisor

Thanks @Vijayalakshmi_S  for the quick turn. 

My requirement is to import asset through custom utility into DAM. While importing i have to set languages dc:language to asset metadataschema.

For this purpose I need to get all possible languagesin my OSGI service.

Avatar

Correct answer by
Community Advisor

Thanks for the inputs @Aruna_surukunta_ 

Every enum constant is an instance of an enum class. Given the list of languages to consider, you can use the one from OOTB location that I shared accordingly. 

Avatar

Community Advisor

Hi @Aruna_surukunta_ 

 

  1. "I want to get all available language codes in AEM." - by this you mean the languages that the languages that your website have? if yes, please check this link: https://help.smartling.com/hc/en-us/articles/360008049933-AEM-Touch-Connector-Configure-Custom-Langu...
  2. To get the language in a service impl use the below code :getcurrentpage().getlanguage(false).getlanguage();. You can send the current page details to the serviceImpl using a servlet (via request object) or model (via currentPage object).

Hope this helps.

 

Thanks,

Kiran Vedantam.

Avatar

Community Advisor

Thanks @Kiran_Vedantam , Actually I 'm not using page here. I'm trying to import asset where I ned to add dc:language through OSGI service