Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 66 additions & 1 deletion src/lib/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { createContext, useCallback, useContext, useEffect, useState, type ReactNode } from "react";

export type Locale = "es" | "en" | "fr" | "de" | "it" | "pt" | "pl" | "cs" | "hu" | "bg" | "sk" | "da" | "sv" | "no" | "sr" | "fi";
export type Locale = "es" | "en" | "fr" | "de" | "it" | "pt" | "pl" | "cs" | "hu" | "bg" | "sk" | "da" | "sv" | "no" | "sr" | "fi" | "ca";

export const LOCALES: { code: Locale; label: string; flag: string }[] = [
{ code: "es", label: "Español", flag: "ES" },
Expand All @@ -21,6 +21,7 @@
{ code: "no", label: "Norsk", flag: "NO" },
{ code: "sr", label: "Srpski", flag: "RS" },
{ code: "fi", label: "Suomi", flag: "FI" },
{ code: "ca", label: "Català", flag: "EU" },
];

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1052,6 +1053,70 @@
"stats.prices": "hintaa",
"stats.lastUpdate": "Viimeisin päivitys",
},
ca: {
"search.placeholder": "Cerca un lloc...",
"search.destination": "Destinació",
"search.origin": "Origen",
"search.whereTo": "On aneu?",
"sheet.routeAndStations": "Ruta i estacions",
"sheet.resize": "Canvia la mida del panell",
"search.addWaypoint": "Afegeix una parada",
"search.waypoint": "Parada intermèdia",
"search.swap": "Intercanvia origen i destinació",
"route.distance": "km",
"route.duration": "min",
"route.loading": "S'està calculant la ruta...",
"route.alternatives": "Rutes alternatives",
"route.error": "S'ha produït un error en calcular la ruta",
"route.noRoute": "No s'ha trobat cap ruta",
"stations.noStations": "No hi ha estacions en aquest tram",
"stations.loadError": "S'ha produït un error en carregar les estacions",
"search.noResults": "No hi ha resultats",
"stations.title": "Estacions en ruta",
"stations.empty": "No hi ha estacions amb aquest filtre",
"stations.detourBasis": "Base del desviament",
"stations.basisRoute": "Aquesta ruta",
"stations.basisAny": "Qualsevol",
"stations.detourMax": "Desviament màxim",
"stations.corridor": "Radi de cerca",
"stations.noLimit": "Sense límit",
"stations.cheapest": "MÉS BARATA",
"stations.leastDetour": "MENYS DESVIAMENT",
"stations.balanced": "EQUILIBRADA",
"stations.avg": "Mitjana:",
"stations.sortPrice": "Preu",
"stations.sortDetour": "Desviament",
"stations.sortKm": "km ruta",
"stations.loading": "S'estan cercant estacions...",
"stations.maxStops": "S'ha arribat al màxim d'aturades",
"fuel.diesel": "Dièsel",
"fuel.gasoline": "Gasolina",
"fuel.gas": "Gas",
"fuel.hydrogen": "Hidrogen",
"fuel.electric": "Elèctric",
"fuel.other": "Altres",
"geo.myLocation": "La meva ubicació",
"geo.center": "Centra en la meva ubicació",
"geo.denied": "S'ha denegat l'accés a la ubicació",
"filter.maxPrice": "Preu màx.",
"filter.clear": "Neteja",
"popup.updatedNow": "Actualitzat ara",
"popup.updated": "Fa",
"popup.noPrice": "Sense preu per a",
"popup.navigate": "Com arribar-hi",
"popup.showOnMap": "Mostra-ho en el mapa",
"popup.share": "Comparteix",
"popup.copied": "S'ha copiat!",
"popup.copyLink": "Copia l'enllaç",
"share.point": "Punt compartit",
"share.routeTitle": "Ruta en Pumperly",
"share.shareRoute": "Comparteix la ruta",
"share.copied": "S'ha copiat!",
"stats.title": "Estadístiques",
"stats.stations": "estacions",
"stats.prices": "preus",
"stats.lastUpdate": "Última actualització",
},
};

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -1103,7 +1168,7 @@
const localePattern = /^\/([a-z]{2})(\/|$)/;
const match = path.match(localePattern);
const rest = match ? path.slice(match[1].length + 1) : path;
window.location.href = `/${l}${rest || ""}`;

Check warning on line 1171 in src/lib/i18n.tsx

View workflow job for this annotation

GitHub Actions / Lint & Type Check

Do not use `window.location.href` to navigate to internal Next.js pages. Use `redirect()` in the render phase, or `useRouter().push()` in Client Components' event handlers instead. See: https://nextjs.org/docs/messages/no-location-assign-relative-destination
}, []);

// Sync <html lang> and ensure cookie exists for middleware (covers fresh visitors)
Expand Down
7 changes: 7 additions & 0 deletions src/lib/og-translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ export const OG_TRANSLATIONS: Record<Locale, OgStrings> = {
imageSubtitle: "Edullisimmat polttoaineet ja EV-lataus reitilläsi",
ogLocale: "fi_FI",
},
ca: {
title: "Pumperly - Planificador de Rutes Energètiques",
description:
"Trobeu les benzineres i els punts de càrrega més barats a la vostra ruta. Preus en temps real a 36 països.",
imageSubtitle: "Benzineres i càrrega EV més barates a la vostra ruta",
ogLocale: "ca_ES",
},
};

export const SUPPORTED_LOCALES = Object.keys(OG_TRANSLATIONS) as Locale[];
Expand Down