Skip to content

Commit daf866f

Browse files
committed
i18n: Translate header/footer/logo components
1 parent e3fc578 commit daf866f

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

src/components/footer.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { Container, Group, ActionIcon, rem, Text } from "@mantine/core";
44
import Link from "next/link";
5+
import { useTranslation } from "next-export-i18n";
56

67
import {
78
IconBrandX,
@@ -18,36 +19,37 @@ const allSocials = [
1819
{
1920
type: IconBrandGithub,
2021
url: "https://github.com/ruffle-rs",
21-
title: "GitHub",
22+
title: "footer.github",
2223
},
2324
{
2425
type: IconBrandX,
2526
url: "https://twitter.com/ruffle_rs",
26-
title: "X",
27+
title: "footer.social-x",
2728
},
2829
{
2930
type: IconBrandTiktok,
3031
url: "https://www.tiktok.com/@ruffle.rs",
31-
title: "Tiktok",
32+
title: "footer.tiktok",
3233
},
3334
{
3435
type: IconBrandInstagram,
3536
url: "https://www.instagram.com/ruffle.rs/",
36-
title: "Instagram",
37+
title: "footer.instagram",
3738
},
3839
{
3940
type: IconBrandMastodon,
4041
url: "https://mastodon.gamedev.place/@ruffle",
41-
title: "Mastodon",
42+
title: "footer.mastodon",
4243
},
4344
{
4445
type: IconBrandDiscord,
4546
url: "https://discord.gg/ruffle",
46-
title: "Discord",
47+
title: "footer.discord",
4748
},
4849
];
4950

5051
export function FooterSocial() {
52+
const { t } = useTranslation();
5153
const socials = allSocials.map((social, i) => (
5254
<ActionIcon
5355
key={i}
@@ -57,7 +59,8 @@ export function FooterSocial() {
5759
component={Link}
5860
href={social.url}
5961
target="_blank"
60-
title={social.title}
62+
title={t(social.title)}
63+
suppressHydrationWarning
6164
>
6265
<social.type style={{ width: rem(18), height: rem(18) }} stroke={1.5} />
6366
</ActionIcon>
@@ -74,8 +77,8 @@ export function FooterSocial() {
7477
width={91}
7578
priority
7679
/>
77-
<Text size="lg" className={classes.tagline}>
78-
Putting Flash back on the web
80+
<Text size="lg" className={classes.tagline} suppressHydrationWarning>
81+
{t("footer.tagline")}
7982
</Text>
8083
</Container>
8184
<Group

src/components/header.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,35 @@ import { LanguagePicker } from "./language-picker";
77
import Image from "next/image";
88
import Link from "next/link";
99
import { usePathname } from "next/navigation";
10+
import { useTranslation } from "next-export-i18n";
1011

1112
const links = [
12-
{ link: "/", label: "About Ruffle" },
13-
{ link: "/downloads", label: "Downloads" },
14-
{ link: "/compatibility", label: "Compatibility" },
15-
{ link: "/contribute", label: "Get Involved" },
16-
{ link: "/blog", label: "Blog" },
17-
{ link: "/demo", label: "Demo", target: "_blank" },
18-
{ link: "https://discord.gg/ruffle", label: "Discord", target: "_blank" },
13+
{ link: "/", label: "header.about" },
14+
{ link: "/downloads", label: "header.downloads" },
15+
{ link: "/compatibility", label: "header.compatibility" },
16+
{ link: "/contribute", label: "header.contribute" },
17+
{ link: "/blog", label: "header.blog" },
18+
{ link: "/demo", label: "header.demo", target: "_blank" },
19+
{
20+
link: "https://discord.gg/ruffle",
21+
label: "header.discord",
22+
target: "_blank",
23+
},
1924
{
2025
link: "https://github.com/ruffle-rs/ruffle/",
21-
label: "GitHub",
26+
label: "header.github",
2227
target: "_blank",
2328
},
2429
];
2530

2631
export function Header() {
32+
const { t } = useTranslation();
2733
const [opened, { toggle, close }] = useDisclosure(false);
2834
const pathname = usePathname();
2935

3036
const items = links.map((link) => (
3137
<Link
38+
suppressHydrationWarning
3239
key={link.label}
3340
href={link.link}
3441
target={link.target}
@@ -38,7 +45,7 @@ export function Header() {
3845
close();
3946
}}
4047
>
41-
{link.label}
48+
{t(link.label)}
4249
</Link>
4350
));
4451

@@ -47,8 +54,9 @@ export function Header() {
4754
<Container size="lg" className={classes.inner}>
4855
<Link href="/">
4956
<Image
57+
suppressHydrationWarning
5058
src="/logo.svg"
51-
alt="Ruffle Logo"
59+
alt={t("logo.alt-tag")}
5260
height={30}
5361
width={91}
5462
priority

src/components/logo.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { useEffect, useRef, useState } from "react";
44
import Image from "next/image";
55
import Script from "next/script";
66
import classes from "../app/index.module.css";
7+
import { useTranslation } from "next-export-i18n";
78

89
declare global {
910
interface Window {
@@ -28,6 +29,7 @@ interface LogoProps {
2829
}
2930

3031
export default function InteractiveLogo({ className }: LogoProps) {
32+
const { t } = useTranslation();
3133
const container = useRef<HTMLDivElement>(null);
3234
const [player, setPlayer] = useState<RufflePlayer | null>(null);
3335

@@ -80,8 +82,9 @@ export default function InteractiveLogo({ className }: LogoProps) {
8082
/>
8183
<div ref={container} className={className}>
8284
<Image
85+
suppressHydrationWarning
8386
src="/logo.svg"
84-
alt="Ruffle Logo"
87+
alt={t("logo.alt-tag")}
8588
className={player ? classes.hidden : classes.staticLogo}
8689
width="340"
8790
height="110"

0 commit comments

Comments
 (0)