mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-14 08:42:08 +10:00
fix(client): exported pdf did not contain "Present" keyword with translations
This commit is contained in:
@ -66,6 +66,7 @@ const Settings = () => {
|
|||||||
const code = value?.code || 'en';
|
const code = value?.code || 'en';
|
||||||
|
|
||||||
document.cookie = `NEXT_LOCALE=${code}; path=/; expires=2147483647`;
|
document.cookie = `NEXT_LOCALE=${code}; path=/; expires=2147483647`;
|
||||||
|
dispatch(setResumeState({ path: 'metadata.locale', value: code }));
|
||||||
|
|
||||||
push({ pathname, query }, asPath, { locale: code });
|
push({ pathname, query }, asPath, { locale: code });
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,6 +5,8 @@ import { useTranslation } from 'next-i18next';
|
|||||||
import { MouseEvent, useState } from 'react';
|
import { MouseEvent, useState } from 'react';
|
||||||
|
|
||||||
import { languages } from '@/config/languages';
|
import { languages } from '@/config/languages';
|
||||||
|
import { useAppDispatch } from '@/store/hooks';
|
||||||
|
import { setResumeState } from '@/store/resume/resumeSlice';
|
||||||
|
|
||||||
import styles from './LanguageSwitcher.module.scss';
|
import styles from './LanguageSwitcher.module.scss';
|
||||||
|
|
||||||
@ -13,6 +15,8 @@ const LanguageSwitcher = () => {
|
|||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
||||||
|
|
||||||
const handleClick = (event: MouseEvent<HTMLButtonElement>) => setAnchorEl(event.currentTarget);
|
const handleClick = (event: MouseEvent<HTMLButtonElement>) => setAnchorEl(event.currentTarget);
|
||||||
@ -23,6 +27,8 @@ const LanguageSwitcher = () => {
|
|||||||
const { pathname, asPath, query } = router;
|
const { pathname, asPath, query } = router;
|
||||||
|
|
||||||
document.cookie = `NEXT_LOCALE=${locale}; path=/; expires=2147483647`;
|
document.cookie = `NEXT_LOCALE=${locale}; path=/; expires=2147483647`;
|
||||||
|
dispatch(setResumeState({ path: 'metadata.locale', value: locale }));
|
||||||
|
|
||||||
router.push({ pathname, query }, asPath, { locale });
|
router.push({ pathname, query }, asPath, { locale });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import clsx from 'clsx';
|
|||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import isEmpty from 'lodash/isEmpty';
|
import isEmpty from 'lodash/isEmpty';
|
||||||
import { GetServerSideProps, NextPage } from 'next';
|
import { GetServerSideProps, NextPage } from 'next';
|
||||||
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import Page from '@/components/build/Center/Page';
|
import Page from '@/components/build/Center/Page';
|
||||||
@ -22,15 +23,19 @@ type Props = {
|
|||||||
redirect?: any;
|
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;
|
const { username, slug, secretKey } = query as QueryParams;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isEmpty(secretKey)) throw new Error('There is no secret key!');
|
if (isEmpty(secretKey)) throw new Error('There is no secret key!');
|
||||||
|
|
||||||
const resume = await fetchResumeByIdentifier({ username, slug, options: { secretKey } });
|
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) {
|
} catch (error) {
|
||||||
return {
|
return {
|
||||||
redirect: {
|
redirect: {
|
||||||
|
|||||||
@ -23,6 +23,7 @@ export type DateConfig = {
|
|||||||
|
|
||||||
export type Metadata = {
|
export type Metadata = {
|
||||||
css: CustomCSS;
|
css: CustomCSS;
|
||||||
|
locale: string;
|
||||||
date: DateConfig;
|
date: DateConfig;
|
||||||
layout: string[][][]; // page.column.section
|
layout: string[][][]; // page.column.section
|
||||||
template: string;
|
template: string;
|
||||||
|
|||||||
@ -133,6 +133,7 @@ const defaultState: Partial<Resume> = {
|
|||||||
background: '#ffffff',
|
background: '#ffffff',
|
||||||
primary: '#f44336',
|
primary: '#f44336',
|
||||||
},
|
},
|
||||||
|
locale: 'en',
|
||||||
date: {
|
date: {
|
||||||
format: 'MMMM DD, YYYY',
|
format: 'MMMM DD, YYYY',
|
||||||
},
|
},
|
||||||
|
|||||||
@ -421,6 +421,7 @@ const sampleData: Partial<Resume> = {
|
|||||||
value: '/* Enter custom CSS here */\n\n* {\n outline: 1px solid #000;\n}',
|
value: '/* Enter custom CSS here */\n\n* {\n outline: 1px solid #000;\n}',
|
||||||
visible: false,
|
visible: false,
|
||||||
},
|
},
|
||||||
|
locale: 'en',
|
||||||
date: {
|
date: {
|
||||||
format: 'MMMM DD, YYYY',
|
format: 'MMMM DD, YYYY',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user