Class CmsTranslationUtil

java.lang.Object
org.opencms.ai.CmsTranslationUtil

public class CmsTranslationUtil extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • findOrCreateValue

      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 context
      content - the XML content
      locale - the locale in which to find/create the value
      path - 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 read
      xmlContent - the XML content
      Returns:
      the translatable values
    • getWaitMessage

      public static String getWaitMessage(Locale locale)
      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