gen fn i18n(dir: String) -> String
Read every <locale>.json under dir, check the locales, and return the translation module's source.
Type to search, or try , or .
1 export, from std/i18n.vyrn.
Typed translations as a generator library.
import { i18n } from "std/i18n" import { t, setLocale, locale, Locale, TransKey, tCartItems } from i18n("./locales")
i18n(dir) reads every <locale>.json under dir at compile time, checks that the locales agree, compiles each ICU message to a Vyrn function body and returns the module as source text (vyrn emit-gen <file> shows it). The module holds Locale (one variant per file), setLocale/locale, TransKey (the finite type of every dotted key), one function per key with arguments taken from the message and the base-locale message as its doc, t(key), and transKey(s), which checks a runtime String against the key set.
The ICU subset: plain text; {name} (String); {n, plural, ...} (Int64, # is the number, other required); {k, select, ...} (a finite string type of the branch names). '' is a literal apostrophe, '{' and '}' literal braces. An argument name may not start with __. Numbers, booleans and null in a locale file, and a plural or select nested in a branch, fail generation.
The import graph shows the whole library.
gen fn i18n(dir: String) -> String
Read every <locale>.json under dir, check the locales, and return the translation module's source.
19 test blocks in std/i18n.vyrn. CI runs all of them.
3 programs in examples/ import this module. Each runs as WebAssembly and as a native binary.