java.lang.Object
net.i2p.router.web.helpers.NetDbRenderer.AgoMemo
Enclosing class:
NetDbRenderer

static class NetDbRenderer.AgoMemoextends Object
Memoized "{0} ago" translations.

Translate.getString(String, I2PAppContext, String) rebuilds a MessageFormat and re-parses the pattern on every call, and a full /netdb page asks for this text once or twice per router row. Keying on the already-formatted duration string is therefore exact and callers may pass dynamic ages freely.

Entries are dropped wholesale when the UI language changes; a race between two render threads can only cost a redundant translation, never a wrong result.

  • Constructor Details

    • AgoMemo

      AgoMemo()
      A memo table holding nothing; _lang stays null until the first ago(String, String, Function) call, which compares it against the current UI language and clears the table.
  • Method Details

    • ago

      String ago(String duration, String lang, java.util.function.Function<String,String> format)
      Render an age as a localized "duration ago" string.
      Parameters:
      duration - the age, already run through DataHelper.formatDuration2(long)
      lang - the current UI language
      format - the translator to memoize
      Returns:
      the localized "<duration> ago", or null if either argument was null