|
|
@@ -4,6 +4,7 @@ import React from 'react';
|
|
|
import {
|
|
|
NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
|
} from 'next';
|
|
|
+import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
|
|
|
|
import { NoLoginLayout } from '~/components/Layout/NoLoginLayout';
|
|
|
import { LoginForm } from '~/components/LoginForm';
|
|
|
@@ -16,7 +17,7 @@ import {
|
|
|
|
|
|
|
|
|
import {
|
|
|
- CommonProps, getServerSideCommonProps, useCustomTitle,
|
|
|
+ CommonProps, getServerSideCommonProps, useCustomTitle, getNextI18NextConfig,
|
|
|
} from './utils/commons';
|
|
|
|
|
|
type Props = CommonProps & {
|
|
|
@@ -54,6 +55,17 @@ const LoginPage: NextPage<Props> = (props: Props) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+/**
|
|
|
+ * for Server Side Translations
|
|
|
+ * @param context
|
|
|
+ * @param props
|
|
|
+ * @param namespacesRequired
|
|
|
+ */
|
|
|
+async function injectNextI18NextConfigurations(context: GetServerSidePropsContext, props: Props, namespacesRequired?: string[] | undefined): Promise<void> {
|
|
|
+ const nextI18NextConfig = await getNextI18NextConfig(serverSideTranslations, context, namespacesRequired);
|
|
|
+ props._nextI18Next = nextI18NextConfig._nextI18Next;
|
|
|
+}
|
|
|
+
|
|
|
function injectEnabledStrategies(context: GetServerSidePropsContext, props: Props): void {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
|
@@ -99,6 +111,7 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
|
|
|
injectServerConfigurations(context, props);
|
|
|
injectEnabledStrategies(context, props);
|
|
|
+ await injectNextI18NextConfigurations(context, props, ['translation']);
|
|
|
|
|
|
return {
|
|
|
props,
|