i18n Developer Guide¶
The dashboard uses react-i18next for internationalisation. All user-visible strings live in JSON locale files — no hardcoded UI text in components.
Namespace Conventions¶
Strings follow a namespace-per-page pattern. Each namespace maps to a file under dashboard/src/locales/<lang>/:
| Namespace | File | Contents |
|---|---|---|
common |
common.json |
Nav items, shared actions (Deploy, Delete, Cancel), status labels, degraded-mode banners |
cluster |
cluster.json |
Cluster Overview page — cards, charts, recent events |
models |
models.json |
Model list, detail, and deploy pages |
workers |
workers.json |
Worker list and detail pages |
metrics |
metrics.json |
Metrics dashboard — chart titles, axis labels, table headers |
auth |
auth.json |
Login page and OAuth callback |
catalog |
catalog.json |
Runner catalog page — import, catalog table, detail view |
playground |
playground.json |
Chatbot Playground page |
Using Translations in a Component¶
import { useTranslation } from 'react-i18next';
export function MyComponent() {
const { t } = useTranslation('models'); // or 'common', 'cluster', …
return <h1>{t('list.heading')}</h1>;
}
For interpolation (dynamic values):
// In the JSON: "deviceCount": "{{count}} GPU"
t('workers:list.deviceCount', { count: 3 }); // → "3 GPU"
For cross-namespace lookups, prefix with the namespace:
Adding New Strings¶
- Add the key-value pair to the appropriate locale file under
dashboard/src/locales/en/. - Use dot-notation keys that describe the context, e.g.
detail.fields.requiredMemory. - Replace the hardcoded string in the component with
t('key'). - Run
npx tsc --buildto confirm no type errors.
Adding a New Language¶
- Create a new directory:
dashboard/src/locales/<lang>/. - Copy all JSON files from
dashboard/src/locales/en/into the new directory. - Translate the values (not the keys).
- Register the language in
dashboard/src/i18n.ts:
import commonFr from './locales/fr/common.json';
// … other namespaces …
resources: {
en: { … },
fr: {
common: commonFr,
// … other namespaces …
},
},
What Not to Extract¶
Do not wrap these in t():
- Route paths (
/models,/workers) - CSS class names
- API endpoint strings
- Technical identifiers (model names, worker IDs) — these are data, not UI labels
- Strings inside test files (
*.spec.ts,*.test.ts)