Skip to content

Commit

Permalink
Fix missing translation for about section
Browse files Browse the repository at this point in the history
  • Loading branch information
drik98 committed Aug 1, 2024
1 parent 9e50d5f commit 3d4aa4d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
11 changes: 1 addition & 10 deletions app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -44,11 +43,3 @@ export default async function Home({
</>
);
}

async function getMessages(locale: string): Promise<Messages> {
try {
return (await import(`../../messages/${locale}.json`)).default;
} catch (error) {
notFound();
}
}
5 changes: 4 additions & 1 deletion content/experience.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions cv/generate-tex-files.ts
Original file line number Diff line number Diff line change
@@ -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));
Expand Down
9 changes: 9 additions & 0 deletions util/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import defaultMessages from "@/messages/de.json";
import { notFound } from "next/navigation";
export type Messages = typeof defaultMessages;

export enum Locale {
Expand Down Expand Up @@ -38,3 +39,11 @@ export function getMultilingualContent<T>(
}
return content;
}

export async function getMessages(locale: string): Promise<Messages> {
try {
return (await import(`@/messages/${locale}.json`)).default;
} catch (error) {
notFound();
}
}

0 comments on commit 3d4aa4d

Please sign in to comment.