Interface Locales


public interface Locales
The display locale, which the application may change while it runs. A singleton.

The locale starts as the choice saved by an earlier run, else the launch's DisplayLocale. A change switches the Resources to the new locale, refreshes the open windows with the UI module, then changes current(), and saves the choice to locale.toml in the application's config directory.

  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the display locale.
    <M> M
    messages(Class<M> type, Locale locale)
    Returns an implementation of a @Messages interface that reads the files of a locale, whatever the display locale.
    void
    Changes the display locale back to the launch's DisplayLocale, as set(Locale) does, and deletes the saved choice.
    void
    set(Locale locale)
    Changes the display locale, and saves the choice.
  • Method Details

    • current

      Observable<Locale> current()
      Returns the display locale.
      Returns:
      the observable locale
    • set

      void set(Locale locale)
      Changes the display locale, and saves the choice. It may be called from any thread, and hands the change to the UiExecutor. A locale equal to the current one changes nothing.
      Parameters:
      locale - the new locale
      Throws:
      NullPointerException - if locale is null
    • reset

      void reset()
      Changes the display locale back to the launch's DisplayLocale, as set(Locale) does, and deletes the saved choice.
    • messages

      <M> M messages(Class<M> type, Locale locale)
      Returns an implementation of a @Messages interface that reads the files of a locale, whatever the display locale. It is cached per type and locale.
      Type Parameters:
      M - the type of the messages
      Parameters:
      type - the @Messages interface
      locale - the locale of the messages
      Returns:
      the messages in that locale
      Throws:
      NullPointerException - if an argument is null
      IllegalArgumentException - if type is not a @Messages interface compiled by swing's processor