fix(client): exported pdf did not contain "Present" keyword with translations

This commit is contained in:
Amruth Pillai
2022-03-12 19:46:30 +01:00
parent dfccb3130f
commit cf670af403
6 changed files with 17 additions and 2 deletions

View File

@ -66,6 +66,7 @@ const Settings = () => {
const code = value?.code || 'en';
document.cookie = `NEXT_LOCALE=${code}; path=/; expires=2147483647`;
dispatch(setResumeState({ path: 'metadata.locale', value: code }));
push({ pathname, query }, asPath, { locale: code });
};

View File

@ -5,6 +5,8 @@ import { useTranslation } from 'next-i18next';
import { MouseEvent, useState } from 'react';
import { languages } from '@/config/languages';
import { useAppDispatch } from '@/store/hooks';
import { setResumeState } from '@/store/resume/resumeSlice';
import styles from './LanguageSwitcher.module.scss';
@ -13,6 +15,8 @@ const LanguageSwitcher = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
const handleClick = (event: MouseEvent<HTMLButtonElement>) => setAnchorEl(event.currentTarget);
@ -23,6 +27,8 @@ const LanguageSwitcher = () => {
const { pathname, asPath, query } = router;
document.cookie = `NEXT_LOCALE=${locale}; path=/; expires=2147483647`;
dispatch(setResumeState({ path: 'metadata.locale', value: locale }));
router.push({ pathname, query }, asPath, { locale });
};

View File

@ -3,6 +3,7 @@ import clsx from 'clsx';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { GetServerSideProps, NextPage } from 'next';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useEffect } from 'react';
import Page from '@/components/build/Center/Page';
@ -22,15 +23,19 @@ type Props = {
redirect?: any;
};
export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, QueryParams> = async ({ query }) => {
export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, QueryParams> = async ({
query,
locale,
}) => {
const { username, slug, secretKey } = query as QueryParams;
try {
if (isEmpty(secretKey)) throw new Error('There is no secret key!');
const resume = await fetchResumeByIdentifier({ username, slug, options: { secretKey } });
const displayLocale = resume.metadata.locale || locale || 'en';
return { props: { resume } };
return { props: { resume, ...(await serverSideTranslations(displayLocale, ['common'])) } };
} catch (error) {
return {
redirect: {