Class I18nLocalizer

java.lang.Object
com.gufli.brick.i18n.common.localization.I18nLocalizer
Direct Known Subclasses:
HytaleLocalizer, MinimessageLocalizer

public class I18nLocalizer extends Object
  • Field Details

    • registry

      protected final I18nRegistry registry
    • defaultLocale

      protected final Locale defaultLocale
    • id

      protected final String id
  • Constructor Details

    • I18nLocalizer

      public I18nLocalizer(String id, Locale defaultLocale)
  • Method Details

    • registerConverter

      public <T> void registerConverter(Class<T> type, Function<T,Object> converter)
    • id

      public final String id()
    • localize

      public final String localize(Locale locale, String key, Object... args)
    • localize

      public final String localize(Locale locale, String key)
    • localizeOptional

      public final String localizeOptional(Locale locale, String key, Object... args)
    • localizeOptional

      public final String localizeOptional(Locale locale, String key)
    • localize

      public final String localize(Locale locale, Duration duration, DurationFormatter formatter)
      This will replace the following time placeholders with their respective localization:
      • Y - duration.year
      • M - duration.month
      • D - duration.day
      • h - duration.hour
      • m - duration.minute
      • s - duration.second
      Parameters:
      locale - the locale to use
      duration - the duration to format
      formatter - the formatter to use
      Returns:
      the translated and formatted duration
    • localize

      public final String localize(Locale locale, Duration duration)
    • recursiveLocalize

      public final String recursiveLocalize(Locale locale, String str)
      This method will replace any keys that are found with its localized value. It will then return the resulting string. If no keys are found, this will return the given string exactly.
      Parameters:
      locale - the locale to use for localization
      str - the string to localize
      Returns:
      the localized string
    • registerLocale

      public final void registerLocale(Path path) throws MalformedURLException
      Throws:
      MalformedURLException
    • registerLocale

      public final void registerLocale(URL resource)
    • registerLocale

      public final void registerLocale(URL resource, Locale locale)
    • registerLocaleMessage

      protected void registerLocaleMessage(Locale locale, String key, MessageFormat messageFormat)