Class I18nTextResourceHandler

    • Method Detail

      • getLocale

        protected String getLocale​(Map<String,​Object> additionalParameters)
        Retrieve the locale from the parameters
        Parameters:
        additionalParameters - The parameters
        Returns:
        The locale, or null
      • _testI18nDeclarationPrefix

        private boolean _testI18nDeclarationPrefix​(char[] srcChars,
                                                   int start)
        Test if the given character is the start of an i18n declaration
        Parameters:
        srcChars - the input file as characters
        start - the index of the given character
        Returns:
        true if this is a start of an i18n declaration, false otherwise
      • _analyzeI18nDeclaration

        private int _analyzeI18nDeclaration​(char[] srcChars,
                                            int candidateBeginIdx,
                                            BufferedWriter outWriter,
                                            int initialOffset,
                                            Source source,
                                            Parameters par,
                                            Map<String,​Object> additionalParameters)
                                     throws IOException
        Analyze characters from the key beginning index to the possible closure sequence '}}', and write the appropriate replacement in the output string builder
        Parameters:
        srcChars - the input file as characters
        candidateBeginIdx - the index at which we started analyzing a viable i18n declaration
        outWriter - the buffered writer where we store the output string
        initialOffset - the initial offset
        source - The source using the i18n
        par - The declaration parameters
        additionalParameters - The additional parameters
        Returns:
        the amount of analyzed characters
        Throws:
        IOException - if an error occurs while writing the output
      • _translateKey

        private void _translateKey​(char[] srcChars,
                                   BufferedWriter outWriter,
                                   int candidateBeginIdx,
                                   int lastIdx,
                                   int initialOffset,
                                   String locale,
                                   Parameters par)
                            throws IOException
        Try to translate the key and write the output stream with its translation if found, the key itself if not
        Parameters:
        srcChars - the input source as characters
        outWriter - the string builder where to write
        candidateBeginIdx - the index at which the i18n declaration started
        lastIdx - the last index analyzed
        initialOffset - the amount of characters that we have to write before the i18n declaration
        locale - The locale to use
        par - The declaration parameters
        Throws:
        IOException - if an error occurs while writing the output