This guide covers managing multi-language content in CHRIS.
Overview
CHRIS supports four languages:
| Language | Code | Flag |
|---|---|---|
| Croatian | hr | ðŸ‡ðŸ‡· |
| English | en | 🇬🇧 |
| Russian | ru | 🇷🇺 |
| Hindi | hi | 🇮🇳 |
Translations are stored in the database and can be managed by administrators.
How Translations Work
Translation Keys
Each translatable string has a key following the pattern:
category.descriptiveName
Examples:
common.save- "Save" button textleaveRequests.submitRequest- "Submit Request" buttonemployees.addEmployee- "Add Employee" header
Fallback Chain
If a translation is missing:
- Try the requested language
- Fall back to English
- Fall back to Croatian
- Show the key itself
View Translations
Navigate to Settings > Translations:
- See all translation keys in a table
- Filter by category
- Search for specific keys
- View translations in all languages
Edit a Translation
Single Translation
- Find the translation key in the list
- Click Edit
- Update the text for each language:
- Croatian (required)
- English (required)
- Russian
- Hindi
- Click Save
Tips for Good Translations
- Keep translations concise for UI elements
- Maintain consistent terminology
- Consider text expansion (German is ~30% longer than English)
- Test in the UI after saving
Add a New Translation
When adding new features that need translation:
Step 1: Create the Key
- Go to Settings > Translations
- Click Add Translation
- Enter the key following the naming convention:
category.descriptiveName
Step 2: Enter Translations
| Language | Field |
|---|---|
| Croatian | Primary language, required |
| English | Required |
| Russian | Optional (falls back to English) |
| Hindi | Optional (falls back to English) |
Step 3: Use in Code
Reference the key in React components:
import { useLanguage } from '@/contexts/LanguageContext';
function MyComponent() {
const { t } = useLanguage();
return <button>{t('common.save')}</button>;
}
Translation Categories
Organize translations by category:
| Category | Purpose |
|---|---|
| common | Shared UI elements (buttons, labels) |
| auth | Authentication (login, logout, password) |
| employees | Employee management |
| leaveRequests | Leave request workflow |
| teams | Team management |
| settings | Settings pages |
| holidays | Holiday management |
| contracts | Contract management |
| audit | Audit logging |
| profile | User profile |
Bulk Operations
Export Translations
Export all translations for review or backup:
- Go to Settings > Translations
- Click Export
- Download the CSV file
The CSV includes:
- Key
- Category
- Croatian text
- English text
- Russian text
- Hindi text
Import Translations
Update multiple translations at once:
- Download the export CSV as a template
- Edit translations in the CSV
- Click Import
- Upload the modified CSV
- Review changes and confirm
!!! warning "Import Caution" Importing overwrites existing translations. Always backup first.
Database Structure
Translations are stored in the translations table:
| Column | Type | Description |
|---|---|---|
| id | uuid | Primary key |
| key | text | Unique translation key |
| croatian | text | Croatian translation |
| english | text | English translation |
| russian | text | Russian translation |
| hindi | text | Hindi translation |
| category | text | Category for organization |
| created_at | timestamp | Creation time |
| updated_at | timestamp | Last update time |
Adding a New Language
To add a fifth language:
Database Migration
ALTER TABLE translations ADD COLUMN german TEXT;
Update LanguageContext
- Add the language to supported languages
- Update the fallback chain
- Add the language picker option
Translate All Keys
- Export existing translations
- Add the new language column
- Translate all keys
- Import the updated file
Best Practices
Key Naming
✓ common.save
✓ leaveRequests.submitRequest
✓ employees.roleEmployee
✗ save (too generic)
✗ submitLeaveRequest (inconsistent format)
✗ EMPLOYEES_ROLE (wrong case)
Translation Quality
- Native speakers: Have native speakers review translations
- Context: Provide context for translators (where is this shown?)
- Consistency: Use the same term for the same concept
- Testing: Test translations in the actual UI
Missing Translations
Check for missing translations:
SELECT key
FROM translations
WHERE russian IS NULL OR hindi IS NULL;
Troubleshooting
Translation Not Showing
- Verify the key exists in the database
- Check for typos in the key
- Clear browser cache
- Refresh the page
Wrong Language Displayed
- Check the language picker selection
- Verify browser language preferences
- Check the translation exists for that language
Special Characters
Ensure proper encoding:
- Database should use UTF-8
- CSV exports should be UTF-8
- Hindi and Russian need Unicode support