From 3d4aa4d50f8198e5f4cbfb67bdf7ec366c86d11c Mon Sep 17 00:00:00 2001 From: Hendrik Schmitz Date: Thu, 1 Aug 2024 11:58:13 +0200 Subject: [PATCH] Fix missing translation for about section --- app/[locale]/page.tsx | 11 +---------- content/experience.json | 5 ++++- cv/generate-tex-files.ts | 9 +++++++-- util/i18n.ts | 9 +++++++++ 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx index 129d7e50b7..69fdbb14f1 100644 --- a/app/[locale]/page.tsx +++ b/app/[locale]/page.tsx @@ -1,6 +1,5 @@ -import { notFound } from "next/navigation"; import { Metadata } from "next"; -import { Locale, Messages } from "@/util/i18n"; +import { Locale, getMessages } from "@/util/i18n"; import About from "@/components/About"; import Banner from "@/components/Banner"; @@ -44,11 +43,3 @@ export default async function Home({ ); } - -async function getMessages(locale: string): Promise { - try { - return (await import(`../../messages/${locale}.json`)).default; - } catch (error) { - notFound(); - } -} diff --git a/content/experience.json b/content/experience.json index bfe73d011b..f88dbdfef2 100644 --- a/content/experience.json +++ b/content/experience.json @@ -59,7 +59,10 @@ } }, { - "company": "Werkzeugmaschinenlabor WZL der RWTH Aachen", + "company": { + "de": "Werkzeugmaschinenlabor WZL der RWTH Aachen", + "en": "Laboratory for Machine Tools and Production Engineering (WZL) of RWTH Aachen University" + }, "url": { "de": "https://www.wzl.rwth-aachen.de/", "en": "https://www.wzl.rwth-aachen.de/cms/~sijq/wzl/?lidx=1" diff --git a/cv/generate-tex-files.ts b/cv/generate-tex-files.ts index 07899a95a6..1742466c07 100644 --- a/cv/generate-tex-files.ts +++ b/cv/generate-tex-files.ts @@ -1,12 +1,17 @@ import fs from 'fs'; -import messages from '@/messages/de.json' import about from "@/content/about.json" import experience from "@/content/experience.json" import education from "@/content/education.json" import { formatDateRangeCV } from '@/util/date-time'; -import { getMultilingualContent, supportedLocales } from '@/util/i18n'; +import { Locale, getMessages, getMultilingualContent, supportedLocales } from '@/util/i18n'; for(const locale of supportedLocales) { + generateTemplate(locale); +} + +async function generateTemplate(locale: Locale) { + const messages = await getMessages(locale); + const birthday = new Intl.DateTimeFormat(locale, { dateStyle: "long" }).format(new Date(about.birthday)); diff --git a/util/i18n.ts b/util/i18n.ts index 1ace54cacd..a554095c03 100644 --- a/util/i18n.ts +++ b/util/i18n.ts @@ -1,4 +1,5 @@ import defaultMessages from "@/messages/de.json"; +import { notFound } from "next/navigation"; export type Messages = typeof defaultMessages; export enum Locale { @@ -38,3 +39,11 @@ export function getMultilingualContent( } return content; } + +export async function getMessages(locale: string): Promise { + try { + return (await import(`@/messages/${locale}.json`)).default; + } catch (error) { + notFound(); + } +}