Documentation
¶
Overview ¶
Package i18n is lys-shell's Fluent localization: a port of the runtime the Rust crates get from i18n-embed 0.16 (FluentLanguageLoader), fluent-bundle 0.16, fluent-syntax 0.12, and fluent-langneg 0.13.
Three domains exist, as in Rust:
- the shell domain (crates/wayle-shell-core/src/i18n.rs, the t!/td! macros): bar labels, dropdowns, OSD, notification popups. T and Attr read it.
- the settings domain (crates/wayle-i18n/src/lib.rs, t/t_attr): the config's field labels, which lys-settings adds its own messages to (ConfigAssets). Settings returns it.
- the greeter domain (crates/lys-greeter/src/i18n.rs, t!): the login screen's labels. Greeter returns it.
Each domain negotiates the desktop locale (LANGUAGE, LC_ALL, LC_MESSAGES, LANG) against its embedded locales once, on first use, with en-US as the always-loaded fallback. Lookups fall through the negotiated languages in order; a missing message yields i18n-embed's "No localization for id" marker rather than an empty string.
Interpolated placeables are wrapped in Unicode isolation marks (U+2068 ... U+2069) exactly as fluent-bundle does by default, which i18n-embed never turns off.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Fallback = MustLangID("en-US")
Fallback is the fallback language both lys-shell domains declare in their i18n.toml.
Functions ¶
Types ¶
type Arg ¶
type Arg struct {
// contains filtered or unexported fields
}
Arg is one named Fluent argument, built with Str, Int, or Float.
type Assets ¶
type Assets struct {
// contains filtered or unexported fields
}
Assets is an embedded locale tree: top-level locale directories holding `_*.ftl` partials at any depth.
func ConfigAssets ¶ added in v0.3.5
func ConfigAssets() Assets
ConfigAssets is the config's field labels and common messages, for a program that edits the config and adds messages of its own.
func NewFileAssets ¶
NewFileAssets wraps a locale tree holding one file per locale, <locale>/<file>.
func (Assets) Available ¶
Available lists the locales that carry at least one partial, sorted like rust-embed's file list, with the fallback first when missing (i18n-embed's available_languages).
type LangID ¶
type LangID struct {
// contains filtered or unexported fields
}
LangID is a Unicode language identifier as unic-langid 0.9 parses it: a lowercase language ("" is und), an optional titlecase script, an optional uppercase region, and sorted, deduplicated variants.
func ParseLangID ¶
ParseLangID ports unic-langid's parse_language_identifier: subtags split on '-' or '_', case-normalized; anything past the variants (an extension, an empty subtag) is an error.
func RequestedLanguages ¶ added in v0.3.5
func RequestedLanguages() []LangID
RequestedLanguages is the desktop locale's languages, as every domain negotiates them.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is i18n-embed's FluentLanguageLoader over one embedded locale tree: the negotiated languages' bundles in preference order, the en-US fallback last.
func Greeter ¶
func Greeter() *Loader
Greeter returns the greeter-domain loader (lys-greeter's loader()).
func Select ¶
Select negotiates the requested languages against the available ones (i18n_embed::select: fluent-langneg filtering, en-US default) and loads the result, fallback last. It is an error only when the fallback itself has no partials.
func Settings ¶
func Settings() *Loader
Settings returns the settings-domain loader (wayle-i18n's loader()).
func Shell ¶
func Shell() *Loader
Shell returns the shell-domain loader (wayle-shell-core's loader()).
func (*Loader) Attr ¶
Attr formats a message attribute from the first bundle that has it, or returns i18n-embed's missing-attribute marker.
func (*Loader) Get ¶
Get formats a message's value from the first bundle that has one, or returns i18n-embed's `No localization for id: "<id>"` marker.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
locales
|
|
|
greeter
Package locales embeds the greeter's Fluent file.
|
Package locales embeds the greeter's Fluent file. |
|
settings
Package locales embeds the config schema's Fluent partials, which lys-settings reads through i18n.ConfigAssets.
|
Package locales embeds the config schema's Fluent partials, which lys-settings reads through i18n.ConfigAssets. |
|
shell
Package locales embeds the shell's Fluent partials: the bar, its dropdowns, the lock screen, the OSD and the notification surfaces.
|
Package locales embeds the shell's Fluent partials: the bar, its dropdowns, the lock screen, the OSD and the notification surfaces. |