feat(client): add i18n with i18next and react-i18next
- install i18next and react-i18next - create src/i18n/index.ts bootstrapping i18next with initReactI18next - add src/i18n/locales/en.json with keys for nav, all pages, and ThemeSwitcher - replace hardcoded English strings in App, all pages, and ThemeSwitcher with t() - move static column definitions inside components where useTranslation is available
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { scenarios } from '../api';
|
||||
import type { Scenario } from '../api';
|
||||
import { Button, Table, type TableColumn } from '../ui';
|
||||
import styles from './Page.module.css';
|
||||
|
||||
export function ScenariosPage() {
|
||||
const { t } = useTranslation();
|
||||
const [items, setItems] = useState<Scenario[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -29,11 +31,11 @@ export function ScenariosPage() {
|
||||
};
|
||||
|
||||
const columns: TableColumn<Scenario>[] = [
|
||||
{ key: 'id', header: 'ID', render: (s) => s.id, width: 60 },
|
||||
{ key: 'name', header: 'Name', render: (s) => s.name },
|
||||
{ key: 'id', header: t('scenarios.col_id'), render: (s) => s.id, width: 60 },
|
||||
{ key: 'name', header: t('scenarios.col_name'), render: (s) => s.name },
|
||||
{
|
||||
key: 'updated',
|
||||
header: 'Updated',
|
||||
header: t('scenarios.col_updated'),
|
||||
width: 120,
|
||||
render: (s) => new Date(s.updatedAt).toLocaleDateString(),
|
||||
},
|
||||
@@ -44,8 +46,8 @@ export function ScenariosPage() {
|
||||
align: 'right',
|
||||
render: (s) => (
|
||||
<span style={{ display: 'inline-flex', gap: 6 }}>
|
||||
<Button size="sm" onClick={() => handleRun(s.id)}>Run</Button>
|
||||
<Button variant="secondary" size="sm" onClick={() => handleDelete(s.id)}>Delete</Button>
|
||||
<Button size="sm" onClick={() => handleRun(s.id)}>{t('scenarios.action_run')}</Button>
|
||||
<Button variant="secondary" size="sm" onClick={() => handleDelete(s.id)}>{t('scenarios.action_delete')}</Button>
|
||||
</span>
|
||||
),
|
||||
},
|
||||
@@ -53,14 +55,14 @@ export function ScenariosPage() {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className={styles.heading}>Scenarios</h1>
|
||||
<h1 className={styles.heading}>{t('scenarios.title')}</h1>
|
||||
{error && <p className={styles.error}>{error}</p>}
|
||||
<Table
|
||||
columns={columns}
|
||||
data={items}
|
||||
rowKey={(s) => s.id}
|
||||
loading={loading}
|
||||
emptyMessage="No scenarios yet."
|
||||
emptyMessage={t('scenarios.empty')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user