How to get website page locale code? | Community
Skip to main content
October 16, 2015
Solved

How to get website page locale code?

  • October 16, 2015
  • 3 replies
  • 6372 views

Hi there,

There is a difficulty case to me:  i wonder if there is a API to get locale code. E.g., when i get node "/content/geometrixx/fr/products/square",  the API could return the "fr"(french); and when i get node "/content/geometrixx/en/services/banking", the api could return the "en" (English). 

Anyone could help that? Thanks a lot.

 

Br,

Brian

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

3 replies

Alex_Popov1Accepted solution
Level 4
October 16, 2015
October 16, 2015

It works, thank you so much.

But i wonder the principle that get the page locale information, and where do it find the language and counrtry of page exactly? I guess maybe one property saved that page locale information? Could you comment details? Thanks a lot.

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Hi,

The API documentation says:

Returns the content language of the page. 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. If ignoreConent is true, only the names of the path is used to determine the language. Note that this has nothing to do with i18n of the cq5 itself.

The "jcr:language" property is supposed to be on the "jcr:content" node on a page. And the methods checks if the page contains this property on its jcr:content node. If it isn't there, all ancestor pages are checked as well. And then some other assumptions kick in (like trying to interprete the parts of the paths as ISO codes).

Jörg