Package org.opencms.ai
Class CmsTranslationUtil
java.lang.Object
org.opencms.ai.CmsTranslationUtil
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMetadata tag to disable translation for a content field.The XML content types that are considered translatable. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindOrCreateValue(CmsObject cms, CmsXmlContent content, Locale locale, String path) Helper method to either find an existing value for a given xpath or to try and create it, along with its parent values if necessary.static List<I_CmsXmlContentValue> getValuesToTranslate(CmsObject cms, CmsXmlContent m_xmlContent, Locale locale, Locale targetLocale) Collects the translatable XML values for the given locale.static StringgetWaitMessage(Locale locale) Gets the message to display to the user, while content is being translated (in HTML format).static booleanChecks if translation is disabled by schema settings for a specific content value.
-
Field Details
-
translatedTypes
The XML content types that are considered translatable. -
AGENT_TAG_NOTRANSLATE
Metadata tag to disable translation for a content field.- See Also:
-
-
Constructor Details
-
CmsTranslationUtil
public CmsTranslationUtil()
-
-
Method Details
-
findOrCreateValue
public static CmsTranslationUtil.FoundOrCreatedValue findOrCreateValue(CmsObject cms, CmsXmlContent content, Locale locale, String path) throws Exception Helper method to either find an existing value for a given xpath or to try and create it, along with its parent values if necessary.The result object contains both the value and an indication whether it was created or found.
Note that this method will fail with an exception when the value can neither found nor created. This can happen if its creation would conflict with pre-existing values in the content, e.g. choice values with different choices than that indicated by the given path.
- Parameters:
cms- the CMS contextcontent- the XML contentlocale- the locale in which to find/create the valuepath- the xpath of the value to find/create- Returns:
- the result, containing both the value and a flag which indicates whether a pre-existing value was found or whether it had to be created
- Throws:
Exception- if something goes wrong
-
getValuesToTranslate
public static List<I_CmsXmlContentValue> getValuesToTranslate(CmsObject cms, CmsXmlContent m_xmlContent, Locale locale, Locale targetLocale) Collects the translatable XML values for the given locale.- Parameters:
locale- the locale to readxmlContent- the XML content- Returns:
- the translatable values
-
getWaitMessage
Gets the message to display to the user, while content is being translated (in HTML format).- Parameters:
locale- the workplace locale- Returns:
- the message
-
isTranslationDisabledInSchema
Checks if translation is disabled by schema settings for a specific content value.- Parameters:
val- the content value- Returns:
- true if translation is disabled
-