Skip to main content

Module i18n

Module i18n 

Source

Structs§

LocaleTestGuard
RAII guard returned by test_lock(). Holds the serialisation mutex AND restores the locale that was current at lock-acquire time. Field declaration order matters: original (with its Drop impl below) drops before _guard, so the locale is restored while the lock is still held — the next waiter never sees a transient mixed state.

Enums§

Locale
Msg

Functions§

current_locale
Return the current global locale. Falls back to Locale::En if the RwLock is poisoned.
resolve_initial_locale
Determine the initial locale from (in priority order): CLI --lang flag, config file language field, environment variables LC_ALL / LC_MESSAGES / LANG.
set_locale
Switch the global locale used by t. Silently no-ops if the RwLock is poisoned.
t
Translate a message using the current global locale.
t_with
Look up against an explicit locale.
test_lock
Serialization lock for tests that mutate the global locale. Prevents test races when multiple tests call set_locale, AND restores the original locale on guard drop so a test that flips to ZhCn doesn’t leak into the next test that assumes the default En.