Skip to content

Commit

Permalink
Differentiated translation keys based on age units (d/h)
Browse files Browse the repository at this point in the history
  • Loading branch information
rupamkairi committed Jan 16, 2025
1 parent abb42fb commit b9e7d1d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion public/static/locales/de/projectDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"seeLess": "weniger sehen",
"seeMore": "mehr sehen",
"forestFire": "Waldbrand",
"ageAgo": "vor {age}",
"hoursAgo": "vor {age}h",
"daysAgo": "vor {age} T",
"highAlertConfidenceText": "<important>Hohe</important> Alarmkonfidenz",
"mediumAlertConfidenceText": "<important>Hohe</important> Alarmkonfidenz",
"lowAlertConfidenceText": "<important>Hohe</important> Alarmkonfidenz",
Expand Down
3 changes: 2 additions & 1 deletion public/static/locales/en/projectDetails.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"seeLess": "see less",
"seeMore": "see more",
"forestFire": "Forest Fire",
"ageAgo": "{age} ago",
"hoursAgo": "{age}h ago",
"daysAgo": "{age}d ago",
"highAlertConfidenceText": "<important>High</important> alert confidence",
"mediumAlertConfidenceText": "<important>Medium</important> alert confidence",
"lowAlertConfidenceText": "<important>Low</important> alert confidence",
Expand Down
14 changes: 9 additions & 5 deletions src/features/projectsV2/ProjectsMap/FirePopup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ export default function FirePopup({ isOpen, feature }: Props) {

const hours = Math.round(ms / (1000 * 60 * 60));
if (hours < 24) {
return `${hours}h`; // Less than 24 hours
return { amount: `${hours}`, unit: 'h' }; // Less than 24 hours
}

const days = Math.round(hours / 24); // Calculate days
return `${days}d`; // 24 hours or more
return { amount: `${days}`, unit: 'd' }; // 24 hours or more
}, [feature.properties.eventDate]);

const alertConfidence = useMemo(() => {
Expand Down Expand Up @@ -93,9 +93,13 @@ export default function FirePopup({ isOpen, feature }: Props) {
<FirePopupIcon width={18} /> {tProjectDetails('forestFire')}
</h2>
<p className={styles.timeDuration}>
{tProjectDetails('ageAgo', {
age: alertAge,
})}
{alertAge.unit === 'h'
? tProjectDetails('hoursAgo', {
age: alertAge.amount,
})
: tProjectDetails('daysAgo', {
age: alertAge.amount,
})}
<InfoIconPopup width={9} height={9} color={'#828282'}>
<div className={styles.infoIconPopupContainer}>
{tProjectDetails('firePopupText')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function FireLocations(): ReactElement {
try {
const qs = new URLSearchParams();
qs.append('remoteId', site as string);
qs.append('span', '1y');
// qs.append('span', '1y'); // This will be needed later while making multiple options
const fireAlertApiUrl =
process.env.NEXT_PUBLIC_FIREALERT_ENDPOINT ??
'https://fa.pp.eco/api/v1';
Expand Down

0 comments on commit b9e7d1d

Please sign in to comment.