typesafe i18n

This commit is contained in:
notmd
2023-01-22 23:28:27 +07:00
parent f645b53405
commit 80a7ad0154
5 changed files with 25 additions and 9 deletions
+1
View File
@@ -1,6 +1,7 @@
{
"about": "About",
"account_settings": "Account",
"admin_dashboard": "Admin Dashboard",
"connect": "Connect",
"conversational": "Conversational AI for everyone.",
"dashboard": "Dashboard",
+2 -2
View File
@@ -27,10 +27,10 @@ export function Faq() {
return (
<ListItem className="space-y-10" key={`question_${index}`}>
<Text as="h3" className={`text-lg font-semibold leading-6 ${headingColorClass}`}>
{t(`faq_items.q${index}`)}
{t(`faq_items.q${index as 0}`)}
</Text>
<Text as="p" className={`mt-4 text-sm ${textColorClass}`}>
{t(`faq_items.a${index}`)}
{t(`faq_items.a${index as 0}`)}
</Text>
</ListItem>
);
+1 -1
View File
@@ -24,7 +24,7 @@ const Home = () => {
<>
<Head>
<title>{t("title")}</title>
<meta name="description" content={t("description")} />
<meta name="description" content={t("index:description")} />
</Head>
<Box as="main" className="oa-basic-theme">
<Hero />
+6 -6
View File
@@ -11,19 +11,19 @@ const Leaderboard = () => {
return (
<>
<Head>
<title>{`${t("leaderboard")} - ${t("common:title")}`}</title>
<title>{`${t("leaderboard:leaderboard")} - ${t("common:title")}`}</title>
<meta name="description" content="Leaderboard Rankings" charSet="UTF-8" />
</Head>
<Box display="flex" flexDirection="column">
<Heading fontSize="2xl" fontWeight="bold" pb="4">
{t("leaderboard")}
{t("leaderboard:leaderboard")}
</Heading>
<Tabs isFitted isLazy>
<TabList>
<Tab>{t("daily")}</Tab>
<Tab>{t("weekly")}</Tab>
<Tab>{t("monthly")}</Tab>
<Tab>{t("overall")}</Tab>
<Tab>{t("leaderboard:daily")}</Tab>
<Tab>{t("leaderboard:weekly")}</Tab>
<Tab>{t("leaderboard:monthly")}</Tab>
<Tab>{t("leaderboard:overall")}</Tab>
</TabList>
<TabPanels>
+15
View File
@@ -0,0 +1,15 @@
import "i18next";
import type common from "../public/locales/en/common.json";
import type index from "../public/locales/en/index.json";
import type leaderboard from "../public/locales/en/leaderboard.json";
declare module "i18next" {
interface CustomTypeOptions {
resources: {
common: typeof common;
index: typeof index;
leaderboard: typeof leaderboard;
};
}
}