Automating Localization: Scaling Multi-Language Ecosystems with mop tscan
In the world of high-end Rust web development, internationalization (i18n) is often treated as an afterthought—a secondary layer of complexity that slows down the creative process. Traditional workflows involve manually generating brittle keys (like auth.login.error_message), tracking them across dozens of YAML files, and hoping they don't drift from the actual source code.
As a Rust artisan, I refuse to settle for "good enough." My ecosystem requires a localization engine that is as precise, automated, and high-performance as the code it serves. This is why I built mop tscan— a specialized DevOps utility within the mop_cli that bridges the gap between raw source code and production-ready, multi-language support.
---
1. The "Source-as-Key" Philosophy
The core philosophy behind mop tscan is simplicity: the source code is the source of truth. Rather than inventing arbitrary keys, the system treats the literal development strings (typically in Italian for the mop_ ecosystem, but mixed languages are supported) as the unique identifiers.
By using the t!("...") macro in the frontend or backend, developers can write natural text directly in the UI components. mop tscan then employs a high-precision regex engine to crawl the entire workspace, extracting every invocation of the macro.
// In a Yew component
html! {
<button class="btn-primary">
{t!("Registrati ora per iniziare")}
</button>
}
This approach eliminates the "translation key mental tax," allowing me to focus on building features without context-switching to a localization spreadsheet.
---
2. Synchronized YAML Orchestration
Extracting strings is only half the battle. The real power of mop tscan lies in its ability to synchronize the ecosystem's state. When the command runs, it:
- Scans the Workspace: Iterates through
mop_frontend,mop_backend, and shared crates. - Analyzes Drift: Compares extracted strings against the existing
locales/*.ymlfiles. - Identity Mapping: For the development language (Italian), it automatically maps the key to itself, ensuring the source-of-truth file is always up to date.
- Missing Key Detection: It identifies which strings lack translations in target languages (English, German, French, etc.) and calculates real-time coverage statistics.
This automation ensures that no "translation hash" ever leaks into the production UI. If a string exists in the code, mop tscan ensures it exists in the localization layer.
---
3. The Gemini AI Translation Pipeline
To achieve true scale without manual overhead, I integrated mop tscan with the Gemini AI API. By passing the --ai flag, the tool transforms from a simple scanner into a fully automated translation pipeline.
# Auto-translate missing entries using Gemini
mop tscan --ai --ai-model gemini-3.1-flash-lite
The pipeline is meticulously engineered for reliability:
- Context-Aware: It sends chunks of untranslated strings to Gemini, using the development language as the reference.
- Automatic Rotation: If an API quota is hit (HTTP 429), the CLI automatically rotates through a list of fallback models (e.g., from Flash to Pro or Gemma) to ensure the job finishes.
- Validation: It fixes malformed YAML and ensures that special characters are correctly escaped, maintaining the structural integrity of the localization files.
---
4. Frictionless Developer Experience
mop tscan is designed for the terminal. It provides a clean, color-coded summary of the ecosystem's localization health, showing exactly how many strings are covered and how many are missing for each supported locale.
For manual refinement, the tool can export untranslated strings into a translated.csv format, allowing for quick bulk edits that can be re-imported with a single command. This hybrid approach—combining AI speed with human-in-the-loop precision—is what makes the mop_ ecosystem so robust.
---
Conclusion
Internationalization should be an asset, not a bottleneck. By automating the extraction, synchronization, and translation of UI strings, mop tscan allows the mop_dev infrastructure to scale across borders with absolute zero friction. It is a testament to what is possible when you apply the "Rust artisan" mindset to every corner of the development lifecycle.
This article is part of the MoP Dev Infrastructure series, documenting the custom tooling built to power high-performance web applications.