Skip to content

Commit cfbb810

Browse files
barshathakurifrozenhelium
authored andcommitted
Add string translation
1 parent 38f7472 commit cfbb810

File tree

19 files changed

+103
-53
lines changed

19 files changed

+103
-53
lines changed

app/src/views/CountryNsOverviewCapacity/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export function Component() {
6262
</Link>
6363
)}
6464
>
65+
{/* Data is currently under review, it will be include in the next version */}
6566
{countryResponse?.region === REGION_ASIA && (
6667
<CountryNsOrganisationalCapacity />
6768
)}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"namespace": "countryClimateChart",
3+
"strings": {
4+
"climateChartMax": "Max",
5+
"climateChangeAverage": "Average",
6+
"climateChangeMin": "Min",
7+
"climateChangePrecipitation": "Precipation totals (mm)",
8+
"climateChangeChart": "Climate chart (Avg. country values)",
9+
"climateChartTemperature": "Average min and max temperature (°C)"
10+
}
11+
}

app/src/views/CountryProfileOverview/ClimateChart/index.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
TextOutput,
1010
Tooltip,
1111
} from '@ifrc-go/ui';
12+
import { useTranslation } from '@ifrc-go/ui/hooks';
1213
import {
1314
maxSafe,
1415
minSafe,
@@ -22,6 +23,7 @@ import {
2223
import useTemporalChartData from '#hooks/useTemporalChartData';
2324
import { GoApiResponse } from '#utils/restRequest';
2425

26+
import i18n from './i18n.json';
2527
import styles from './styles.module.css';
2628

2729
const NUM_Y_AXIS_TICKS = 5;
@@ -35,6 +37,8 @@ function ClimateChart(props: Props) {
3537
data,
3638
} = props;
3739

40+
const strings = useTranslation(i18n);
41+
3842
const temperatureContainerRef = useRef<HTMLDivElement>(null);
3943
const precipitationContainerRef = useRef<HTMLDivElement>(null);
4044

@@ -127,20 +131,17 @@ function ClimateChart(props: Props) {
127131
description={(
128132
<>
129133
<TextOutput
130-
// FIXME: use translation
131-
label="Max"
134+
label={strings.climateChartMax}
132135
value={currentData.max_temp}
133136
valueType="number"
134137
/>
135138
<TextOutput
136-
// FIXME: use translation
137-
label="Average"
139+
label={strings.climateChangeAverage}
138140
value={currentData.avg_temp}
139141
valueType="number"
140142
/>
141143
<TextOutput
142-
// FIXME: use translation
143-
label="Min"
144+
label={strings.climateChangeMin}
144145
value={currentData.min_temp}
145146
valueType="number"
146147
/>
@@ -149,7 +150,12 @@ function ClimateChart(props: Props) {
149150
/>
150151
);
151152
},
152-
[dataByMonth],
153+
[
154+
dataByMonth,
155+
strings.climateChartMax,
156+
strings.climateChangeAverage,
157+
strings.climateChangeMin,
158+
],
153159
);
154160

155161
const precipitationTooltipSelector = useCallback(
@@ -170,16 +176,15 @@ function ClimateChart(props: Props) {
170176
title={currentData.month_display}
171177
description={(
172178
<TextOutput
173-
// FIXME: use translation
174-
label="Precipitation"
179+
label={strings.climateChangePrecipitation}
175180
value={currentData.precipitation}
176181
valueType="number"
177182
/>
178183
)}
179184
/>
180185
);
181186
},
182-
[dataByMonth],
187+
[dataByMonth, strings.climateChangePrecipitation],
183188
);
184189

185190
const barWidth = bound(
@@ -191,14 +196,12 @@ function ClimateChart(props: Props) {
191196
return (
192197
<Container
193198
className={styles.climateChart}
194-
// FIXME: use translation
195-
heading="Climate chart"
199+
heading={strings.climateChangeChart}
196200
contentViewType="vertical"
197201
withHeaderBorder
198202
>
199203
<Container
200-
// FIXME: use translation
201-
heading="Temperature"
204+
heading={strings.climateChartTemperature}
202205
headingLevel={5}
203206
>
204207
<div
@@ -233,8 +236,7 @@ function ClimateChart(props: Props) {
233236
</div>
234237
</Container>
235238
<Container
236-
// FIXME: use translation
237-
heading="Precipitation"
239+
heading={strings.climateChangePrecipitation}
238240
headingLevel={5}
239241
>
240242
<div
@@ -257,8 +259,8 @@ function ClimateChart(props: Props) {
257259
height={(
258260
Math.max(
259261
precipitationChartData.dataAreaSize.height
260-
- chartPoint.y
261-
+ precipitationChartData.dataAreaOffset.top,
262+
- chartPoint.y
263+
+ precipitationChartData.dataAreaOffset.top,
262264
0,
263265
)
264266
)}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"namespace": "populationMap",
3+
"strings": {
4+
"populationMapTitle": "Population Map"
5+
}
6+
}

app/src/views/CountryProfileOverview/PopulationMap/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo } from 'react';
22
import { Container } from '@ifrc-go/ui';
3+
import { useTranslation } from '@ifrc-go/ui/hooks';
34
import { maxSafe } from '@ifrc-go/ui/utils';
45
import {
56
isDefined,
@@ -30,6 +31,7 @@ import {
3031
} from '#utils/constants';
3132
import { GoApiResponse } from '#utils/restRequest';
3233

34+
import i18n from './i18n.json';
3335
import styles from './styles.module.css';
3436

3537
const DEFAULT_MAX_POPULATION = 1000000;
@@ -40,6 +42,8 @@ interface Props {
4042

4143
function PopulatioMap(props: Props) {
4244
const { data } = props;
45+
const strings = useTranslation(i18n);
46+
4347
const countryData = useCountry({ id: data?.id ?? -1 });
4448

4549
const bounds = (isDefined(countryData) && isDefined(countryData.bbox))
@@ -209,8 +213,7 @@ function PopulatioMap(props: Props) {
209213

210214
return (
211215
<Container
212-
// FIXME: use translation
213-
heading="Population Map"
216+
heading={strings.populationMapTitle}
214217
className={styles.populationMap}
215218
withHeaderBorder
216219
>

app/src/views/CountryProfileOverview/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"seasonalCalendarTooltipEventLabel": "Event",
2020
"seasonalCalendarTooltipEventTypeLabel": "Event type",
2121
"seasonalCalendarTooltipMonthsLabel": "Months",
22-
"seasonalCalendarTooltipSourceLabel": "Source"
22+
"seasonalCalendarTooltipSourceLabel": "Source",
23+
"seasonalCalenderDataNotAvailable": "Data is not available!"
2324
}
2425
}

app/src/views/CountryProfileOverview/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ export function Component() {
371371
</div>
372372
{(isNotDefined(eventTypeGroupedData) || eventTypeGroupedData.length === 0) && (
373373
<Message
374-
// FIXME: use translation
375-
title="Data is not available!"
374+
title={strings.seasonalCalenderDataNotAvailable}
376375
/>
377376
)}
378377
{eventTypeGroupedData?.map(
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"namespace": "emergenciesOverMonth",
3+
"strings": {
4+
"emergenciesOverMonthTargetedPopulation": "Targeted population"
5+
}
6+
}

app/src/views/CountryProfilePreviousEvents/EmergenciesOverMonth/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import {
99
TextOutput,
1010
Tooltip,
1111
} from '@ifrc-go/ui';
12+
import { useTranslation } from '@ifrc-go/ui/hooks';
1213
import { isNotDefined } from '@togglecorp/fujs';
1314

1415
import useTemporalChartData from '#hooks/useTemporalChartData';
1516
import { useRequest } from '#utils/restRequest';
1617

18+
import i18n from './i18n.json';
1719
import styles from './styles.module.css';
1820

1921
interface Props {
@@ -29,6 +31,8 @@ function EmergenciesOverMonth(props: Props) {
2931
countryId,
3032
} = props;
3133

34+
const strings = useTranslation(i18n);
35+
3236
const containerRef = useRef<ElementRef<'div'>>(null);
3337

3438
const {
@@ -78,8 +82,7 @@ function EmergenciesOverMonth(props: Props) {
7882
<>
7983
<DateOutput value={dataPoint.originalData.date} />
8084
<TextOutput
81-
// FIXME: use translation
82-
label="Targeted population"
85+
label={strings.emergenciesOverMonthTargetedPopulation}
8386
value={dataPoint.originalData.targeted_population}
8487
valueType="number"
8588
/>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"namespace": "pastEventsChart",
3+
"strings": {
4+
"pastEventsChartEvents": "Past events",
5+
"pastEventsPeopleExposed": "People Exposed / Affected",
6+
"pastEventsTargetedPopulation": "Targeted population",
7+
"pastEventsAmountRequested": "Amount requested",
8+
"pastEventsAmountFunded": "Amount funded"
9+
}
10+
}

0 commit comments

Comments
 (0)