Skip to content

Commit 0c4249b

Browse files
committed
feat: add translations
1 parent 1375316 commit 0c4249b

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

frontend/app/gs-map/gs-map.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ import { useEffect } from 'react';
2626
import { nanoid } from 'nanoid';
2727
import { type CenterLocation } from '../model/location';
2828
import { type GsValue } from '../model/gs-point';
29+
import { useTranslation } from 'node_modules/react-i18next';
2930

3031
interface InputProps {
3132
center: CenterLocation;
3233
gsValues: GsValue[];
3334
}
3435

3536
export default function GsMap(inputProps: InputProps) {
37+
const { i18n } = useTranslation();
3638
let map: Map;
3739
let currentOverlay: Overlay | null = null;
3840
useEffect(() => {
@@ -63,7 +65,7 @@ export default function GsMap(inputProps: InputProps) {
6365
return inputProps.gsValues.map((gsValue, index) => {
6466
const element = document.createElement('div');
6567
element.id = nanoid();
66-
element.innerHTML = `${gsValue.location}<br/>E5: ${gsValue.e5}<br/>E10: ${gsValue.e10}<br/>Diesel: ${gsValue.diesel}`;
68+
element.innerHTML = `${gsValue.location}<br/>${i18n.t('table.e5')}: ${gsValue.e5}<br/>${i18n.t('table.e10')}: ${gsValue.e10}<br/>${i18n.t('table.diesel')}: ${gsValue.diesel}`;
6769
const overlay = new Overlay({
6870
element: element,
6971
offset: [-5, 0],

frontend/app/i18n/de/translation.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,32 @@
1212
"password": "Passwort",
1313
"login": "Login",
1414
"signin": "Registrieren"
15+
},
16+
"header": {
17+
"title": "Günstiges Benzin",
18+
"location": "Standort",
19+
"targetPrice": "Zielpreis"
20+
},
21+
"location": {
22+
"setLocation": "Standort festlegen",
23+
"searchRadius": "Suchradius (km)",
24+
"postalCode": "Postleitzahl",
25+
"getLocation": "Standort abrufen"
26+
},
27+
"targetPrice": {
28+
"setTargetPrice": "Zielpreise festlegen",
29+
"diesel": "Zielpreis Diesel",
30+
"e5": "Zielpreis E5",
31+
"e10": "Zielpreis E10"
32+
},
33+
"table": {
34+
"currentPrices": "Aktuelle Preise",
35+
"lastPriceMatches": "Letzte Preistreffer",
36+
"currentPriceMap": "Aktuelle Preiskarte",
37+
"diesel": "Diesel",
38+
"e5": "E5",
39+
"e10": "E10",
40+
"location": "Standort",
41+
"time": "Zeit"
1542
}
1643
}

frontend/app/i18n/en/translation.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@
2929
"diesel": "Target Price Diesel",
3030
"e5": "Target Price E5",
3131
"e10": "Target Price E10"
32+
},
33+
"table": {
34+
"currentPrices": "Current Prices",
35+
"lastPriceMatches": "Last Price Matches",
36+
"currentPriceMap": "Current Price Map",
37+
"diesel": "Diesel",
38+
"e5": "E5",
39+
"e10": "E10",
40+
"location": "Location",
41+
"time": "Time"
3242
}
33-
3443
}

frontend/app/main/main.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ import { type TimeSlot } from '../model/time-slot-response';
2424
import { type GsValue } from '../model/gs-point';
2525
import { type MyDataJson } from '../model/my-data-json';
2626
import { useAtom } from "jotai";
27+
import { useTranslation } from 'node_modules/react-i18next';
2728

2829
export default function Main() {
2930
const navigate = useNavigate();
31+
const { t } = useTranslation();
3032
const [controller, setController] = useState(null as AbortController | null);
3133
const [timer, setTimer] = useState(undefined as undefined | NodeJS.Timeout);
3234
const [value, setValue] = useState(0);
@@ -132,16 +134,16 @@ export default function Main() {
132134

133135
return (<Box sx={{ width: '100%' }}>
134136
<Tabs value={value} onChange={handleTabChange} centered={true}>
135-
<Tab label="Current Prices" />
136-
<Tab label="Last Price matches" />
137-
<Tab label="Current Prices Map" />
137+
<Tab label={t('table.currentPrices')} />
138+
<Tab label={t('table.lastPriceMatches')} />
139+
<Tab label={t('table.currentPriceMap')} />
138140
</Tabs>
139141
{value === 0 &&
140-
<DataTable diesel='Diesel' e10='E10' e5='E5' location='Location' showAverages={true} time='Time' rows={rows}></DataTable>}
142+
<DataTable diesel={t('table.diesel')} e10={t('table.e10')} e5={t('table.e5')} location={t('table.location')} showAverages={true} time={t('table.time')} rows={rows}></DataTable>}
141143
{value === 1 &&
142144
<Chart timeSlots={avgTimeSlots}></Chart>}
143145
{value === 1 &&
144-
<DataTable diesel='Diesel' e10='E10' e5='E5' location='Location' showAverages={true} time='Time' rows={rows}></DataTable>}
146+
<DataTable diesel={t('table.diesel')} e10={t('table.e10')} e5={t('table.e5')} location={t('table.location')} showAverages={true} time={t('table.time')} rows={rows}></DataTable>}
145147
{value === 2 &&
146148
<GsMap gsValues={gsValues} center={globalUserDataState}></GsMap>}
147149
</Box>);

0 commit comments

Comments
 (0)