Class Translations

  • All Implemented Interfaces:
    java.io.Serializable

    public class Translations
    extends java.lang.Object
    implements java.io.Serializable
    This class hold the translations and options for translation of a single report (Engine).
    Since:
    9.1
    See Also:
    Engine.getTranslations(), Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.util.Locale> getAvailableLocales()
      Get a list of all available translation locales in this report.
      java.util.ResourceBundle getResourceBundle​(java.util.Locale locale)
      Request a resource bundle for translation the current report.
      java.lang.String getResourceBundleName()
      Get the base name of the ResourceBundle
      java.util.Properties getTranslation​(java.util.Locale locale)
      Request the property of a translation for the given locale.
      boolean isUseParagraph()
      Get the flag useParagraph.
      void setResourceBundleName​(java.lang.String name)
      Set an optional ResourceBundle.
      void setTranslation​(java.util.Locale locale, java.util.Properties props)
      Set a new translation for the current report/engine or remove it.
      void setUseParagraph​(boolean useParagraph)
      Set the flag useParagraph.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getResourceBundle

        public java.util.ResourceBundle getResourceBundle​(java.util.Locale locale)
        Request a resource bundle for translation the current report. This include the report translations if available else global resources. The resulting ResourceBundle is cascaded. The search order is:
        • saved translations in this report
        • resource bundle of the report
        • global language resource
        Parameters:
        locale - the locale for which a resource bundle is desired, can not be null
        Returns:
        the resource bundle if one find, else null
        Since:
        9.1
      • getTranslation

        public java.util.Properties getTranslation​(java.util.Locale locale)
        Request the property of a translation for the given locale. The locale must match exactly.
        Parameters:
        locale - the locale for which a translation is desired, can not be null
        Returns:
        the properties if one find, else null
        Since:
        9.1
        See Also:
        getAvailableLocales(), setTranslation(Locale, Properties)
      • setTranslation

        public void setTranslation​(java.util.Locale locale,
                                   java.util.Properties props)
        Set a new translation for the current report/engine or remove it. This override an existing translation for the given locale. The translation is saved together with the report file. You can reused the Properties after the call.
        Parameters:
        locale - the locale of the translation
        props - the new key/value pairs. The required keys can be request via Translator.listLabels(boolean). A value of null remove it.
        Since:
        9.1
        See Also:
        getTranslation(Locale)
      • getAvailableLocales

        public java.util.List<java.util.Locale> getAvailableLocales()
        Get a list of all available translation locales in this report.
        Returns:
        the available locales or an empty list, never null
        Since:
        9.1
        See Also:
        setTranslation(Locale, Properties)
      • setUseParagraph

        public void setUseParagraph​(boolean useParagraph)
        Set the flag useParagraph. If this flag is set then every paragraph will translate in one step. In the other case every text part of the paragraph will be translate separately. If you translate a paragraph in one step then you need also to set the placeholder for fields and needed formating in the translation.
        Parameters:
        useParagraph - the value of the flag useParagraph.
        Since:
        9.1
        See Also:
        isUseParagraph(), Translator.listLabels(boolean)
      • isUseParagraph

        public boolean isUseParagraph()
        Get the flag useParagraph. This flag control if a paragraph should translate in a single step or every text part separately. This has only an effect if your paragraphs has more then one part (FieldPart or TextPart).
        Returns:
        true, if a paragraph is translate in one step
        Since:
        9.1
        See Also:
        setUseParagraph(boolean)
      • setResourceBundleName

        public void setResourceBundleName​(java.lang.String name)
        Set an optional ResourceBundle. The bundle must be available in the class path. A separate ResourceBundle give you possibility to use a single ResourceBundle for multiple reports but not the need for all report like the global LanguageResource.
        Parameters:
        name - the base name of the ResourceBundle or null
        Since:
        9.1
        See Also:
        getResourceBundleName()
      • getResourceBundleName

        public java.lang.String getResourceBundleName()
        Get the base name of the ResourceBundle
        Returns:
        the name or null
        Since:
        9.1
        See Also:
        setResourceBundleName(String)