Package com.day.cq.wcm.api
Interface LanguageManager
-
@ProviderType public interface LanguageManager
Provides a service for content languages. Note that this has nothing to do with the i18n of the WCM itself.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
LanguageManager.Info
Information about a resource in a language tree.static interface
LanguageManager.Tree
Encapsulates information about language specific existences of resources in a tree.static interface
LanguageManager.TreeNode
Denotes a node in the tree.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
IS_LANGUAGE_ROOT_PROP_NAME
relative path of the language root property of a hierarchy node.static java.lang.String
ISO_PROP_NAME
relative path of the language property of a hierarchy node.
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description LanguageManager.Tree
compareLanguageTrees(ResourceResolver resolver, java.lang.String path)
Compares language trees using the language of the page at the given path as main language.java.util.Map<java.util.Locale,LanguageManager.Info>
getAdjacentInfo(ResourceResolver resolver, java.lang.String path)
Deprecated.java.util.Map<Language,LanguageManager.Info>
getAdjacentLanguageInfo(ResourceResolver resolver, java.lang.String path)
Returns a map of language information for each language filled with information if respective hierarchy or content exists for that language.Language
getCqLanguage(Resource res)
Returns the language for the given resource.Language
getCqLanguage(Resource res, boolean respectContent)
Returns the language for the given resource.java.util.Collection<Language>
getCqLanguages(ResourceResolver resolver, java.lang.String path)
Returns a collection of root languages for the given page.java.lang.String
getIsoCountry(java.util.Locale language)
Returns the country iso code for the given locale.java.util.Locale
getLanguage(Resource res)
Returns the language for the given resource.java.util.Locale
getLanguage(Resource res, boolean respectContent)
Returns the language for the given resource.Page
getLanguageRoot(Resource res)
Returns the language root page for the given resource.Page
getLanguageRoot(Resource res, boolean respectContent)
Returns the language root page for the given resource.Resource
getLanguageRootResource(Resource res)
Returns the language root resource for the given resource.Resource
getLanguageRootResource(Resource res, boolean respectContent)
Returns the language root resource for the given resource.java.util.Collection<Resource>
getLanguageRootResources(ResourceResolver resolver, java.lang.String path)
Returns a collection ofResource
objects which act as language roots for the resource at the given path.java.util.Collection<Resource>
getLanguageRootResources(ResourceResolver resolver, java.lang.String path, boolean respectContent)
Returns a collection ofResource
objects which act as language roots for the resource at the given path.java.util.Collection<Page>
getLanguageRoots(ResourceResolver resolver, java.lang.String path)
Returns a collection of language root pages for the given page.java.util.Collection<java.util.Locale>
getLanguages(ResourceResolver resolver, java.lang.String path)
Deprecated.usegetCqLanguages(ResourceResolver, String)
instead.
-
-
-
Field Detail
-
ISO_PROP_NAME
static final java.lang.String ISO_PROP_NAME
relative path of the language property of a hierarchy node.- See Also:
- Constant Field Values
-
IS_LANGUAGE_ROOT_PROP_NAME
static final java.lang.String IS_LANGUAGE_ROOT_PROP_NAME
relative path of the language root property of a hierarchy node.- See Also:
- Constant Field Values
-
-
Method Detail
-
getIsoCountry
java.lang.String getIsoCountry(java.util.Locale language)
Returns the country iso code for the given locale. if the country is not already defined in the locale a configured default value is returned. If no iso code exists, an empty string is returned.- Parameters:
language
- the language locale to retrieve the country from- Returns:
- a country iso code or ""
-
getAdjacentInfo
java.util.Map<java.util.Locale,LanguageManager.Info> getAdjacentInfo(ResourceResolver resolver, java.lang.String path)
Deprecated.Returns a map of language information for each language filled with information if respective hierarchy or content exists for that language.- Parameters:
resolver
- resource resolverpath
- path to check- Returns:
- map of information or
null
if the given path does not reside on or below a language root. - See Also:
LanguageUtil.getLanguageRoot(String)
-
getAdjacentLanguageInfo
java.util.Map<Language,LanguageManager.Info> getAdjacentLanguageInfo(ResourceResolver resolver, java.lang.String path)
Returns a map of language information for each language filled with information if respective hierarchy or content exists for that language.- Parameters:
resolver
- resource resolverpath
- path to check- Returns:
- map of information or
null
if the given path does not reside on or below a language root. - Since:
- 5.4
- See Also:
LanguageUtil.getLanguageRoot(String)
-
getLanguage
java.util.Locale getLanguage(Resource res)
Returns the language for the given resource. Note that this method only uses the path names for the determination of the language.- Parameters:
res
- resource- Returns:
- the locale or
null
if not determinable
-
getCqLanguage
Language getCqLanguage(Resource res)
Returns the language for the given resource. Note that this method only uses the path names for the determination of the language.- Parameters:
res
- resource- Returns:
- the locale or
null
if not determinable - Since:
- 5.4
-
getLanguage
java.util.Locale getLanguage(Resource res, boolean respectContent)
Returns the language for the given resource. The path of the resource is analyzed to find a matching iso code. If no iso code can be found,null
is returned unlessrespectContent
istrue
. then the resources ancestors (including the given) one is searched for aISO_PROP_NAME
property.- Parameters:
res
- resourcerespectContent
- iffalse
only the path is analyzed- Returns:
- the locale or
null
if not determinable - Since:
- 5.4
-
getCqLanguage
Language getCqLanguage(Resource res, boolean respectContent)
Returns the language for the given resource. The path of the resource is analyzed to find a matching iso code. If no iso code can be found,null
is returned unlessrespectContent
istrue
. then the resources ancestors (including the given) one is searched for aISO_PROP_NAME
property.- Parameters:
res
- resourcerespectContent
- iffalse
only the path is analyzed- Returns:
- the locale or
null
if not determinable - Since:
- 5.4
-
getLanguageRoot
Page getLanguageRoot(Resource res)
Returns the language root page for the given resource. Note that currently only the path names are respected for the determination of the language.- Parameters:
res
- resource- Returns:
- the language root page or
null
if not determinable
-
getLanguageRoot
@Nullable Page getLanguageRoot(Resource res, boolean respectContent)
Returns the language root page for the given resource. IfrespectContent
istrue
, then the resources ancestors (including the given one) are searched for aIS_LANGUAGE_ROOT_PROP_NAME
property. If the property istrue
,ISO_PROP_NAME
is used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAME
property isfalse
or theISO_PROP_NAME
property is not found orrespectContent
isfalse
, the path of the resource is analyzed to find a matching iso code. If no iso code can be found,null
is returned.- Parameters:
res
- resourcerespectContent
- iffalse
only the path is analyzed- Returns:
- the language root page or
null
if not determinable - Since:
- 6.4
-
getLanguageRootResource
Resource getLanguageRootResource(Resource res)
Returns the language root resource for the given resource. Note that currently only the path names are respected for the determination of the language.- Parameters:
res
- the resource- Returns:
- the language root resource or
null
if not determinable
-
getLanguageRootResource
@Nullable Resource getLanguageRootResource(Resource res, boolean respectContent)
Returns the language root resource for the given resource. IfrespectContent
aretrue
, then the resources ancestors (including the given one) is searched for aIS_LANGUAGE_ROOT_PROP_NAME
property. If the property istrue
,ISO_PROP_NAME
is used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAME
property isfalse
or theISO_PROP_NAME
property is not found orrespectContent
isfalse
, the path of the resource is analyzed to find a matching iso code. If no iso code can be found,null
is returned.- Parameters:
res
- the resourcerespectContent
- iffalse
only the path is analyzed- Returns:
- the language root resource or
null
if not determinable - Since:
- 6.4
-
getLanguages
java.util.Collection<java.util.Locale> getLanguages(ResourceResolver resolver, java.lang.String path)
Deprecated.usegetCqLanguages(ResourceResolver, String)
instead.Returns a collection of root languages for the given page. Note that only the path names are respected for the determination of the language.- Parameters:
resolver
- resource resolverpath
- path of the current page- Returns:
- collection of root languages
-
getCqLanguages
java.util.Collection<Language> getCqLanguages(ResourceResolver resolver, java.lang.String path)
Returns a collection of root languages for the given page. Note that only the path names are respected for the determination of the language.- Parameters:
resolver
- resource resolverpath
- path of the current page- Returns:
- collection of root languages
- Since:
- 5.4
-
getLanguageRoots
java.util.Collection<Page> getLanguageRoots(ResourceResolver resolver, java.lang.String path)
Returns a collection of language root pages for the given page. Note that only the path names are respected for the determination of the language.- Parameters:
resolver
- resource resolverpath
- path of the current page- Returns:
- collection of language root paths
-
getLanguageRootResources
java.util.Collection<Resource> getLanguageRootResources(ResourceResolver resolver, java.lang.String path)
Returns a collection ofResource
objects which act as language roots for the resource at the given path.- Parameters:
resolver
- aResourceResolver
used to access the repositorypath
- the path of the current page- Returns:
- a collection of language root resources
-
getLanguageRootResources
java.util.Collection<Resource> getLanguageRootResources(ResourceResolver resolver, java.lang.String path, boolean respectContent)
Returns a collection ofResource
objects which act as language roots for the resource at the given path. For example, consider the following structure where language roots would be searched a level up or down./content/example/language-masters +-- en +-- emea | +-- de | +-- fr +-- apac | +-- ko | +-- zh-cn
IfrespectContent
istrue
, then the resources ancestors (including the given one) are searched for aIS_LANGUAGE_ROOT_PROP_NAME
property. If the property istrue
,ISO_PROP_NAME
is used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAME
property isfalse
or theISO_PROP_NAME
property is not found orrespectContent
isfalse
, the path of the resource is analyzed to find a matching iso code. Implementation may choose to optimize for certain type of hierarchies.- Parameters:
resolver
- aResourceResolver
used to access the repositorypath
- the path of the current pagerespectContent
- iffalse
only the path is analyzed- Returns:
- a collection of language root resources
- Since:
- 6.4
-
compareLanguageTrees
LanguageManager.Tree compareLanguageTrees(ResourceResolver resolver, java.lang.String path)
Compares language trees using the language of the page at the given path as main language.- Parameters:
resolver
- resource resolvedpath
- path to resource to start from- Returns:
- the tree information
-
-