Skip to content

Commit

Permalink
translate title of city links on start page
Browse files Browse the repository at this point in the history
  • Loading branch information
Falsal committed Nov 11, 2023
1 parent 7831780 commit e058a63
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/utils/seoPageHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import Box from "@mui/material/Box";
import { Grid, Typography } from "@mui/material";
// import {Helmet} from "react-helmet";
import { Helmet, HelmetProvider } from "react-helmet-async";
import { t } from "i18next";
// import { useTranslation } from "react-i18next";

export const getPageHeader = (directLink) => {
// console.log("L8 directLink: ", JSON.stringify(directLink));

if (!!directLink && !!directLink.header) {
console.log("L11 directLink.header: ", JSON.stringify(directLink.header));
// console.log("L11 directLink.header: ", JSON.stringify(directLink.header));
return (
<HelmetProvider>
<Helmet>
Expand Down Expand Up @@ -185,14 +186,34 @@ export const listAllCityLinks = (cities, searchParams = null) => {

const translatedCountry = () => {
// const { t } = useTranslation();
const country = getCountryName();
let country = getCountryName();
// const countryKey = getCountryKey(country);

country = getTranslatedCountry(country);
// return t(`start.${countryKey}`);
//try to pass the countryKey to the translation function in utils/translation.js
return country;
};

export const getTranslatedCountry = (name) => {
switch (name) {
case "Schweiz":
return t("start.schweiz");
case "Österreich":
return t("start.oesterreich");
case "Deutschland":
return t("start.deutschland");
case "Frankreich":
return t("start.frankreich");
case "Slowenien":
return t("start.slowenien");
case "Italien":
return t("start.italien");
default:
return t("start.oesterreich");
}
};

export const getCountryKey = (name) => {
switch (name) {
case "Schweiz":
Expand Down

0 comments on commit e058a63

Please sign in to comment.