Skip to content

Commit

Permalink
Add i18n coverage for ko and other languages (#198)
Browse files Browse the repository at this point in the history
* Add i18n coverage for ko and other languages

* Fix some build errors from localization addition
  • Loading branch information
nickick authored Sep 11, 2023
1 parent 7316420 commit 4aabee6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
2 changes: 1 addition & 1 deletion locales.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = ["en", "es"];
module.exports = ["en", "es", "tr", "ru", "ko", "vi"];
1 change: 1 addition & 0 deletions pages/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export async function getStaticProps({ params, locale }) {
if (!data) {
return {
notFound: true,
revalidate: 5 * 60, // Cache response for 5m
};
}

Expand Down
20 changes: 16 additions & 4 deletions pages/governance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
fetchImprovementProposals,
fetchVoterCount,
} from "../src/governance/utils";
import { GetStaticProps } from "next";

const overrideCss = "bg-origin-bg-grey";

Expand Down Expand Up @@ -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: {
Expand Down
8 changes: 7 additions & 1 deletion pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 16 additions & 4 deletions pages/ogv-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 4aabee6

Please sign in to comment.