Skip to content

xdvi/l10n4x

Repository files navigation

l10n4x

Language C-FFI License CI

Modern, Dynamic, and Type-Safe Localization (l10n) Engine and Toolkit in Rust.

l10n4x compiles translation bundles into compressed .lpk files, loads them dynamically in any runtime, and generates type-safe bindings for Go, TypeScript/React, C/C++, Python, and Flutter/Dart.


Install

Download prebuilt binaries from GitHub Releases. Each platform bundle includes l10n4x, l10n4c (shared library), and l10n4c.h with standard names:

Platform Bundle
Linux l10n4x-linux-amd64.tar.gz
macOS l10n4x-macos-universal.tar.gz
Windows l10n4x-windows-amd64.zip
WASM l10n4x.wasm

No Rust toolchain required for consumers. Building from source is optional (for contributors).

Examples

Example Path
Go examples/go
Python examples/python
C# examples/csharp
Flutter examples/flutter
TypeScript (SSR) examples/typescript

Smoke-test all examples (builds l10n4c, compiles fixture lpks, runs each binding):

./scripts/verify.sh

Toolkit

Command Description
l10n4x build Compile .lpk files and generate bindings (CI-safe)
l10n4x build --dry-run Validate keys without writing output
l10n4x dev Hot-reload dev server
l10n4x validate Check key consistency

JSON flattening rules

Nested objects are flattened with dot notation. Arrays follow two distinct rules:

Primitive arrays (strings, numbers, booleans) are stored as a single JSON literal at the array key:

{ "menu": { "items": ["Home", "Settings"] } }

menu.items = ["Home","Settings"]

Object arrays require semantic keys inside each element — numeric index keys are not supported:

{ "menu": { "items": [{ "home": "Home" }, { "settings": "Settings" }] } }

menu.items.home = Home, menu.items.settings = Settings


C-FFI: l10n4c

Header: packages/ffi/l10n4c.h

Interpolation uses typed L10n4cParam { key, value } arrays — no JSON parsing in the FFI layer.

L10n4cParam params[] = { { "name", "Diego" } };
char *out = l10n4c_translate_with_params_alloc("en", "welcome", params, 1);
l10n4c_free_string(out);

.lpk files are signed (Ed25519, mandatory). Optional AES-GCM encryption ("encrypt": true) wraps the signed lpk for confidentiality — see docs/LPK_FORMAT.md and docs/THREAT_MODEL.md.


Documentation

Document Description
Enterprise Adoption Governance, CI/CD, namespaces, OTA
Architecture Data flow and package layout
Roadmap P2 backlog and shipped milestones
l10n4x-js Official @l10n4x/react and @l10n4x/runtime packages

Testing

cargo test --workspace
cargo clippy --workspace -- -D warnings
cargo bench -p l10n4x-core

About

A simple, memory-efficient internationalization engine in Rust. It compiles localization assets into a compressed binary layout for zero-copy lookups and supports lock-free reloads, memory-safe C-FFI bindings, and standard ICU MessageFormat 2.0.

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages