Internationalization (i18n)
Relevant source files
The following files were used as context for generating this wiki page:
The Ever Teams platform employs a comprehensive internationalization (i18n) strategy to support multiple languages across its web, mobile, and desktop applications. The system is designed to be adaptable, using different file formats and structures tailored to each platform's technology stack. The core of the i18n system relies on key-value pairs stored in language-specific files, which are then accessed within the application components to display localized text.
The web application utilizes next-intl for its i18n capabilities, while the mobile application has a custom testing script to ensure all translation keys are present. The desktop application uses a flat JSON structure for its translations. Language preference is persisted for users via a cookie named auth-active-language.
Cross-Platform i18n Architecture
The project maintains separate i18n implementations for its web, mobile, and desktop applications, each with its own set of translation files and structure.
| Platform | Translation Format | Example File | Key Structure |
|---|---|---|---|
| Web | TypeScript Object | apps/web/core/lib/i18n/en.ts | Nested objects (pages.home.BREADCRUMB) |
| Mobile | TypeScript Object | apps/mobile/app/i18n/fr.ts | Nested objects (loginScreen.name) |
| Desktop | JSON | apps/desktop/i18n/en.json | Nested objects with uppercase keys (BUTTONS.ADD) |
Sources: apps/web/core/lib/i18n/en.ts, apps/mobile/app/i18n/fr.ts, apps/desktop/i18n/en.json
Language Configuration
Global language settings are defined in the web application's constants. This includes the list of supported languages, their codes, and corresponding flags for UI components.
- Default Language:
en - Supported Language Codes:
en,fr,ar,bg,zh,nl,de,he,it,pl,pt,ru,es - Language Persistence: The active language is stored in a cookie named
auth-active-language.
Sources: apps/web/core/constants/config/constants.tsx:210-226, apps/web/core/constants/config/constants.tsx:43
The following table details the language-to-flag mapping used in the UI:
| Country | Code |
|---|---|
| United Kingdom | en |
| China | zh |
| Spain | es |
| Russia | ru |
| Portugal | pt |
| Italy | it |
| Germany | de |
| Bulgaria | bg |
| Saudi Arabia | ar |
| Netherlands | nl |
| France | fr |
| Poland | pl |
| Israel | he |
Sources: apps/web/core/constants/config/constants.tsx:264-325
Web Application i18n
The web application uses TypeScript files to define translation objects. The next-intl library is used to provide translations within React components, as seen with the useTranslations hook.
Sources: apps/web/core/components/features/projects/add-or-edit-project/steps/review-summary.tsx:10
Translation File Structure
The English translations are defined in apps/web/core/lib/i18n/en.ts. The main object is structured by domain, such as common, pages, timer, and errors.
This diagram illustrates the nested structure of the web translation object.
Sources: apps/web/core/lib/i18n/en.ts:3-368
A snippet from the en.ts file shows this structure:
// apps/web/core/lib/i18n/en.ts
export const en = {
TITLE: APP_NAME,
common: {
COPY_NUMBER: 'Copy Number',
VERIFY: 'verify',
// ...
},
pages: {
home: {
BREADCRUMB: ['Dashboard'],
SENT_EMAIL_VERIFICATION: 'Code Verification has been sent to your email',
// ...
},
auth: {
SEND_CODE: 'send code',
RESEND_CODE: 'Resend Code',
// ...
},
// ...
}
}
Sources: apps/web/core/lib/i18n/en.ts:3-368
Mobile Application i18n
The mobile app follows a similar pattern to the web app, using TypeScript objects for translations. Files like apps/mobile/app/i18n/fr.ts contain the localized strings for different languages.
Translation Testing
A key feature of the mobile i18n system is an automated test that ensures all translation keys used in the application are defined in the English translation file. This test, located in apps/mobile/test/i18n.test.ts, prevents runtime errors from missing translations.
The test executes a grep command to find all translation keys (e.g., tx="...", translate(...)) in the /app directory. It then compares this list against the keys defined in app/i18n/en.ts.
The following diagram shows the workflow of the i18n test script.
Sources: apps/mobile/test/i18n.test.ts:39-51
The test command is defined as:
grep "[T\\|t]x=[{]\\?\\"\\S*\\"[}]\\?\\|translate(\\"\\S*\\"" -ohr './app' | grep -o "\\".*\\""
This command searches for tx props and translate() function calls to extract the keys. An EXCEPTIONS array is available to ignore keys that cannot be statically analyzed.
Sources: apps/mobile/test/i18n.test.ts:8, apps/mobile/test/i18n.test.ts:41
Desktop Application i18n
The desktop application uses a large, single en.json file for its English translations. The keys are organized into nested objects, typically with uppercase names, which correspond to different parts of the UI.
JSON File Structure
The structure of apps/desktop/i18n/en.json is based on UI domains.
This diagram shows the top-level categories in the desktop translation file.
Sources: [apps/desktop/i18n/en.json]
A snippet from the en.json file illustrates this structure:
{
"BUTTONS": {
"PAY": "Pay",
"ADD_EXISTING_USER": "Add Existing User",
"ADD_NEW": "Add New",
"ADD": "Add"
},
"SM_TABLE": {
"NO_DATA": {
"RECEIVE_ESTIMATE": "You have not received any estimate."
},
"TRANSACTION_TYPE": "Type",
"AMOUNT": "Amount"
},
"FORM": {
"USERNAME": "Username",
"PASSWORD": "Password"
}
}
Sources: apps/desktop/i18n/en.json:2-27
Summary
The Ever Teams platform implements a robust, multi-platform internationalization system. While each application (web, mobile, desktop) has a distinct implementation tailored to its environment, they all share the fundamental approach of using key-value pairs for localization. The web and mobile apps leverage TypeScript for type-safe translations, with the mobile app including a valuable automated test to prevent missing keys. The desktop app uses a comprehensive JSON file. This federated yet consistent approach allows for flexibility while ensuring the entire platform can be effectively localized.