Expand my Community achievements bar.

SOLVED

How to add a website translation to an "unofficial" language in AEM 6.5 if this language does not have an ISO code?

Avatar

Level 2

Hi everyone,

 

We have a multilingual project in AEM 6.5 in which we need to show pages in the following languages:

 

  • Spanish
  • English
  • French
  • Catalan
  • Basque
  • Galician
  • Valencian

 

All of these languages but Valencian have ISO codes.

 

Valencian is linguistically considered a variant of Catalan language but politically it is considered an independent language in Spain. (https://en.wikipedia.org/wiki/Valencian_language).

 

In Java it is identified with the variant code "ca_ES_VALENCIA".

 

We have organized our project using the following tree:

 

  • /content/client
    • language-masters
      • es
      • en
      • fr
      • ca
      • eu
      • gl
      • va
    • es
    • en
    • fr
    • ca
    • eu
    • gl
    • va

 

We are using i18n dictionaries in json format and all of them but for Valencian are working fine.

 

This was expected as AEM only supports OOTB ISO languages.

 

We now need to make it work for Valencian. How could we do this?

 

We have found some promissing documentation regarding adding languages to AEM but it has not worked as expected.

 

We have followed these steps to add Valencian as a language in AEM (https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-msm...) and indeed we can now set the "language" property (jcr:language) of a page (/content/client/language-masters/va) as Valencian.

 

apps_wcm_core_resources_languages_va.png

A screenshot showing that we have Valencian as an available language.

 

content_client_language-masters_va_jcr-content.png

A screenshot showing we can set the jcr:language property of a page to "va".

 

The problem is that com.day.cq.wcm.api.Page.getLanguage() is not returning "va" (getting it from the path nor from the property) but "es_ES", the value of my request's "Accept-Language" header.

 

In the official documentation for this method (https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/api/Pa...) it says:

 

"The language is usually defined on the page content via a jcr:language property containing the iso codes for language and country. if the property is not defined on this page all ancestors are search for such an property. If no language is defined at all, the path is examined if it contains a iso label. If no language can be found at all, the systems default locale is returned. Note that this has nothing to do with i18n of the cq5 itself."

 

So, how could we do it for Valencian to work as any other language in AEM 6.5?

 

Thanks in advance.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If the Valencian does not have an ISO code, then the limitation goes beyond AEM. This becomes tricky if JAVA does not support this ISO, so I think you need to use a workaround to implement this solution. Below are some ideas you could use:

 

- Use a different language in the "jcr:language" and treat this as if it was Valencian. You will have to adjust the backend and most likely the dispatcher configs to properly match the other language to "va"

- Extend the languages as you were doing to add the Valencian language, then manually create your own getLanguage() method which will get manually the "jcr:language" and check firstly if your value is "va" to return your expected value otherwise just let the original getLanguage() method to run. 

 

Hopefully, it gives you some insights.



Esteban Bustamante

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

If the Valencian does not have an ISO code, then the limitation goes beyond AEM. This becomes tricky if JAVA does not support this ISO, so I think you need to use a workaround to implement this solution. Below are some ideas you could use:

 

- Use a different language in the "jcr:language" and treat this as if it was Valencian. You will have to adjust the backend and most likely the dispatcher configs to properly match the other language to "va"

- Extend the languages as you were doing to add the Valencian language, then manually create your own getLanguage() method which will get manually the "jcr:language" and check firstly if your value is "va" to return your expected value otherwise just let the original getLanguage() method to run. 

 

Hopefully, it gives you some insights.



Esteban Bustamante