Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

Translation in CF

Avatar

Level 2

Is there a way to serve localized content from Content Fragment. For country and language. Like I have an hierarchy us/en/ and I have de/de. Is there any OOB functionality for the same?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @ShamliKh ,

No problem. In GraphQL, AEM provides a locale parameter that allows you to serve content based on the locale, but not specifically by country. The system processes the hierarchy from the last segment and serves the corresponding content as soon as it identifies a matching locale.

For example, if your content fragment is located under hierarchies such as us/en/ or hk/en/, it will serve the content for the en locale. Similarly, if the hierarchy is de/de/, it will recognize the latter de as the locale and return the content specific to Germany. Even if the hierarchy is in/de/, the system will only consider the latter part of the path and serve content accordingly.

{
  carModelList(_locale: "de") {
    items {
      modelCd
    }
  }
}


Thanks,
Madhur Madan

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @ShamliKh ,

Could you please provide more clarity on if this question is directed towards content rendered via graphQL?

Thanks,
Madhur

Avatar

Level 2

Hi @Madhur-Madan ,

Sorry I might have missed it in my question but yes I want to know from an omnichannel perspective via GraphQL

Thanks,
Shamli

Avatar

Correct answer by
Community Advisor

Hi @ShamliKh ,

No problem. In GraphQL, AEM provides a locale parameter that allows you to serve content based on the locale, but not specifically by country. The system processes the hierarchy from the last segment and serves the corresponding content as soon as it identifies a matching locale.

For example, if your content fragment is located under hierarchies such as us/en/ or hk/en/, it will serve the content for the en locale. Similarly, if the hierarchy is de/de/, it will recognize the latter de as the locale and return the content specific to Germany. Even if the hierarchy is in/de/, the system will only consider the latter part of the path and serve content accordingly.

{
  carModelList(_locale: "de") {
    items {
      modelCd
    }
  }
}


Thanks,
Madhur Madan