From ed6dcc926fafe5ef8a2e32b97ef02cd3294a5980 Mon Sep 17 00:00:00 2001 From: myl7 Date: Tue, 8 Feb 2022 17:17:21 +0800 Subject: [PATCH] pass locale related info into oauth guide page props --- pages/onedrive-vercel-index-oauth/step-1.tsx | 9 +++++++++ pages/onedrive-vercel-index-oauth/step-2.tsx | 9 +++++++++ pages/onedrive-vercel-index-oauth/step-3.tsx | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pages/onedrive-vercel-index-oauth/step-1.tsx b/pages/onedrive-vercel-index-oauth/step-1.tsx index a3d6d24..c5a2587 100644 --- a/pages/onedrive-vercel-index-oauth/step-1.tsx +++ b/pages/onedrive-vercel-index-oauth/step-1.tsx @@ -2,6 +2,7 @@ import Head from 'next/head' import Image from 'next/image' import { useRouter } from 'next/router' import { useTranslation, Trans } from 'next-i18next' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import siteConfig from '../../config/site.config' import apiConfig from '../../config/api.config' @@ -145,3 +146,11 @@ export default function OAuthStep1() { ) } + +export async function getServerSideProps({ locale }) { + return { + props: { + ...(await serverSideTranslations(locale, ['common'])) + } + } +} diff --git a/pages/onedrive-vercel-index-oauth/step-2.tsx b/pages/onedrive-vercel-index-oauth/step-2.tsx index ad72fb3..faa0f17 100644 --- a/pages/onedrive-vercel-index-oauth/step-2.tsx +++ b/pages/onedrive-vercel-index-oauth/step-2.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router' import { useState } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useTranslation, Trans } from 'next-i18next' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import siteConfig from '../../config/site.config' import Navbar from '../../components/Navbar' @@ -138,3 +139,11 @@ export default function OAuthStep2() { ) } + +export async function getServerSideProps({ locale }) { + return { + props: { + ...(await serverSideTranslations(locale, ['common'])) + } + } +} diff --git a/pages/onedrive-vercel-index-oauth/step-3.tsx b/pages/onedrive-vercel-index-oauth/step-3.tsx index 89bb054..0dde295 100644 --- a/pages/onedrive-vercel-index-oauth/step-3.tsx +++ b/pages/onedrive-vercel-index-oauth/step-3.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { useTranslation, Trans } from 'next-i18next' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import siteConfig from '../../config/site.config' import Navbar from '../../components/Navbar' @@ -221,7 +222,7 @@ export default function OAuthStep3({ accessToken, expiryTime, refreshToken, erro ) } -export async function getServerSideProps({ query }) { +export async function getServerSideProps({ query, locale }) { const { authCode } = query // Return if no auth code is present @@ -255,6 +256,7 @@ export async function getServerSideProps({ query }) { expiryTime, accessToken, refreshToken, + ...(await serverSideTranslations(locale, ['common'])) }, } }