How flakysl/translatable works
Project Type and Purpose
• This is an open-source Rust library (“translatable”) for internationalization (i18n), providing both compile-time and run-time translation lookup, ISO-639-1 language support, TOML-based translation files, and a compile-time procedural macro for validation and code generation.
File Structure Analysis
• Top-level crates/directories:
• translatable/ — the main library, exposes translation! macro, Language, and runtime API
• translatable_proc/ — the procedural-macro crate that parses translation files at compile time and generates Rust code
• translatable_shared/ — a shared library of data types, templating logic, common utilities used by both the macro and runtime crates
• translatable/tests/… — integration and unit tests for the main crate
• translatable.toml — user-provided configuration for file path, seek_mode, overlap
• translations/ — user translation files (TOML)
• CI/deployment files (.github/workflows, Makefile), cargo manifests (Cargo.toml, Cargo.lock), formatting, linting configs.
Insights from README
• The library provides macros for static and dynamic translations.
• It reads .toml translation files via a walk-dir algorithm.
• It performs compile-time checks for static parameters (language code validity, path existence) via the procedural macro.
• At run-time or dynamic paths, it returns Result<String, Error> with lazy error retrieval.
• It emphasizes ergonomics and extensibility (custom file structures, template replacements).