java.lang.Object
net.i2p.router.web.helpers.NetDbRenderer.AgoMemo
- Enclosing class:
NetDbRenderer
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 Summary
ConstructorsConstructorDescriptionAgoMemo()A memo table holding nothing; _lang stays null until the firstago(String, String, Function)call, which compares it against the current UI language and clears the table.Method Summary
All Methods
Constructor Details
AgoMemo
AgoMemo()A memo table holding nothing; _lang stays null until the firstago(String, String, Function)call, which compares it against the current UI language and clears the table.
Method Details
ago
Render an age as a localized "duration ago" string.- Parameters:
duration- the age, already run throughDataHelper.formatDuration2(long)lang- the current UI languageformat- the translator to memoize- Returns:
- the localized "<duration> ago", or null if either argument was null