|
@@ -4,11 +4,14 @@ import {
|
|
|
NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
NextPage, GetServerSideProps, GetServerSidePropsContext,
|
|
|
} from 'next';
|
|
} from 'next';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
import { useTranslation } from 'next-i18next';
|
|
|
|
|
+import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
|
|
import dynamic from 'next/dynamic';
|
|
import dynamic from 'next/dynamic';
|
|
|
import { useRouter } from 'next/router';
|
|
import { useRouter } from 'next/router';
|
|
|
|
|
|
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
import { CrowiRequest } from '~/interfaces/crowi-request';
|
|
|
-import { CommonProps, getServerSideCommonProps, useCustomTitle } from '~/pages/commons';
|
|
|
|
|
|
|
+import {
|
|
|
|
|
+ CommonProps, getServerSideCommonProps, useCustomTitle, getNextI18NextConfig,
|
|
|
|
|
+} from '~/pages/commons';
|
|
|
import PluginUtils from '~/server/plugins/plugin-utils';
|
|
import PluginUtils from '~/server/plugins/plugin-utils';
|
|
|
import ConfigLoader from '~/server/service/config-loader';
|
|
import ConfigLoader from '~/server/service/config-loader';
|
|
|
import {
|
|
import {
|
|
@@ -53,7 +56,7 @@ type Props = CommonProps & {
|
|
|
|
|
|
|
|
const AdminMarkdownSettingsPage: NextPage<Props> = (props: Props) => {
|
|
const AdminMarkdownSettingsPage: NextPage<Props> = (props: Props) => {
|
|
|
|
|
|
|
|
- const { t } = useTranslation();
|
|
|
|
|
|
|
+ const { t } = useTranslation('admin');
|
|
|
const router = useRouter();
|
|
const router = useRouter();
|
|
|
const path = router.query.path || 'home';
|
|
const path = router.query.path || 'home';
|
|
|
const name = Array.isArray(path) ? path[0] : path;
|
|
const name = Array.isArray(path) ? path[0] : path;
|
|
@@ -146,6 +149,17 @@ const AdminMarkdownSettingsPage: 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;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
|
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
const req: CrowiRequest = context.req as CrowiRequest;
|
|
|
const { crowi } = req;
|
|
const { crowi } = req;
|
|
@@ -154,7 +168,6 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
} = crowi;
|
|
} = crowi;
|
|
|
|
|
|
|
|
const { user } = req;
|
|
const { user } = req;
|
|
|
-
|
|
|
|
|
const result = await getServerSideCommonProps(context);
|
|
const result = await getServerSideCommonProps(context);
|
|
|
|
|
|
|
|
// check for presence
|
|
// check for presence
|
|
@@ -168,6 +181,8 @@ export const getServerSideProps: GetServerSideProps = async(context: GetServerSi
|
|
|
props.currentUser = JSON.stringify(user);
|
|
props.currentUser = JSON.stringify(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ injectNextI18NextConfigurations(context, props, ['admin']);
|
|
|
|
|
+
|
|
|
props.siteUrl = appService.getSiteUrl();
|
|
props.siteUrl = appService.getSiteUrl();
|
|
|
props.nodeVersion = crowi.runtimeVersions.versions.node ? crowi.runtimeVersions.versions.node.version.version : null;
|
|
props.nodeVersion = crowi.runtimeVersions.versions.node ? crowi.runtimeVersions.versions.node.version.version : null;
|
|
|
props.npmVersion = crowi.runtimeVersions.versions.npm ? crowi.runtimeVersions.versions.npm.version.version : null;
|
|
props.npmVersion = crowi.runtimeVersions.versions.npm ? crowi.runtimeVersions.versions.npm.version.version : null;
|