Class I18nizableText

    • Constructor Detail

      • I18nizableText

        public I18nizableText​(String label)
        Create a simple international text
        Parameters:
        label - The text. Cannot be null.
      • I18nizableText

        public I18nizableText​(String catalogue,
                              String key)
        Create an i18nized text
        Parameters:
        catalogue - the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.
        key - the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.
      • I18nizableText

        public I18nizableText​(String catalogue,
                              String key,
                              List<String> parameters)
        Create an i18nized text with ordered parameters.
        Parameters:
        catalogue - the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.
        key - the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.
        parameters - the parameters of the key if any. Can be null.
      • I18nizableText

        public I18nizableText​(String catalogue,
                              String key,
                              Map<String,​I18nizableTextParameter> parameters)
        Create an i18nized text with named parameters.
        Parameters:
        catalogue - the catalogue where the key is defined. Can be null. Can be overloaded by the catalogue in the key.
        key - the key of the text. Cannot be null. May include the catalogue using the character ':' as separator. CATALOG:KEY.
        parameters - the named parameters of the message, as a Map of name -> value. Value can itself be an i18n key but must not have parameters.
      • I18nizableText

        public I18nizableText​(String catalogueLocation,
                              String catalogueFilename,
                              String key)
        Create an i18nized text. Use this constructor only when the catalogue is an external catalogue, not managed by Ametys application
        Parameters:
        catalogueLocation - the file location URI of the catalogue where the key is defined.
        catalogueFilename - the catalogue bundle name such as 'messages'
        key - the key of the text. Cannot be null.
      • I18nizableText

        public I18nizableText​(String catalogueLocation,
                              String catalogueFilename,
                              String key,
                              List<String> parameters)
        Create an i18nized text with ordered parameters. Use this constructor only when the catalogue is an external catalogue, not managed by Ametys application
        Parameters:
        catalogueLocation - the file location URI of the catalogue where the key is defined.
        catalogueFilename - the catalogue bundle name such as 'messages'
        key - the key of the text. Cannot be null.
        parameters - the parameters of the key if any. Can be null.
      • I18nizableText

        public I18nizableText​(String catalogueLocation,
                              String catalogueFilename,
                              String key,
                              Map<String,​I18nizableTextParameter> parameters)
        Create an i18nized text with named parameters.
        Parameters:
        catalogueLocation - the file location URI of the catalogue where the key is defined.
        catalogueFilename - the catalogue bundle name such as 'messages'
        key - the key of the text. Cannot be null.
        parameters - the named parameters of the message, as a Map of name -> value. Value can itself be an i18n key but must not have parameters.
    • Method Detail

      • isI18n

        public boolean isI18n()
        Determine whether the text is i18nized or a simple cross languages text.
        Returns:
        true if the text is i18nized and so defined by a catalogue, a key and optionaly parameters.
        false if the text is a simple label
      • getCatalogue

        public String getCatalogue()
        Get the catalogue of the i18nized text.
        Returns:
        The catalogue where the key is defined
      • getLocation

        public String getLocation()
        Get the file location URI of the i18nized text.
        Returns:
        The catalog location where the key is defined
      • getBundleName

        public String getBundleName()
        Get the files name of catalog
        Returns:
        bundle name
      • getKey

        public String getKey()
        Get the key of the i18nized text.
        Returns:
        The key in the catalogue
      • getParameters

        public List<StringgetParameters()
        Get the parameters of the key of the i18nized text.
        Returns:
        The list of parameters' values or null if there is no parameters
      • getLabel

        public String getLabel()
        Get the label if a text is not i18nized.
        Returns:
        The label
      • getI18nizableTextValue

        public static I18nizableText getI18nizableTextValue​(Configuration config,
                                                            String defaultCatalogue,
                                                            String value)
        Get an i18n text configuration (can be a key or a "direct" string).
        Parameters:
        config - The configuration to parse.
        defaultCatalogue - The i18n catalogue to use when not specified.
        value - The i18n text, can be a key or a "direct" string.
        Returns:
        The i18nizable text or null if the config is null
      • parseI18nizableText

        public static I18nizableText parseI18nizableText​(Configuration config,
                                                         String catalogueLocation,
                                                         String catalogueFilename,
                                                         String defaultValue)
                                                  throws ConfigurationException
        Parse a i18n text configuration.
        Parameters:
        config - the configuration to use.
        catalogueLocation - The i18n catalog location URI
        catalogueFilename - The i18n catalog bundle name
        defaultValue - The default value key in configuration
        Returns:
        the i18n text or null if the config is null
        Throws:
        ConfigurationException - if the configuration is not valid.
      • parseI18nizableText

        public static I18nizableText parseI18nizableText​(Configuration config,
                                                         String defaultCatalogue,
                                                         String defaultValue)
        Parse an optional i18n text configuration, with a default value.
        Parameters:
        config - the configuration to use.
        defaultCatalogue - the i18n catalogue to use when not specified.
        defaultValue - the default value key in configuration.
        Returns:
        the i18n text or null if the config is null
      • parseI18nizableText

        public static I18nizableText parseI18nizableText​(Configuration config,
                                                         String defaultCatalog,
                                                         I18nizableText defaultValue)
        Parse an optional i18n text configuration, with a default i18n text value.
        Parameters:
        config - the configuration to use.
        defaultCatalog - the i18n catalog to use when not specified.
        defaultValue - the default i18n text value.
        Returns:
        the i18n text or null if the config is null
      • i18nizableTextToString

        public static String i18nizableTextToString​(I18nizableText i18nizableText)
        Gets a string representation of a i18n text
        Parameters:
        i18nizableText - The i18 text
        Returns:
        The string representation of the i18n text
      • stringToI18nizableText

        public static I18nizableText stringToI18nizableText​(String str)
        Returns the i18n text from its string representation
        Parameters:
        str - The string representation of the i18n text
        Returns:
        The i18n text