FallbackLocaleFormatter

A locale-independent LocaleFormatter: ASCII separators, English names, English plural rules.

This is not a locale implementation and does not claim to be one. It is what the four locale-sensitive functions do when nobody has chosen a locale, chosen so that their output is predictable rather than plausible: 1234.5 is 1,234.5 here on every target and in every environment, which is what makes the evaluator's own behaviour testable. SymbolLocaleFormatter is what a host uses instead once it wants a locale.

Its output is English-shaped rather than root-shaped on purpose. CLDR's root locale has a single plural category and numeric month names, which would make pluralize and formatDate produce output no renderer would ship. Approximating en-US at least produces something a developer can read while recognising it as a placeholder.

Functions

Link copied to clipboard
open override fun formatCurrency(value: Double, currency: String, decimals: Int?, grouping: Boolean): String

USD 1,234.50 — the code and the amount, since no symbol table is available here.

Link copied to clipboard
open override fun formatDate(epochMillis: Long, pattern: String): String

The instant epochMillis rendered with the Unicode TR35 pattern pattern.

Link copied to clipboard
open override fun formatNumber(value: Double, decimals: Int?, grouping: Boolean): String

value as a decimal string.

Link copied to clipboard
open override fun pluralCategory(value: Double): PluralCategory

The English rule, |n| == 1 → PluralCategory.ONE.