Expand my Community achievements bar.

Provide Javascript API to retrieve single translations

Avatar

8/9/21

Request for Feature Enhancement (RFE) Summary: There is an OOTB function CQ.I18n.getDictionary() to get translations, but it always gets the whole dictionary to the UI, which puts much load on the visitor's browser. This reuest is to provide a function that retrieves only the requested translations. E.g. it could accept key name(s) and language name as parameters.
Use-case: Use localized strings in custom JS code on user-facing pages.
Current/Experienced Behavior:  
Improved/Expected Behavior:  
Environment Details (AEM version/service pack, any other specifics if applicable): AEM 6.5 with SP8
Customer-name/Organization name: Veeam Software
Screenshot (if applicable):  
Code package (if applicable):  
2 Comments

Avatar

Employee Advisor

9/6/21

Hi @Alexander_Prikhodko 

 

Thanks for proposing the idea.

This request has been raised to the product team via the Jira CQ-4331470. The product team will triage this request to verify feasibility based on the prioritization model. This post will be updated according to the Jira request status.

 

Thanks,

Akash

Status changed to: Investigating

Avatar

Community Advisor

11/5/21

Hi @Alexander_Prikhodko 

Could you please check if below code fulfill your requirement?

if (CQ && CQ.I18n) {
CQ.I18n.setLocale("de_DE");
var localizedMessage = CQ.I18n.getMessage("Go");
console.log(localizedMessage)
}