Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

feat(i18n): increase key + add fr translation (#1231)

Augustin Mauroy70d0cb6da614
diff --git a/apps/web/src/app/[locale]/_components/features.tsx b/apps/web/src/app/[locale]/_components/features.tsx
index 0f6ba005..57bdef38 100644
--- a/apps/web/src/app/[locale]/_components/features.tsx
+++ b/apps/web/src/app/[locale]/_components/features.tsx
@@ -22,8 +22,10 @@ import {
ChallengeCreationCard,
CuratedTracksCard,
} from './feature-card';
+import { getScopedI18n } from '~/locales/server';
-export function Features() {
+export async function Features() {
+ const t = await getScopedI18n('landing.features');
return (
<section className="relative overflow-hidden" id="features">
<div className="mx-auto mb-[64px] grid max-w-[1400px] items-center justify-center px-4 sm:px-24 md:px-4 lg:px-24">
@@ -42,7 +44,7 @@ export function Features() {
>
<path d="m19.2 36.4-4.75-10.45L4 21.2l10.45-4.75L19.2 6l4.75 10.45L34.4 21.2l-10.45 4.75ZM36.4 42l-2.35-5.25-5.25-2.35 5.25-2.4 2.35-5.2 2.4 5.2 5.2 2.4-5.2 2.35Z" />
</svg>
- many features, wow{' '}
+ {t('badge')}{' '}
<Image
className="absolute -bottom-1 right-1 translate-y-7 duration-300 group-hover:translate-y-0"
alt="doge smile"
@@ -54,10 +56,10 @@ export function Features() {
</div>
</a>
<h1 className="text-4xl font-bold">
- <Balancer>What&apos;s in TypeHero?</Balancer>
+ <Balancer>{t('title')}</Balancer>
</h1>
<p className="text-black/50 dark:text-white/50">
- <Balancer>All you need to become a TypeScript menace</Balancer>
+ <Balancer>{t('description')}</Balancer>
</p>
</div>
<div className="relative z-10 grid w-full gap-4 md:grid-cols-2 lg:gap-8 [&>*:nth-child(3)]:hidden md:[&>*:nth-child(3)]:block">
diff --git a/apps/web/src/app/[locale]/_components/hero.tsx b/apps/web/src/app/[locale]/_components/hero.tsx
index f0d4c20c..43ba5596 100644
--- a/apps/web/src/app/[locale]/_components/hero.tsx
+++ b/apps/web/src/app/[locale]/_components/hero.tsx
@@ -164,7 +164,7 @@ export async function Hero() {
<span className="animate-bg-gradient-to-center relative flex select-none items-center bg-gradient-to-r to-70% bg-[length:420%_420%] bg-clip-text bg-right-bottom text-transparent duration-500 group-hover:bg-left-top dark:from-yellow-500 dark:via-white dark:to-[#3178c6]">
<Sparkle className="animate-oldstar absolute -left-1 top-0.5 mr-2 h-5 w-5 translate-x-0.5 stroke-[#3178c6] stroke-2 duration-500 group-hover:rotate-180 group-hover:scale-110 group-hover:stroke-yellow-600 dark:duration-500 " />
<Sparkle className="animate-newstar mr-2 h-4 w-4 stroke-[#3178c6] stroke-2 duration-500 group-hover:rotate-180 group-hover:scale-110 group-hover:fill-[#3178c6] dark:stroke-white dark:duration-500 dark:group-hover:fill-white" />{' '}
- Star us on GitHub
+ {t('ghStars')}
</span>
</div>
</a>
@@ -218,7 +218,7 @@ export async function Hero() {
<Link href="/explore">
<span className="text-primary inline-flex h-full w-fit items-center gap-2 rounded-[10px] bg-white px-4 py-2 transition-all duration-300">
<Compass className="h-4 w-4" />
- Explore
+ {t('explore')}
</span>
</Link>
</Button>
@@ -232,7 +232,7 @@ export async function Hero() {
<Link href="/explore">
<span className="inline-flex h-full w-fit items-center gap-2 rounded-xl px-4 py-2 transition-all duration-300 dark:bg-neutral-900 dark:text-white group-hover:dark:bg-black">
<Compass className="h-4 w-4" />
- Explore
+ {t('explore')}
</span>
</Link>
</Button>
diff --git a/apps/web/src/app/not-found.tsx b/apps/web/src/app/not-found.tsx
index 3c46995e..1ed8e754 100644
--- a/apps/web/src/app/not-found.tsx
+++ b/apps/web/src/app/not-found.tsx
@@ -44,7 +44,7 @@ export default async function NotFound() {
<div className="flex flex-col gap-4">
<a href="/explore">
<Button className="w-56" variant="default" size="lg">
- Go to explore
+ {t('explore')}
</Button>
</a>
<a href={`/challenge/${randomChallengeSlug}`}>
@@ -53,7 +53,7 @@ export default async function NotFound() {
size="lg"
className="fancy-border-gradient bg-background relative mx-auto flex w-56 gap-4 border-none"
>
- I'm feeling lucky
+ {t('luck')}
</Button>
</a>
</div>
@@ -61,7 +61,7 @@ export default async function NotFound() {
<div>
<a href="/">
<Button variant="default" size="lg">
- Go to home
+ {t('home')}
</Button>
</a>
</div>
diff --git a/apps/web/src/locales/client.ts b/apps/web/src/locales/client.ts
index 1ecf45b6..d9e2c0ee 100644
--- a/apps/web/src/locales/client.ts
+++ b/apps/web/src/locales/client.ts
@@ -2,4 +2,5 @@ import { createI18nClient } from 'next-international/client';
export const { useI18n, useScopedI18n, I18nProviderClient } = createI18nClient({
en: () => import('./en'),
+ fr: () => import('./fr'),
});
diff --git a/apps/web/src/locales/en.ts b/apps/web/src/locales/en.ts
index ff2e076e..7aa9284f 100644
--- a/apps/web/src/locales/en.ts
+++ b/apps/web/src/locales/en.ts
@@ -1,8 +1,16 @@
export default {
'landing.hero.description':
'Connect, collaborate, and grow with a community of TypeScript developers. Elevate your skills through interactive coding challenges, discussions, and knowledge sharing',
+ 'landing.hero.ghStars': 'Star us on GitHub',
'landing.hero.buttons.waitlist': 'Join the waitlist',
+ 'landing.hero.explore': 'Explore',
+ 'landing.features.badge': 'many features, wow',
+ 'landing.features.title': "What's in TypeHero?",
+ 'landing.features.description': 'All you need to become a TypeScript menace',
'404.message': 'Page not found, sus',
+ '404.explore': 'Go to explore',
+ '404.luck': "I'm feeling lucky",
+ '404.home': 'Go to home',
'navigation.explore': 'Explore',
'navigation.tracks': 'Tracks',
'navigation.advent': 'Advent of TypeScript',
diff --git a/apps/web/src/locales/fr.ts b/apps/web/src/locales/fr.ts
new file mode 100644
index 00000000..c3463874
--- /dev/null
+++ b/apps/web/src/locales/fr.ts
@@ -0,0 +1,18 @@
+export default {
+ 'landing.hero.description':
+ 'Connectez-vous, collaborez et évoluez avec une communauté de développeurs TypeScript. Améliorez vos compétences grâce à des défis de codage interactifs, des discussions et le partage des connaissances.',
+ 'landing.hero.ghStars': 'Étoile nous sur GitHub',
+ 'landing.hero.buttons.waitlist': "S'inscrire sur la liste d'attente",
+ 'landing.hero.explore': 'Explorer',
+ 'landing.features.badge': 'Nombreuses foncionalité, wow',
+ 'landing.features.title': "Qu'est-ce que TypeHero ?",
+ 'landing.features.description':
+ 'Tout ce dont vous avez besoin pour devenir une menace TypeScript',
+ '404.message': 'Page non trouvée, sus',
+ '404.explore': 'Aller à explorer',
+ '404.luck': " J'ai de la chance",
+ '404.home': "Aller à la page d'accueil",
+ 'navigation.explore': 'Explorer',
+ 'navigation.tracks': 'Pistes',
+ 'navigation.advent': 'Advent of TypeScript',
+} as const;
diff --git a/apps/web/src/locales/server.ts b/apps/web/src/locales/server.ts
index 5d14a15c..7fd25c65 100644
--- a/apps/web/src/locales/server.ts
+++ b/apps/web/src/locales/server.ts
@@ -2,4 +2,5 @@ import { createI18nServer } from 'next-international/server';
export const { getI18n, getScopedI18n, getStaticParams } = createI18nServer({
en: () => import('./en'),
+ fr: () => import('./fr'),
});
diff --git a/apps/web/src/middleware.ts b/apps/web/src/middleware.ts
index 0583bfc2..2f9d95da 100644
--- a/apps/web/src/middleware.ts
+++ b/apps/web/src/middleware.ts
@@ -2,7 +2,7 @@ import { createI18nMiddleware } from 'next-international/middleware';
import { type NextRequest } from 'next/server';
const I18nMiddleware = createI18nMiddleware({
- locales: ['en'],
+ locales: ['en', 'fr'],
defaultLocale: 'en',
urlMappingStrategy: 'rewrite',
});