From fb148e1e881a38d57046155087c5876125fdbd99 Mon Sep 17 00:00:00 2001 From: Nick Hong Date: Wed, 30 Aug 2023 15:09:26 -0400 Subject: [PATCH 1/2] Add i18n coverage for ko and other languages --- locales.js | 2 +- pages/[slug].tsx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 }; } From c32f97a86c0336430f6a6ec8476a1eae1274170c Mon Sep 17 00:00:00 2001 From: Nick Hong Date: Wed, 30 Aug 2023 15:49:28 -0400 Subject: [PATCH 2/2] Fix some build errors from localization addition --- pages/governance.tsx | 20 ++++++++++++++++---- pages/index.tsx | 8 +++++++- pages/ogv-dashboard.tsx | 20 ++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) 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: {