Class TranslatorUtils

java.lang.Object
org.hippoecm.frontend.i18n.TranslatorUtils

public class TranslatorUtils extends Object
  • Field Details

  • Method Details

    • getTemplateNode

      public static Node getTemplateNode(Node typeNode) throws TranslatorException
      Get the first node of type 'frontend:plugincluster' under the 'editor:templates' node
      Parameters:
      typeNode - a node of type 'editor:templates'
      Returns:
      the template node or thrown exceptions
      Throws:
      RepositoryException
      TranslatorException - if either no child node of type 'frontend:plugincluster' is found, typeNode is null or not the type 'editor:templates'.
    • getExceptionTranslation

      public static org.apache.wicket.model.IModel<String> getExceptionTranslation(org.apache.wicket.Component component, Throwable t, Object... parameters)
      Create a model containing the translated message for the given exception and its parameters. The message will be loaded from the resource properties files of either component or exception class with following syntax:
       
        exception,type\=${exception-class-path},message\=${exception-message}=<your-localized-message>
       
       
      Parameters:
      component - the component having translated resource files
      t - the throwable exception
      parameters - parameters used in the message template storing in resource files
      Returns:
      A model for the translated exception message.
    • getExceptionTranslation

      public static org.apache.wicket.model.IModel<String> getExceptionTranslation(Class clazz, Throwable t, Object... parameters)
      Create a model containing the translated message for the given exception and its parameters. The message will be loaded from a class's resource properties files with following syntax:
       
        exception,type\=${exception-class-path}
       
       
      This method was created due to CMS-9656, where the GalleryUploadPanel failed to retrieve messages from its own resource bundle due to an intricate inheritance structure. Using the clazz instead of a component circumvents the inheritance structure as far as necessary.
      Parameters:
      clazz - the class having translated resource files
      t - the throwable exception
      parameters - parameters used in the message template storing in resource files
      Returns:
      A model for the translated exception message.