Package com.day.cq.wcm.api
Interface LanguageManager
-
public interface LanguageManagerProvides 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 interfaceLanguageManager.InfoInformation about a resource in a language tree.static interfaceLanguageManager.TreeEncapsulates information about language specific existences of resources in a tree.static interfaceLanguageManager.TreeNodeDenotes a node in the tree.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringIS_LANGUAGE_ROOT_PROP_NAMErelative path of the language root property of a hierarchy node.static java.lang.StringISO_PROP_NAMErelative 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.TreecompareLanguageTrees(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.LanguagegetCqLanguage(Resource res)Returns the language for the given resource.LanguagegetCqLanguage(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.StringgetIsoCountry(java.util.Locale language)Returns the country iso code for the given locale.java.util.LocalegetLanguage(Resource res)Returns the language for the given resource.java.util.LocalegetLanguage(Resource res, boolean respectContent)Returns the language for the given resource.PagegetLanguageRoot(Resource res)Returns the language root page for the given resource.PagegetLanguageRoot(Resource res, boolean respectContent)Returns the language root page for the given resource.ResourcegetLanguageRootResource(Resource res)Returns the language root resource for the given resource.ResourcegetLanguageRootResource(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 ofResourceobjects 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 ofResourceobjects 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
nullif 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
nullif 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
nullif 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
nullif 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,nullis returned unlessrespectContentistrue. then the resources ancestors (including the given) one is searched for aISO_PROP_NAMEproperty.- Parameters:
res- resourcerespectContent- iffalseonly the path is analyzed- Returns:
- the locale or
nullif 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,nullis returned unlessrespectContentistrue. then the resources ancestors (including the given) one is searched for aISO_PROP_NAMEproperty.- Parameters:
res- resourcerespectContent- iffalseonly the path is analyzed- Returns:
- the locale or
nullif 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
nullif not determinable
-
getLanguageRoot
@Nullable Page getLanguageRoot(Resource res, boolean respectContent)
Returns the language root page for the given resource. IfrespectContentistrue, then the resources ancestors (including the given one) are searched for aIS_LANGUAGE_ROOT_PROP_NAMEproperty. If the property istrue,ISO_PROP_NAMEis used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAMEproperty isfalseor theISO_PROP_NAMEproperty is not found orrespectContentisfalse, the path of the resource is analyzed to find a matching iso code. If no iso code can be found,nullis returned.- Parameters:
res- resourcerespectContent- iffalseonly the path is analyzed- Returns:
- the language root page or
nullif 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
nullif not determinable
-
getLanguageRootResource
@Nullable Resource getLanguageRootResource(Resource res, boolean respectContent)
Returns the language root resource for the given resource. IfrespectContentaretrue, then the resources ancestors (including the given one) is searched for aIS_LANGUAGE_ROOT_PROP_NAMEproperty. If the property istrue,ISO_PROP_NAMEis used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAMEproperty isfalseor theISO_PROP_NAMEproperty is not found orrespectContentisfalse, the path of the resource is analyzed to find a matching iso code. If no iso code can be found,nullis returned.- Parameters:
res- the resourcerespectContent- iffalseonly the path is analyzed- Returns:
- the language root resource or
nullif 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 ofResourceobjects which act as language roots for the resource at the given path.- Parameters:
resolver- aResourceResolverused 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 ofResourceobjects 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
IfrespectContentistrue, then the resources ancestors (including the given one) are searched for aIS_LANGUAGE_ROOT_PROP_NAMEproperty. If the property istrue,ISO_PROP_NAMEis used to determine language root. If theIS_LANGUAGE_ROOT_PROP_NAMEproperty isfalseor theISO_PROP_NAMEproperty is not found orrespectContentisfalse, 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- aResourceResolverused to access the repositorypath- the path of the current pagerespectContent- iffalseonly 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
-
-