Class Translations


  • public class Translations
    extends java.lang.Object
    Represents a class, holding translations for a specific language.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull Translations get​(@NotNull TranslationFile translationFile, @NotNull java.lang.String language)
      Retrieves a new Translations instance with the specified TranslationFile
      static @NotNull Translations get​(@NotNull java.io.InputStream in, @NotNull java.lang.String language)
      Retrieves a new Translations which are bound to the ".properties" file type.
      static @NotNull Translations get​(@NotNull java.io.Reader reader, @NotNull java.lang.String language)
      Retrieves a new Translations which are bound to the ".properties" file type.
      @NotNull java.util.Collection<java.lang.String> getKeys()
      Returns a immutable collection of the translation keys
      @NotNull java.lang.String getLanguage()
      Returns the language of the translations held
      @NotNull java.lang.String getTranslation​(@NotNull java.lang.String key, @Nullable java.lang.Object... args)
      Retrieves the translation, held by the specified key.
      @NotNull java.lang.String getTranslationFileType()
      Returns the file type, where the translations are stored.
      • Methods inherited from class java.lang.Object

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

      • get

        @NotNull
        public static @NotNull Translations get​(@NotNull
                                                @NotNull TranslationFile translationFile,
                                                @NotNull
                                                @NotNull java.lang.String language)
        Retrieves a new Translations instance with the specified TranslationFile
        Parameters:
        translationFile - translation file
        language - language of the translations
        Returns:
        translations
      • get

        @NotNull
        public static @NotNull Translations get​(@NotNull
                                                @NotNull java.io.InputStream in,
                                                @NotNull
                                                @NotNull java.lang.String language)
                                         throws java.io.IOException
        Retrieves a new Translations which are bound to the ".properties" file type.
        Parameters:
        in - a ".properties" resource's input stream
        language - the language of these translations
        Returns:
        translations
        Throws:
        java.io.IOException - if an i/o error occurs
      • get

        @NotNull
        public static @NotNull Translations get​(@NotNull
                                                @NotNull java.io.Reader reader,
                                                @NotNull
                                                @NotNull java.lang.String language)
                                         throws java.io.IOException
        Retrieves a new Translations which are bound to the ".properties" file type.
        Parameters:
        reader - a ".properties" resource's reader
        language - the language of these translations
        Returns:
        translations
        Throws:
        java.io.IOException - if an i/o error occurs
      • getTranslation

        @NotNull
        public @NotNull java.lang.String getTranslation​(@NotNull
                                                        @NotNull java.lang.String key,
                                                        @Nullable
                                                        @Nullable java.lang.Object... args)
        Retrieves the translation, held by the specified key.
        Parameters:
        key - the key of the translation you want to get
        args - the arguments to replace in the translation
        Returns:
        translation, or a message saying that it is missing
      • getKeys

        @NotNull
        public @NotNull java.util.Collection<java.lang.String> getKeys()
        Returns a immutable collection of the translation keys
        Returns:
        keys
      • getTranslationFileType

        @NotNull
        public @NotNull java.lang.String getTranslationFileType()
        Returns the file type, where the translations are stored.
        Returns:
        file type
      • getLanguage

        @NotNull
        public @NotNull java.lang.String getLanguage()
        Returns the language of the translations held
        Returns:
        language