Copyright© 2008-2026 Sitevision AB, all rights reserved.
@Requireable(value="TranslationUtil") public interface TranslationUtil
An instance of the Sitevision class implementing this interface can be obtained via
Utils.getTranslationUtil().
See Utils for how to obtain an instance of the Utils interface.
| Modifier and Type | Method and Description |
|---|---|
List<Locale> |
getSiteTranslationLocales()
Gets a list of all Locales that are set up for translations on the current site.
|
Node |
getTranslatedFrom(Node aPageNode)
Gets the page node a given node is potentially translated from (the translation source).
|
Map<Locale,Node> |
getTranslations(Node aPageNode,
boolean aIncludePageNode)
Gets the translation mappings for a given page node.
|
boolean |
setTranslatedFrom(Node aOriginalPageNode,
Node aTranslationPageNode)
Sets the translated from node to the page node provided as translation node.
|
List<Locale> getSiteTranslationLocales()
Note! The returned List is immutable/unmodifiable, i.e. you must create a copy if you want to modify it (e.g. sort).
Map<Locale,Node> getTranslations(Node aPageNode, boolean aIncludePageNode)
Each entry in the returned map depicts a "translation", i.e. a localized version of the given aPageNode.
Important note! The returned map is never null, but entry values in the map might be!
PermissionUtil.Permission.READ permissions on the node.
Tip! If you are only interested in non-null Nodes/values in the returned map, you can use
NodeFilterUtil to filter them out!
Below is a conceptual example of how it could be done in server-side JavaScript (e.g. WebApp, RESTApp, Script module).
var thePotentiallyTranslatedPageNode = ...,
translationUtil = require('TranslationUtil'),
nodeFilterUtil = require('NodeFilterUtil'),
translationMappings,
skipNullValuesFilter,
filteredTranslationMappings;
translationMappings = translationUtil.getTranslations(thePotentiallyTranslatedPageNode, false);
skipNullValuesFilter = nodeFilterUtil.getNonNullFilter();
filteredTranslationMappings = nodeFilterUtil.getFilteredValueMap(translationMappings, skipNullValuesFilter);
Please note that determining the "is this page node translated at all?" state from the returned result
depends on the aIncludePageNode value:
false, an empty map will be returned.
true, a map with one entry (i.e. the aPageNode itself) will be returned.
aPageNode - a page node that can be translatedaIncludePageNode - whether or not to include aPageNode in the resultNode getTranslatedFrom(Node aPageNode)
aPageNode - the page node that is translatedPermissionUtil.Permission.READ permissions on the from node.boolean setTranslatedFrom(Node aOriginalPageNode, Node aTranslationPageNode)
Permission note! Current user must match have
PermissionUtil.Permission.MANAGE_TRANSLATIONS and
PermissionUtil.Permission.WRITE
on @aTranslationPageNode.
aOriginalPageNode - the original page node to be configured as translated from on aTranslationPageNode. It will be configured as
original in aTranslationPageNode as well if aOriginalPageNode doesn't have any original configured.aTranslationPageNode - the translation page node to be configured as translation of aOriginalPageNodeSitevision - Content Management Made Easy
Sitevision is an advanced Java enterprise portal product that implements Java Content Repository (JSR 283).
Copyright© 2008-2026 Sitevision AB, all rights reserved.