From 4aabee6b215ced3d612d321424e12a6d6fb1da89 Mon Sep 17 00:00:00 2001 From: Nick Hong Date: Mon, 11 Sep 2023 21:04:40 +0800 Subject: [PATCH] Add i18n coverage for ko and other languages (#198) * Add i18n coverage for ko and other languages * Fix some build errors from localization addition --- locales.js | 2 +- pages/[slug].tsx | 1 + pages/governance.tsx | 20 ++++++++++++++++---- pages/index.tsx | 8 +++++++- pages/ogv-dashboard.tsx | 20 ++++++++++++++++---- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/locales.js b/locales.js index 29704b7..81111f6 100644 --- a/locales.js +++ b/locales.js @@ -1 +1 @@ -module.exports = ["en", "es"]; +module.exports = ["en", "es", "tr", "ru", "ko", "vi"]; diff --git a/pages/[slug].tsx b/pages/[slug].tsx index b8c701c..32f9b95 100644 --- a/pages/[slug].tsx +++ b/pages/[slug].tsx @@ -37,6 +37,7 @@ export async function getStaticProps({ params, locale }) { if (!data) { return { notFound: true, + revalidate: 5 * 60, // Cache response for 5m }; } diff --git a/pages/governance.tsx b/pages/governance.tsx index 32cd769..9cce096 100644 --- a/pages/governance.tsx +++ b/pages/governance.tsx @@ -16,6 +16,7 @@ import { fetchImprovementProposals, fetchVoterCount, } from "../src/governance/utils"; +import { GetStaticProps } from "next"; const overrideCss = "bg-origin-bg-grey"; @@ -65,10 +66,21 @@ const GovernanceInfo = ({ ); }; -export const getStaticProps = async (): Promise<{ - props: GovernanceProps; - revalidate: number; -}> => { +export const getStaticProps: GetStaticProps = async ({ + locale, +}): Promise< + | { + props: GovernanceProps; + revalidate: number; + } + | { notFound: true } +> => { + if (locale !== "en") { + return { + notFound: true, + }; + } + const navResPromise = fetchAPI("/ousd-nav-links", { populate: { links: { diff --git a/pages/index.tsx b/pages/index.tsx index 43152ed..1bc9d32 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -89,7 +89,13 @@ const Home = ({ ); }; -export async function getStaticProps() { +export async function getStaticProps({ locale }) { + if (locale !== "en") { + return { + notFound: true, + }; + } + const { vault, dripper } = setupContracts(); const initialTvl = await fetchTvl(vault, dripper); const apyHistory = await fetchApyHistory(); diff --git a/pages/ogv-dashboard.tsx b/pages/ogv-dashboard.tsx index e48ff5b..b7d1a6c 100644 --- a/pages/ogv-dashboard.tsx +++ b/pages/ogv-dashboard.tsx @@ -146,10 +146,22 @@ const OgvDashboard = ({ ); }; -export const getStaticProps: GetStaticProps = async (): Promise<{ - props: DashProps; - revalidate: number; -}> => { +export const getStaticProps: GetStaticProps = async ({ + locale, +}): Promise< + | { + props: DashProps; + revalidate: number; + } + | { + notFound: true; + } +> => { + if (locale !== "en") { + return { + notFound: true, + }; + } const seoResPromise = fetchAPI("/ousd/page/en/%2Fogv-dashboard"); const navResPromise = fetchAPI("/ousd-nav-links", { populate: {