All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.addc.commons.i18n.Translator Maven / Gradle / Ivy

Go to download

The addc-base library supplies classes for creating UUIDs, converting between types, outputting byte arrays with different formats, support for Julian dates, delay generators, parsing properties files and support for I18N.

There is a newer version: 2.6
Show newest version
package com.addc.commons.i18n;

import java.util.Locale;

/**
 * The Translator interface defines the contract for classes that translate
 * texts depending on either the current locale or a specific locale set on the
 * implementing class.
 */
public interface Translator {

    /**
     * Translate a text. if no translation is available return the original
     * text.
     * 
     * @param text
     *            The text to translate
     * @return The translated text or the original if no translation is
     *         available
     */
    String translate(String text);

    /**
     * Translate a text and replace place holders with the replacements
     * 
     * @param pattern
     *            A MessageFormat style pattern text to translate
     * @param replacements
     *            A variable list of replacements for the placeholders in the
     *            translated text
     * @return The translated text with replacements
     */
    String translate(String pattern, Object... replacements);

    /**
     * Changes the locale used to look for the translation of the texts passed
     * to the class.
     * 
     * @param locale
     *            The locale to set
     * @return reference to this translator instance with the new locale set
     */
    Translator setLocale(Locale locale);

    /**
     * Get the locale currently in use.
     * 
     * @return the locale currently in use.
     */
    Locale getLocale();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy