make all strings translatable

i18n
mrshmllow 2 years ago committed by Michal
parent ba847cf45e
commit 093635341e
No known key found for this signature in database
GPG Key ID: 52F8801FC912EB4F

@ -14,19 +14,17 @@ import Link from "next/link";
import { useTranslation } from "next-i18next";
const Footer = () => {
const { t } = useTranslation('footer');
const { t } = useTranslation("common");
return (
<footer className="border-t border-ctp-mantle text-ctp-text">
<div className="mx-auto flex max-w-8xl flex-col gap-8 px-4 py-6 md:flex-row md:px-8">
<section className="basis-1/3">
<h4 className="text-2xl font-bold">About</h4>
<p>
{t("subtitle")}
</p>
<h4 className="text-2xl font-bold">{t("generics.about")}</h4>
<p>{t("subtitle")}</p>
</section>
<section className="basis-1/3">
<h4 className="text-2xl font-bold">Community</h4>
<h4 className="text-2xl font-bold">{t("generics.community")}</h4>
<ul>
<li>
<a href="https://forum.getcryst.al/">
@ -35,7 +33,7 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Forums
{t("locations.forums")}
</a>
</li>
<li>
@ -45,7 +43,7 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Twitter
{t("locations.twitter")}
</a>
</li>
<li>
@ -55,7 +53,7 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Mastodon
{t("locations.mastodon")}
</a>
</li>
<li>
@ -65,7 +63,7 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Github
{t("locations.github")}
</a>
</li>
<li>
@ -76,7 +74,7 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Discord
{t("locations.discord")}
</a>
</Link>
</li>
@ -88,14 +86,14 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Matrix
{t("locations.matrix")}
</a>
</Link>
</li>
</ul>
</section>
<section className="basis-1/3">
<h4 className="text-2xl font-bold">Other</h4>
<h4 className="text-2xl font-bold">{t("generics.other")}</h4>
<ul>
<li>
<Link href="https://opencollective.com/crystal-linux">
@ -105,22 +103,24 @@ const Footer = () => {
className="mr-1"
fixedWidth={true}
/>
Open Collective
{t("locations.open_collective")}
</a>
</Link>
</li>
<li>
<a href="https://github.com/crystal-linux/.github/blob/main/CONTRIBUTING.md">
Contributing Guidelines
{t("locations.contributing_guidelines")}
</a>
</li>
<li>
<a href="https://www.contributor-covenant.org/">
The Contributor Covenant
{t("locations.contributor_covenant")}
</a>
</li>
<li>
<a href="https://developercertificate.org/">The DCO</a>
<a href="https://developercertificate.org/">
{t("locations.dco")}
</a>
</li>
</ul>
</section>

@ -1,6 +1,7 @@
import { faGithub } from "@fortawesome/free-brands-svg-icons";
import { faArrowUpRightFromSquare } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useTranslation } from "next-i18next";
import Image from "next/image";
import Link from "next/link";
import { useRouter } from "next/router";
@ -12,6 +13,8 @@ const Navbar = () => {
const [scrollTop, setScrollTop] = useState(0);
const [toggled, setToggled] = useState(false);
const { route } = useRouter();
const { t: common } = useTranslation("common");
const { t } = useTranslation("navbar");
useEffect(() => {
const onScroll = () => {
@ -58,7 +61,7 @@ const Navbar = () => {
className="mr-3 hidden rounded-lg bg-ctp-mauve px-5 py-2.5 text-center text-sm font-medium text-ctp-base !no-underline focus:outline-none focus:ring-4 md:mr-0 md:block"
href="https://github.com/crystal-linux/iso/releases/latest"
>
Download
{common("generics.download")}
</a>
<button
@ -68,7 +71,7 @@ const Navbar = () => {
setToggled(!toggled);
}}
>
<span className="sr-only">Open main menu</span>
<span className="sr-only">{t("open_main_menu")}</span>
<svg
className="h-6 w-6"
fill="currentColor"
@ -98,7 +101,7 @@ const Navbar = () => {
: "text-ctp-text md:hover:text-ctp-mauve"
} no-underline md:p-0`}
>
Home
{common("locations.home")}
</a>
</Link>
</li>
@ -107,7 +110,7 @@ const Navbar = () => {
href="https://forum.getcryst.al/"
className="md:dark:hover:bg-transparen block rounded py-2 pr-4 pl-3 text-ctp-text no-underline md:p-0 md:hover:bg-transparent md:hover:text-ctp-mauve"
>
Forum
{common("locations.forums")}
<FontAwesomeIcon
className="ml-2"
icon={faArrowUpRightFromSquare}
@ -123,7 +126,7 @@ const Navbar = () => {
: "text-ctp-text md:hover:text-ctp-mauve"
} no-underline md:p-0`}
>
Docs
{common("locations.docs")}
</a>
</Link>
</li>
@ -132,7 +135,7 @@ const Navbar = () => {
className={`block rounded py-2 pr-4 pl-3 text-ctp-text no-underline md:bg-transparent md:p-0 md:hover:text-ctp-mauve`}
href="https://github.com/crystal-linux/"
>
Github
{common("locations.github")}
<FontAwesomeIcon
className="ml-2"
icon={faArrowUpRightFromSquare}
@ -144,7 +147,7 @@ const Navbar = () => {
className={`block rounded py-2 pr-4 pl-3 text-ctp-text no-underline md:bg-transparent md:p-0 md:hover:text-ctp-mauve`}
href="https://github.com/crystal-linux/iso/releases/latest"
>
Download
{common("generics.download")}
<FontAwesomeIcon
className="ml-2"
icon={faArrowUpRightFromSquare}
@ -156,7 +159,7 @@ const Navbar = () => {
!toggled ? "hidden" : ""
} mt-2 flex items-center justify-between border-t border-ctp-mantle px-2 pt-4 md:hidden`}
>
<p className="text-ctp-text">Switch Theme</p>{" "}
<p className="text-ctp-text">{t("switch_theme")}</p>
<NativeThemeSwitcher />
</div>
</ul>

@ -1,23 +0,0 @@
import type { I18n } from "@lingui/core";
import { en, de } from "make-plural/plurals";
//anounce which locales we are going to use and connect them to approprite plural rules
export function initTranslation(i18n: I18n) {
i18n.loadLocaleData({
en: { plurals: en },
de: { plurals: de },
pseudo: { plurals: en },
});
}
export async function loadTranslation(locale: string, isProduction = true) {
if (isProduction) {
return (await import(`../translations/locales/${locale}/messages`)).messages;
} else {
return (
await import(
`@lingui/loader!../translations/locales/${locale}/messages.po`
)
).messages;
}
}

@ -1,6 +1,7 @@
module.exports = {
/** @type {import('next/dist/server/config-shared').I18NConfig} **/
i18n: {
defaultLocale: 'en',
locales: ['en', 'de'],
defaultLocale: "en",
locales: ["en", "de"],
},
};

@ -1,7 +1,7 @@
// next.config.mjs
import remarkGfm from "remark-gfm";
import createMDX from "@next/mdx";
// import { i18n } from "./next-i18next.config"
import i18next from "./next-i18next.config.js";
/** @type {import('next').NextConfig} */
const nextConfig = {
@ -32,10 +32,7 @@ const nextConfig = {
},
];
},
i18n: {
defaultLocale: 'en',
locales: ['en', 'de'],
},
i18n: i18next.i18n,
};
const withMDX = createMDX({

@ -22,10 +22,7 @@ type AppPropsWithLayout = AppProps & {
Component: NextPageWithLayout;
};
function GetCrystal({
Component,
pageProps,
}: AppPropsWithLayout) {
function GetCrystal({ Component, pageProps }: AppPropsWithLayout) {
const getLayout = Component.getLayout ?? ((page) => page);
return (

@ -7,33 +7,38 @@ import { NextPageWithLayout } from "./_app";
import { ReactElement } from "react";
import onyxDark from "../public/demos/onyx-dark.png";
import onyxLight from "../public/demos/onyx-light.png";
import timeshiftSnapshots from "../public/demos/timeshift-snapshots.png"
import timeshiftSnapshots from "../public/demos/timeshift-snapshots.png";
import AmePreview from "../components/AmePreview";
import HomeSection from "../components/HomeSection";
import { useRouter } from "next/router";
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { GetStaticProps } from "next";
import { useTranslation } from "next-i18next";
export const getStaticProps: GetStaticProps = async ({ locale }) => {
return {
props: {
...(await serverSideTranslations(locale!, ['common', 'footer', 'home'])),
...(await serverSideTranslations(locale!, [
"common",
"footer",
"home",
"navbar",
])),
},
};
}
};
const Home: NextPageWithLayout = () => {
const { resolvedTheme } = useTheme();
const { locale } = useRouter()
const { locale } = useRouter();
const { t: common } = useTranslation("common")
const { t } = useTranslation("home")
const { t: common } = useTranslation("common");
const { t } = useTranslation("home");
return (
<>
<section>
<div className="flex-col items-center justify-center px-4 pt-36 flex text-center md:px-8 md:pb-32 lg:pt-44">
<div className="flex flex-col items-center justify-center px-4 pt-36 text-center md:px-8 md:pb-32 lg:pt-44">
<h1 className="mb-4 text-4xl font-extrabold leading-none tracking-tight text-ctp-text md:text-5xl lg:text-6xl">
{common("header")}
</h1>
@ -41,7 +46,7 @@ const Home: NextPageWithLayout = () => {
{common("subtitle")}
</p>
<div className="w-full flex gap-2 justify-center flex-wrap">
<div className="flex w-full flex-wrap justify-center gap-2">
<a
className="inline-flex w-full items-center justify-center rounded-lg bg-ctp-mauve py-3 px-5 text-center text-base font-medium text-ctp-base no-underline focus:ring-4 sm:w-fit"
href="https://github.com/crystal-linux/iso/releases/latest"
@ -61,13 +66,12 @@ const Home: NextPageWithLayout = () => {
<HomeSection className="">
<div className="basis-1/4">
<p className="mt-8 font-semibold text-ctp-maroon"></p>
<p className="mt-8 font-semibold text-ctp-maroon">{t("onyx.tag")}</p>
<p className="mt-4 text-3xl font-extrabold tracking-tight text-ctp-text sm:text-4xl">
Onyx built-in
{t("onyx.title")}
</p>
<p className="mt-4 max-w-3xl text-ctp-subtext1">
Install Crystal with it{"'"}s in-house desktop experience, a custom
GNOME session with a familiar layout. Or choose your favourite!
{t("onyx.description")}
</p>
</div>
@ -82,12 +86,14 @@ const Home: NextPageWithLayout = () => {
<HomeSection>
<div>
<p className="mt-8 font-semibold text-ctp-rosewater">Buttery</p>
<p className="mt-8 font-semibold text-ctp-rosewater">
{t("timeshift.tag")}
</p>
<p className="mt-4 text-3xl font-extrabold tracking-tight text-ctp-text sm:text-4xl">
Automatic Backups
{t("timeshift.title")}
</p>
<p className="mt-4 max-w-3xl space-y-6 text-ctp-subtext1">
Backup & Restore your system. Easily boot into Btrfs snapshots.
{t("timeshift.description")}
</p>
</div>
@ -102,19 +108,19 @@ const Home: NextPageWithLayout = () => {
<HomeSection className="pb-16 md:pb-28">
<div className="basis-1/4">
<p className="mt-8 font-semibold text-ctp-mauve">Rusty Quartz?</p>
<p className="mt-8 font-semibold text-ctp-mauve">
{t("amethyst.tag")}
</p>
<p className="mt-4 text-3xl font-extrabold tracking-tight text-ctp-text sm:text-4xl">
Amethyst
{t("amethyst.title")}
</p>
<p className="mt-4 max-w-3xl text-ctp-subtext1">
Amethyst is a fast, efficient and lightweight AUR helper and Pacman
wrapper. Made for Crystal, compatible with any Arch-based Linux
distribution.
{t("amethyst.decsription")}
</p>
<Link href="/docs/amethyst/getting-started">
<a className="inline-flex mt-4 w-full items-center border border-ctp-mantle bg-ctp-surface0 justify-center gap-2 rounded-full py-2 px-4 text-center text-base font-medium text-ctp-text no-underline focus:ring-4 sm:w-fit">
Learn more
<a className="mt-4 inline-flex w-full items-center justify-center gap-2 rounded-full border border-ctp-mantle bg-ctp-surface0 py-2 px-4 text-center text-base font-medium text-ctp-text no-underline focus:ring-4 sm:w-fit">
{common("generics.learn_more")}
<FontAwesomeIcon icon={faArrowRight} />
</a>
</Link>

@ -1,3 +0,0 @@
{
"subtitle": "this is german"
}

@ -1,9 +1,28 @@
{
"header": "An Arch based distribution",
"subtitle": "Crystal Linux is a brand new Arch Linux based distribution. Friendly, powerful and easy to use.",
"generics": {
"download": "Download",
"getting_started": "Getting Started"
"getting_started": "Getting Started",
"learn_more": "Learn more",
"about": "About",
"community": "Community",
"other": "Other"
},
"locations": {
"home": "Home",
"docs": "Docs",
"forums": "Forums",
"twitter": "Twitter",
"mastodon": "Mastodon",
"github": "Github",
"discord": "Discord",
"matrix": "Matrix",
"open_collective": "Open Collective",
"contributing_guidelines": "Contributing Guidelines",
"contributor_covenant": "The Contributor Covenant",
"dco": "The DCO"
}
}

@ -0,0 +1,17 @@
{
"onyx": {
"tag": "Beatiful",
"title": "Onyx built-in",
"description": "Install Crystal with it's in-house desktop experience, a custom GNOME session with a familiar layout. Or choose your favourite!"
},
"timeshift": {
"tag": "Buttery",
"title": "Automatic Backups",
"description": "Backup & Restore your system. Easily boot into Btrfs snapshots."
},
"amethyst": {
"tag": "Rusty Quartz?",
"title": "Amethyst",
"description": "Amethyst is a fast, efficient and lightweight AUR helper and Pacman wrapper. Made for Crystal, compatible with any Arch-based Linux distribution."
}
}

@ -0,0 +1,4 @@
{
"open_main_menu": "Open main menu",
"switch_theme": "Switch Theme"
}
Loading…
Cancel
Save