ACS Commons Localized Generic List

As part of this tutorial, we will look in to the implementation of localized generic list to support multiple languages as shown below.

Implementation

We will be following below steps to create localized generic list.

  1. To support required languages, create an overlay from /libs/wcm/core/resources/languages to /apps/wcm/core/resources/languages as shown below.

Add below entry as part of filter.xml to overlay language structure as part of ui.apps:

Add below entry if not available as part of pom.xml file inside ui.apps.structure

/apps/wcm

2. Override OSGI configurations to enable localization and allow require languages: 

com.adobe.acs.commons.mcp.impl.McpLocalizationServiceImpl.cfg.json

{
"overlayedLanguagesResourcePath" : "/apps/wcm/core/resources/languages",
"localizationEnabled" : true
}

3. Now, try to create a generic list will provide lacalized fields also as part of it as show n below:

Make sure to set and enable French or other languages as part of root language node /content/practice/us/fr as shown below:

Backend code to access generic list localized text

Follow below backend code to access localized text given as part of generic list:

public void printGenericListLocalizedTitle(Locale locale, String value,
    ResourceResolver resourceResolver) {
    if (resourceResolver != null) {
        PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
        if (nonNull(pageManager)) {
            Page listPage = pageManager.getPage("/etc/acs-commons/lists/practice/global/interests");
            GenericList list = listPage.adaptTo(GenericList.class);
            for (GenericList.Item item : list.getItems()) {
                if (StringUtils.equalsIgnoreCase(item.getValue(), value) &&
                        StringUtils.isNotEmpty(item.getTitle(locale))) {
                    LOG.error("Localized Title = {}", item.getTitle(locale));
                }
            }
        }
    }
}

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan