Documentation
¶
Overview ¶
Package i18n looks up the text that ncly and its extensions show a human in their message catalogs, and formats numbers, sizes, and dates for the active language. Every catalog entry carries a description that tells a translator where the text appears.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Pseudo = language.MustParse("en-XA")
Pseudo is the pseudo-locale: every catalog string, marked between ⟦ and ⟧, so a scenario finds the text that bypasses the catalog.
Functions ¶
func CheckCatalogs ¶
CheckCatalogs applies the catalog rules of SDK in contract.md to the catalogs at the top of fsys: every entry has a description, and every language holds exactly the IDs of en. A non-empty domain, an extension's, also requires every ID to start with the domain and a dot.
Types ¶
type CatalogError ¶
CatalogError reports an en catalog that is missing, unreadable, or not a catalog. Line is 0 when the parser does not say where.
func (*CatalogError) Error ¶
func (e *CatalogError) Error() string
func (*CatalogError) Unwrap ¶
func (e *CatalogError) Unwrap() error
type Catalogs ¶
type Catalogs struct {
// contains filtered or unexported fields
}
Catalogs holds the catalogs of one or more owners, such as the SDK and core, or the SDK and an extension: for each owner, one file per language, named after its tag, such as en.toml or fr-CA.toml. Each owner's en catalog is required, and the pseudo-locale marks it.
func Load ¶
Load reads the catalogs at the top of each folder. Only each en catalog must be valid: a translation that cannot be read is skipped, so its entries fall back to en. The owners' IDs never overlap, as the catalog rules require, so the order of the folders does not matter.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer returns catalog text and formats values in one language.
func (*Printer) Date ¶
Date formats a day as ISO 8601, such as 2026-10-06, in every language: it reads the same in English and is the Canadian French standard.
func (*Printer) N ¶
N returns the plural form of the message id that fits count, with data filling its template. Count in the template is always count, formatted.
func (*Printer) Number ¶
Number formats v with at most the given decimals, such as 1,234.5 in English and 1 234,5 in Canadian French.