How to get country and language codes in OSGI service | Community
Skip to main content
Anny0505
Community Advisor
Community Advisor
September 22, 2021
Solved

How to get country and language codes in OSGI service

  • September 22, 2021
  • 2 replies
  • 2567 views

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

Thanks,

Aruna

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijayalakshmi_S

Thanks for the inputs @anny0505 

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. 

2 replies

Vijayalakshmi_S
Level 10
September 22, 2021

Hi @anny0505,

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. 

Anny0505
Community Advisor
Anny0505Community AdvisorAuthor
Community Advisor
September 22, 2021

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.

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
September 22, 2021

Thanks for the inputs @anny0505 

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. 

Kiran_Vedantam
Community Advisor
Community Advisor
September 22, 2021

Hi @anny0505 

 

  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-Language
  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.

Anny0505
Community Advisor
Anny0505Community AdvisorAuthor
Community Advisor
September 22, 2021

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