Skip to main content

Crate rlvgl_i18n

Crate rlvgl_i18n 

Source
Expand description

Thin compile-time i18n for rlvgl.

Translations are stored in locales/*.json, compiled to a compact binary blob at build time, and embedded via include_bytes!. Use the t! macro to look up strings:

use rlvgl_i18n::t;

let label = t!("demo.plugins");              // &'static str
let msg   = t!("demo.clicks", count = 42);   // String

§Binary blob format (RLTN v1)

The .bin file produced by the build is self-contained and can be copied to an SD card or flash partition. Call load_translations at runtime to override the built-in blob with one loaded from media.

[0..4]   magic   b"RLTN"
[4]      version 1
[5]      num_locales
[6..8]   num_keys   (u16 LE)
[8..]    entries    (num_locales × num_keys) × 6 bytes:
           offset: u32 LE  (into string data region)
           len:    u16 LE
[..]     string data  (UTF-8, packed)

Macros§

t
Translate a key, optionally with parameters.

Enums§

Key
Locale

Functions§

builtin_blob
Return a reference to the built-in binary translation blob.
load_translations
Override the built-in translations with a blob loaded from media.
locale
Return the currently active locale.
locale_from_u8
set_locale
Set the active locale for all subsequent t!() calls.
t_format
Format a translation template by replacing {name} placeholders.
t_static
Look up a plain (non-parameterized) translation for the current locale.