ui/i18n_locale.rs#
Source: lib/ui/i18n_locale.rs
i18n_locale -- regional formats (a compact subset of CLDR) and plural categories
Locale::get(tag) -> Locale the best match of a BCP 47 tag: the tag itself, the
language with the region, the language's default
("de" -> de-DE, "en" -> en-US), else "en-001"
locale() / set_locale(tag) / locale_tag() the user's format: ui boots it from
jfgui_LANG, the system (window mode) or "de-DE"
(headless runs, so shots match on every machine)
loc.fmt_int(n) "1.234.567" (de), "1,234,567" (en), "12,34,567" (hi)
loc.fmt_num(v, decimals) fixed decimals, rounded; grouped
loc.fmt_percent(fraction, decimals) 0.25 -> "25 %" (de), "25%" (en), "%25" (tr)
loc.fmt_currency(v, "USD") / fmt_money(v) "1.234,56 $" (de), "$1,234.56" (en-US);
fmt_money in the locale's own currency
loc.fmt_size(bytes) "1,5 MB" (1024 based; French "Mo")
loc.fmt_date(&civil, DATE_SHORT | DATE_LONG) / fmt_time(&civil) / fmt_date_time(&civil)
"17.10.2026" / "17. Oktober 2026" / "19:58";
en-US "10/17/2026" / "October 17, 2026" / "7:58 PM"
loc.first_weekday() (0 = Monday .. 6 = Sunday), rtl(), decimal(), group(), currency(), tag()
fmt_int / fmt_num / fmt_percent / fmt_currency / fmt_money / fmt_size / fmt_date /
fmt_time / fmt_date_time the same with locale()
plural(lang, i, v, f) / plural_int(lang, n) -> Plural CLDR cardinal categories (i the
integer digits, v the number of visible fraction
digits, f those digits as an integer)
Numbers use ASCII digits everywhere (also Arabic and Hindi); spaces inside numbers and
before units are no-break spaces (U+00A0, French U+202F). Long dates use the format
(genitive) month names of the locale's language.
/// fmt_date: "17.10.2026" / "10/17/2026"
DATE_SHORT: u32 = 0
/// fmt_date: "17. Oktober 2026" / "October 17, 2026"
DATE_LONG: u32 = 1
struct Localethe formats of one region (copy it freely)
impl Locale
fn get(tag: &str) -> Localethe best match of a BCP 47 tag or a POSIX locale name (see the module comment)fn tag(&self) -> &'static strthe tag of the matched data ("de-DE", "en-001")fn decimal(&self) -> charthe decimal signfn group(&self) -> charthe thousands separatorfn first_weekday(&self) -> u32the first day of the week: 0 = Monday .. 6 = Sundayfn rtl(&self) -> boolright-to-left script (Arabic, Hebrew)fn currency(&self) -> &'static strthe ISO 4217 code of the region's currencyfn month_name(&self, m: u32) -> &'static strthe long (format) name of month m (1..12) in the locale's languagefn fmt_int(&self, n: i64) -> Stringan integer with group separatorsfn fmt_num(&self, v: f64, decimals: u32) -> Stringa number with exactlydecimalsfraction digits (rounded) and group separatorsfn fmt_percent(&self, fraction: f64, decimals: u32) -> Stringa fraction as percent: 0.25 -> "25 %" (de) / "25%" (en)fn fmt_currency(&self, v: f64, code: &str) -> Stringan amount of the ISO 4217 currencycode("EUR", "USD"; unknown codes are shown as is)fn fmt_money(&self, v: f64) -> Stringan amount in the region's own currencyfn fmt_size(&self, bytes: u64) -> Stringa byte count: "512 B", "1,5 KB", "23 MB" (1024 based, one decimal below 10)fn fmt_date(&self, c: &Civil, style: u32) -> Stringa date: DATE_SHORT "17.10.2026" / DATE_LONG "17. Oktober 2026"fn fmt_time(&self, c: &Civil) -> Stringa time of day: "19:58" / "7:58 PM"fn fmt_date_time(&self, c: &Civil) -> Stringthe short date and the time: "17.10.2026, 19:58" / "10/17/2026, 7:58 PM"fn locale() -> Localethe user's regional format (default "de-DE")fn locale_tag() -> Stringthe tag the format was asked for ("de-LU" may use the data of "de-DE")fn set_locale(tag: &str)set the user's regional format (a BCP 47 tag or a POSIX locale name)fn fmt_int(n: i64) -> StringLocale::fmt_int in the user's formatfn fmt_num(v: f64, decimals: u32) -> StringLocale::fmt_num in the user's formatfn fmt_percent(fraction: f64, decimals: u32) -> StringLocale::fmt_percent in the user's formatfn fmt_currency(v: f64, code: &str) -> StringLocale::fmt_currency in the user's formatfn fmt_money(v: f64) -> StringLocale::fmt_money in the user's formatfn fmt_size(bytes: u64) -> StringLocale::fmt_size in the user's formatfn fmt_date(c: &Civil, style: u32) -> StringLocale::fmt_date in the user's formatfn fmt_time(c: &Civil) -> StringLocale::fmt_time in the user's formatfn fmt_date_time(c: &Civil) -> StringLocale::fmt_date_time in the user's formatenum Plurala CLDR plural categoryZeroOneTwoFewManyOther
impl Plural
fn name(self) -> &'static strthe CLDR keyword: "zero", "one", "two", "few", "many", "other"fn plural_int(lang: &str, n: i64) -> Pluralthe plural category of an integer in a language ("de", "ru-RU", ...)fn plural(lang: &str, i: u64, v: u32, f: u64) -> Pluralthe plural category of a number: i = its integer digits, v = the number of visible fraction digits, f = those digits as an integer ("1,50": i 1, v 2, f 50)