Interface Translator

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Translator
Strategy for translating a piece of text from one language to another, used by LocalizedField to fill in the language versions the user has not typed in themselves.

The interface is intentionally independent of any particular translation backend: implement it with an online translation service, a large language model (e.g. via Spring AI), a dictionary, or anything else. Implementations are allowed to block (do network I/O); LocalizedField invokes them off the UI thread and applies the results via UI.access(...).

  • Method Summary

    Modifier and Type
    Method
    Description
    translate(String text, Locale from, Locale to)
    Translates the given text.
  • Method Details

    • translate

      String translate(String text, Locale from, Locale to)
      Translates the given text.
      Parameters:
      text - the text to translate, never null
      from - the language of text
      to - the language to translate into
      Returns:
      the translated text