Internationalization (i18n)
Relevant source files
The following files were used as context for generating this wiki page: - [AGENTS.md](https://github.com/srbhr/Resume-Matcher/blob/HEAD/AGENTS.md) - [apps/backend/app/prompts/templates.py](https://github.com/srbhr/Resume-Matcher/blob/HEAD/apps/backend/app/prompts/templates.py) - [apps/frontend/app/(default)/settings/page.tsx](https://github.com/srbhr/Resume-Matcher/blob/HEAD/apps/frontend/app/(default)/settings/page.tsx) - [apps/frontend/lib/context/language-context.tsx](https://github.com/srbhr/Resume-Matcher/blob/HEAD/apps/frontend/lib/context/language-context.tsx) - [apps/frontend/messages/en.json](https://github.com/srbhr/Resume-Matcher/blob/HEAD/apps/frontend/messages/en.json) - [apps/frontend/messages/zh.json](https://github.com/srbhr/Resume-Matcher/blob/HEAD/apps/frontend/messages/zh.json) - [README.md](https://github.com/srbhr/Resume-Matcher/blob/HEAD/README.md)The Resume Matcher application provides a multi-language experience, separating the user interface (UI) language from the language used for AI-generated content. This allows users to navigate the application in one language while creating resumes and cover letters in another. The system is designed to be straightforward, using a simple JSON import approach for UI translations and passing a language parameter to the backend for content generation.
Currently, the application supports English, Spanish, Chinese (Simplified), and Japanese. These settings are configured independently on the Settings page, providing flexibility for a global user base.
Architecture Overview
The i18n architecture is split into two distinct concerns: UI Language and Content Language.
- UI Language: This controls the language of static interface elements like buttons, labels, and navigation. It is managed entirely on the frontend and persisted in the browser's
localStorage. - Content Language: This dictates the language for all content generated by the Large Language Model (LLM), such as resume summaries, tailored experience descriptions, and cover letters. This setting is managed on the frontend, persisted in
localStorage, and also sent to the backend with relevant API requests.
The diagram below illustrates this separation.
This diagram shows the dual-language settings managed by the LanguageProvider on the frontend and how the Content Language is passed to the backend for AI processing.
Sources: AGENTS.md, apps/frontend/lib/context/language-context.tsx, apps/frontend/app/(default)/settings/page.tsx
UI Language Translation
The UI translation system uses a simple JSON file-based approach without external dependencies. Each supported language has a corresponding JSON file in the apps/frontend/messages/ directory.
Sources: AGENTS.md
Translation Files
Translations are stored as key-value pairs in JSON files. The keys are structured to represent different parts of the application (e.g., nav, dashboard, settings).
Example from en.json:
{
"nav": {
"dashboard": "Dashboard",
"builder": "Resume Builder",
"tailor": "Tailor Resume",
"settings": "Settings"
},
"settings": {
"title": "Settings",
"subtitle": "Configure your preferences",
"aiProvider": "AI Provider",
"contentLanguage": "Content Language",
"uiLanguage": "UI Language"
}
}
Sources: apps/frontend/messages/en.json:8-14,39-45
Example from zh.json:
{
"nav": {
"dashboard": "仪表板",
"builder": "简历生成器",
"tailor": "定制简历",
"settings": "设置"
},
"settings": {
"title": "设置",
"subtitle": "配置您的偏好",
"aiProvider": "AI 供应商",
"contentLanguage": "内容语言",
"uiLanguage": "界面语言"
}
}
Sources: apps/frontend/messages/zh.json:8-14,39-45
State Management
The LanguageProvider component is responsible for managing the application's language state. It uses React's Context API to provide the current language and functions to update it throughout the component tree.
uiLanguage: State for the UI language. It is initialized fromlocalStorageand defaults to English ('en').setUiLanguage: A function to update the UI language and persist the new value tolocalStorageunder the keyresume_matcher_ui_language.
The diagram below shows the structure of the LanguageProvider.
This class diagram represents the state and methods exposed by the LanguageProvider context.
Sources: apps/frontend/lib/context/language-context.tsx
Content Language Generation
The content language setting determines the output language of AI-generated text. This is handled by passing the selected language code to the backend, which then injects it into the LLM prompts.
Backend Prompt Integration
The backend uses prompt templates with an {output_language} placeholder. The IMPROVE_RESUME_PROMPT and COVER_LETTER_PROMPT are two examples that utilize this for generating content in the user's desired language. A helper function, get_language_name, converts the language code (e.g., 'es') into its full name (e.g., 'Spanish') for the prompt.
Example from IMPROVE_RESUME_PROMPT:
IMPROVE_RESUME_PROMPT = """Tailor this resume for the job. Output ONLY the JSON object, no other text.
IMPORTANT: Generate ALL text content (summary, descriptions, skills) in {output_language}.
Rules:
- Rephrase content to highlight relevant experience
- DO NOT invent new information
- Use action verbs and quantifiable achievements
- Keep proper nouns (names, company names, locations) unchanged
- Translate job titles, descriptions, and skills to {output_language}
...
"""
Sources: apps/backend/app/prompts/templates.py:101-111
The LANGUAGE_NAMES dictionary maps language codes to their full names.
# Language code to full name mapping
LANGUAGE_NAMES = {
"en": "English",
"es": "Spanish",
"zh": "Chinese (Simplified)",
"ja": "Japanese",
}
Sources: apps/backend/app/prompts/templates.py:4-10
State Management and Persistence
The LanguageProvider also manages the contentLanguage state. When a user changes the content language via the Settings page, the setContentLanguage function is called. This function updates the state and saves the new value to localStorage under the key resume_matcher_content_language.
This flow is depicted in the sequence diagram below.
This diagram shows how a user's language choice is persisted and later used in a backend request to generate localized content.
Sources: apps/frontend/lib/context/language-context.tsx, apps/frontend/app/(default)/settings/page.tsx
Configuration
Users can configure both UI and Content languages from the "Settings" page.
Supported Languages
The application officially supports the following languages for both UI and content generation.
| Code | Language | Native Name |
|---|---|---|
en | English | English |
es | Spanish | Español |
zh | Chinese | 中文 |
ja | Japanese | 日本語 |
Sources: AGENTS.md, apps/backend/app/prompts/templates.py:4-10
Settings UI
The settings page (/settings) provides two separate sections for language configuration. It fetches the list of supported languages and their names from the LanguageProvider and renders a set of buttons for each setting.
// UI Language Selection
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
{supportedLanguages.map((lang) => (
<button
key={`ui-${lang}`}
onClick={() => setUiLanguage(lang as Locale)}
// ...
>
{languageNames[lang]}
</button>
))}
</div>
// Content Language Selection
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
{supportedLanguages.map((lang) => (
<button
key={`content-${lang}`}
onClick={() => setContentLanguage(lang as SupportedLanguage)}
// ...
>
{languageNames[lang]}
</button>
))}
</div>
Sources: apps/frontend/app/(default)/settings/page.tsx:585-595,609-619
Storage Keys
Language preferences are persisted in the browser's localStorage using the following keys:
| Key | Purpose |
|---|---|
resume_matcher_ui_language | Stores the selected UI language code (e.g., 'en', 'zh'). |
resume_matcher_content_language | Stores the selected content generation language code. |
Sources: AGENTS.md, apps/frontend/lib/context/language-context.tsx:28,41
Adding a New Language
Based on the file structure and documentation, adding a new language involves the following steps:
- Create a new translation file
apps/frontend/messages/{code}.json. - Add the new locale to the configuration in
apps/frontend/i18n/config.ts. - Add the language name to the
LANGUAGE_NAMESdictionary inapps/backend/app/prompts/templates.py. - Update the
SUPPORTED_LANGUAGESlist in the backend configuration router.
Sources: AGENTS.md