Skip to content

A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!

fix(printer/i18n): fix dates not showing up in resume language when printing

Amruth Pillai90321e128440
diff --git a/client/pages/[username]/[slug]/printer.tsx b/client/pages/[username]/[slug]/printer.tsx
index b0aa8de39..3b83350db 100644
--- a/client/pages/[username]/[slug]/printer.tsx
+++ b/client/pages/[username]/[slug]/printer.tsx
@@ -3,6 +3,7 @@ import clsx from 'clsx';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import { GetServerSideProps, NextPage } from 'next';
+import { useRouter } from 'next/router';
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
import { useEffect } from 'react';
@@ -20,6 +21,7 @@ type QueryParams = {
type Props = {
resume?: Resume;
+ locale: string;
redirect?: any;
};
@@ -35,7 +37,13 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
const resume = await fetchResumeByIdentifier({ username, slug, options: { secretKey } });
const displayLocale = resume.metadata.locale || locale || 'en';
- return { props: { resume, ...(await serverSideTranslations(displayLocale, ['common'])) } };
+ return {
+ props: {
+ resume,
+ locale: displayLocale,
+ ...(await serverSideTranslations(displayLocale, ['common'])),
+ },
+ };
} catch (error) {
return {
redirect: {
@@ -46,7 +54,9 @@ export const getServerSideProps: GetServerSideProps<Props | Promise<Props>, Quer
}
};
-const Printer: NextPage<Props> = ({ resume: initialData }) => {
+const Printer: NextPage<Props> = ({ resume: initialData, locale }) => {
+ const router = useRouter();
+
const dispatch = useAppDispatch();
const resume = useAppSelector((state) => state.resume);
@@ -55,6 +65,12 @@ const Printer: NextPage<Props> = ({ resume: initialData }) => {
if (initialData) dispatch(setResume(initialData));
}, [dispatch, initialData]);
+ useEffect(() => {
+ const { pathname, asPath, query } = router;
+
+ router.push({ pathname, query }, asPath, { locale });
+ }, [router, locale]);
+
if (!resume || isEmpty(resume)) return null;
const layout: string[][][] = get(resume, 'metadata.layout', []);