Translate pages

This commit is contained in:
Andras Schmelczer 2026-04-04 09:47:18 +01:00
parent a7aaf5effa
commit 96402228e3
49 changed files with 1458 additions and 926 deletions

View file

@ -160,6 +160,8 @@ export function stateToParams(
}
export function summarizeParams(queryString: string): string {
const i18n = require('../i18n').default as { t: (key: string, opts?: Record<string, unknown>) => string };
const { ts } = require('../i18n/server') as { ts: (v: string) => string };
const params = new URLSearchParams(queryString);
const parts: string[] = [];
@ -173,7 +175,9 @@ export function summarizeParams(queryString: string): string {
.filter((n) => n && n !== 'Listing status');
if (filterNames.length > 0) {
parts.push(
filterNames.length <= 2 ? filterNames.join(', ') : `${filterNames.length} filters`
filterNames.length <= 2
? filterNames.map((n) => ts(n)).join(', ')
: i18n.t('format.nFilters', { count: filterNames.length })
);
}
}
@ -182,7 +186,11 @@ export function summarizeParams(queryString: string): string {
if (poiParams.length > 0) {
const count = poiParams.filter(Boolean).length;
if (count > 0) {
parts.push(`${count} POI ${count === 1 ? 'category' : 'categories'}`);
parts.push(
count === 1
? i18n.t('format.poiCategory', { count })
: i18n.t('format.poiCategories', { count })
);
}
}
@ -190,9 +198,13 @@ export function summarizeParams(queryString: string): string {
if (ttParams.length > 0) {
const count = ttParams.filter(Boolean).length;
if (count > 0) {
parts.push(`${count} travel time ${count === 1 ? 'destination' : 'destinations'}`);
parts.push(
count === 1
? i18n.t('format.travelDestination', { count })
: i18n.t('format.travelDestinations', { count })
);
}
}
return parts.length > 0 ? parts.join(' + ') : 'No filters';
return parts.length > 0 ? parts.join(' + ') : i18n.t('format.noFilters');
}