PolyglotReferenceValueLocalizer

A generic PolyglotLocalizer that accepts a value of type T and a Zoned<Instant> reference point, and returns a TickingValue of type String.

The TickingValue.nextTick represent the amount of time that the reference needs to advance by for the TickingValue.value to change, thus requiring a new call to localize with the same exact value but updated reference, assuming that the time moves forward linearly.

If you are using coroutines, a convenience localizeAsFlow is also provided.

Note that any class implementing this interface is not strictly required to return the same exact string for the same value in different platforms.

Inheritors

Functions

Link copied to clipboard
abstract fun localize(value: T, reference: Zoned<Instant>): TickingValue<String>
Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localize(value: T, clock: Clock = Clock.System): TickingValue<String>

Localizes value by using the given clock's Clock.now as a reference point, rather than passing the reference explicitly.

Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localizeAsFlow(value: T, clock: Clock = Clock.System, maxTick: Duration? = null): Flow<String>

Localizes value by using the given clock's Clock.now as a reference point and returns a Flow that emits updated values based on the underlying TickingValue.nextTick. This function assumes that the given clock moves forward linearly.