Interface Translator

    • Method Detail

      • parseLocale

        @Nullable
        static @Nullable java.util.Locale parseLocale​(@NotNull
                                                      @NotNull java.lang.String string)
        Parses a Locale from a String.
        Parameters:
        string - the string
        Returns:
        a locale
        Since:
        4.0.0
      • name

        @NotNull
        @NotNull Key name()
        A key identifying this translation source.

        Intended to be used for display to users.

        Returns:
        an identifier for this translation source
        Since:
        4.0.0
      • translate

        @Nullable
        @Nullable java.text.MessageFormat translate​(@NotNull
                                                    @NotNull java.lang.String key,
                                                    @NotNull
                                                    @NotNull java.util.Locale locale)
        Gets a message format from a key and locale.

        When used in the GlobalTranslator, this method is called only if translate(TranslatableComponent, Locale) returns null.

        Parameters:
        locale - a locale
        key - a translation key
        Returns:
        a message format or null to skip translation
        Since:
        4.0.0
      • translate

        @Nullable
        default @Nullable Component translate​(@NotNull
                                              @NotNull TranslatableComponent component,
                                              @NotNull
                                              @NotNull java.util.Locale locale)
        Gets a translated component from a translatable component and locale.
        Parameters:
        locale - a locale
        component - a translatable component
        Returns:
        a translated component or null to use translate(String, Locale) instead (if available)
        Since:
        4.13.0