Internationalization (i18n)
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Internationalization (i18n) system in the ElmecV2 project provides a structured framework for managing multi-language support across the mobile application. Built using the i18next library and integrated with react-i18next, the system centralizes UI strings, technical terminology for specialized modules (such as drilling and milling calculators), and general application settings.
The scope of the current implementation focuses on providing a robust foundation for Spanish (ES) as the primary language, with built-in mechanisms for fallback and interpolation. This system ensures that user interface elements, from basic loading screens to complex engineering calculation labels, remain consistent and easily translatable as the project scales.
Sources: i18n/index.ts:1-60, README.md:12-45
Core Architecture
The i18n architecture relies on a centralized configuration file that initializes the translation engine and defines the translation resources. It follows a modular structure where translations are categorized by application feature.
System Configuration
The system uses the i18next core instance extended by initReactI18next to bridge the translation logic with React components.
| Option | Value | Description |
|---|---|---|
Primary Language (lng) | 'es' | The default language set to Spanish. |
Fallback Language (fallbackLng) | 'es' | The backup language used if a key is missing. |
| Interpolation Escape | false | Disabled to allow React to handle XSS protection. |
Sources: i18n/index.ts:1-2, i18n/index.ts:54-60
Translation Resource Structure
Resources are organized into logical namespaces within the translation object, allowing for targeted string retrieval.
The diagram shows the hierarchical structure of translation keys used to categorize UI text based on application modules.
Sources: i18n/index.ts:5-52
Module-Specific Translations
Engineering Calculator Labels
A significant portion of the i18n system is dedicated to technical parameters for the Drilling (Barrenado) and Milling (Fresado) modules. These keys support the functional requirements identified in the project's technical documentation.
| Parameter Key | Spanish Translation | Description |
|---|---|---|
d | Diámetro (D) | Tool Diameter |
z | Número de filos (Z) | Number of flutes/edges |
n | Velocidad de giro (N) | Spindle speed |
vc | Velocidad de corte (Vc) | Cutting speed |
fz | Avance por filo (fz) | Feed per tooth |
vf | Velocidad de avance (Vf) | Feed rate |
tc | Tiempo de corte (Tc) | Machining time |
q | Tasa de remoción (Q) | Removal rate |
Sources: i18n/index.ts:24-52, VALIDACION-COMPLETA.md:65-72
General UI and Settings
The system handles standard application text to maintain a consistent user experience.
- General: Includes standard actions like
loading,back, andsettings. - Settings: Localized labels for measurement units (
medida) and speed (velocidad).
Sources: i18n/index.ts:8-23
Integration with Application Logic
The i18n system works alongside other core utilities such as the logging system to provide context-aware feedback. While translations handle the user-facing text, the Logger utility handles internal system states using environment variables to determine logging levels.
The sequence diagram illustrates how components retrieve translated strings while simultaneously interacting with the system's logging infrastructure.
Sources: i18n/index.ts:1-4, utils/logger.ts:32-45, TEST_REPORT.md:215-230
Technical Implementation Snippet
The following configuration initializes the internationalization environment for the mobile application:
// i18n/index.ts:54-62
i18n.use(initReactI18next).init({
resources,
lng: 'es',
fallbackLng: 'es',
interpolation: {
escapeValue: false, // react already safes from xss
},
});
Sources: i18n/index.ts:54-62
Summary
The Internationalization (i18n) module is a critical component of the ElmecV2-Demo project, providing the necessary infrastructure to handle multi-language technical data and general UI strings. By utilizing a key-value pair approach within i18next, the system ensures that complex engineering terms for drilling and milling are accurately represented to the end user while maintaining a clean separation between content and application logic.