Skip to content

Commit

Permalink
fix(client): exported pdf did not contain "Present" keyword with tran…
Browse files Browse the repository at this point in the history
…slations
  • Loading branch information
AmruthPillai committed Mar 12, 2022
1 parent dfccb31 commit cf670af
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions client/components/build/RightSidebar/sections/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
};
Expand Down
6 changes: 6 additions & 0 deletions client/components/shared/LanguageSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
Expand All @@ -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 });
};

Expand Down
9 changes: 7 additions & 2 deletions client/pages/[username]/[slug]/printer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions schema/src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type DateConfig = {

export type Metadata = {
css: CustomCSS;
locale: string;
date: DateConfig;
layout: string[][][]; // page.column.section
template: string;
Expand Down
1 change: 1 addition & 0 deletions server/src/resume/data/defaultState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const defaultState: Partial<Resume> = {
background: '#ffffff',
primary: '#f44336',
},
locale: 'en',
date: {
format: 'MMMM DD, YYYY',
},
Expand Down
1 change: 1 addition & 0 deletions server/src/resume/data/sampleData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ const sampleData: Partial<Resume> = {
value: '/* Enter custom CSS here */\n\n* {\n outline: 1px solid #000;\n}',
visible: false,
},
locale: 'en',
date: {
format: 'MMMM DD, YYYY',
},
Expand Down

0 comments on commit cf670af

Please sign in to comment.