From d3b9b1bf348d3a4ba6579a3770442a33cc41ffa7 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Tue, 13 Feb 2024 08:01:52 +0000 Subject: [PATCH] updated rep pdfs for multilingual --- components/case/representation/index.js | 4 +- components/pdftemplates/finalComments_pdf.js | 122 ++++++++++++++---- components/pdftemplates/statement_pdf.js | 118 +++++++++++++---- .../pdftemplates/writtenStatement_pdf.js | 4 +- locales/cy/myrepresentations.json | 15 ++- locales/en/myrepresentations.json | 15 ++- 6 files changed, 223 insertions(+), 55 deletions(-) diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 2303938d..5cbecbb0 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -115,10 +115,10 @@ let MakeRepresentation = (props) => { var detailsObj = {}; detailsObj = jsonpath( - setCaseDetailsObj, '$..[?(@.pinswg_name=="' + currentView.caseReference.currentReference + - '")]' + '")]', + setCaseDetailsObj ); detailsObj = detailsObj[0]; diff --git a/components/pdftemplates/finalComments_pdf.js b/components/pdftemplates/finalComments_pdf.js index a0a5e3ae..104215d9 100644 --- a/components/pdftemplates/finalComments_pdf.js +++ b/components/pdftemplates/finalComments_pdf.js @@ -14,6 +14,19 @@ import { getFormCollectionByID } from "../../components/utils"; import renderers, { renderBlock } from "react-pdf-html/dist/renderers"; +import transLookupCY from "../../locales/cy/myrepresentations.json"; +import transLookupEN from "../../locales/en/myrepresentations.json"; +import { JSONPath as jsonpath } from "jsonpath-plus"; + +const getTrans = (locale, key) => { + let jsonQuery = `$.${key}`; + + let jsonObj = locale == "cy" ? transLookupCY : transLookupEN; + + console.log(locale, jsonObj[key]); + return jsonObj[key]; +}; + const styles = StyleSheet.create({ page: { backgroundColor: "white", @@ -117,7 +130,11 @@ export const finalComments_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Final Comments + F + {getTrans( + docProps.locale, + "final-comments-label" + )} { fontFamily: "Helvetica-Bold", }} > - For Planning, Conservation area, Listed + {/* For Planning, Conservation area, Listed Building and Advertisement - applications/appeals + applications/appeals */} @@ -148,7 +165,12 @@ export const finalComments_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Case details + + {getTrans( + docProps.locale, + "statement-case-details-header" + )} + { marginBottom: 10, }} > - 1a. + 1. - Case reference : + {getTrans( + docProps.locale, + "s78-section-question-1" + )}{" "} + : {values.caseRef} @@ -173,9 +199,13 @@ export const finalComments_pdf = ({ docProps }) => { marginBottom: 10, }} > - + 2. - Representation capacity: + {getTrans( + docProps.locale, + "statement-representation-capacity-label" + )} + : {values.representationCapacity} @@ -188,9 +218,13 @@ export const finalComments_pdf = ({ docProps }) => { marginBottom: 10, }} > - + 3. - Representation capacity{"\n"} details: + {getTrans( + docProps.locale, + "statement-representation-capacity-details-label" + )} + : @@ -214,9 +248,13 @@ export const finalComments_pdf = ({ docProps }) => { marginBottom: 10, }} > - 3. + 4. - Site address/grid ref: + {getTrans( + docProps.locale, + "s78-section-question-3" + )} + : {values.siteAddress} @@ -229,9 +267,13 @@ export const finalComments_pdf = ({ docProps }) => { marginBottom: 10, }} > - 4. + 5. - Case Type: + {getTrans( + docProps.locale, + "statement-case-type-label" + )} + : {appealTypeValue.value} @@ -246,7 +288,12 @@ export const finalComments_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Comments + + {getTrans( + docProps.locale, + "statement-comments-header" + )} + { }} > - 5. + 6. - Final Comments + {getTrans( + docProps.locale, + "final-comments-label" + )} @@ -285,7 +335,10 @@ export const finalComments_pdf = ({ docProps }) => { }} > - Supporting documents + {getTrans( + docProps.locale, + "statement-supporting-documents-header" + )} @@ -296,9 +349,12 @@ export const finalComments_pdf = ({ docProps }) => { marginBottom: 10, }} > - 11. + 7. - List of attached files + {getTrans( + docProps.locale, + "statement-list-of-attached-files-label" + )} { fontFamily: "Helvetica-Bold", }} > - Declaration + + {" "} + {getTrans( + docProps.locale, + "statement-declaration-header" + )} + { - Signed: + {getTrans( + docProps.locale, + "statement-signed-label" + )} + : {values.firstname} {values.lastname} @@ -371,7 +437,11 @@ export const finalComments_pdf = ({ docProps }) => { }} > - Date: + {getTrans( + docProps.locale, + "statement-date-label" + )} + : {signedDate} @@ -386,7 +456,11 @@ export const finalComments_pdf = ({ docProps }) => { }} > - On behalf of: + {getTrans( + docProps.locale, + "statement-onbehalf-label" + )} + : {values.representationCapacity} diff --git a/components/pdftemplates/statement_pdf.js b/components/pdftemplates/statement_pdf.js index ba7d000a..395487e7 100644 --- a/components/pdftemplates/statement_pdf.js +++ b/components/pdftemplates/statement_pdf.js @@ -11,9 +11,23 @@ import ReactPDF, { import { createElement } from "react"; import Html from "react-pdf-html"; import { getFormCollectionByID } from "../../components/utils"; +import useTranslation from "next-translate/useTranslation"; import renderers, { renderBlock } from "react-pdf-html/dist/renderers"; +import transLookupCY from "../../locales/cy/myrepresentations.json"; +import transLookupEN from "../../locales/en/myrepresentations.json"; +import { JSONPath as jsonpath } from "jsonpath-plus"; + +const getTrans = (locale, key) => { + let jsonQuery = `$.${key}`; + + let jsonObj = locale == "cy" ? transLookupCY : transLookupEN; + + console.log(locale, jsonObj[key]); + return jsonObj[key]; +}; + const styles = StyleSheet.create({ page: { backgroundColor: "white", @@ -90,7 +104,7 @@ const styles = StyleSheet.create({ }); export const statement_pdf = ({ docProps }) => { - //console.log("----", docProps); + console.log("----", docProps); function formatDates(dateObj) { var dateObj = new Date(dateObj); var dd = String(dateObj.getDate()).padStart(2, "0"); @@ -104,7 +118,7 @@ export const statement_pdf = ({ docProps }) => { let datestr = values.pinswg_name.split("-"); let signedDate = datestr[2] + "/" + datestr[1] + "/" + datestr[0]; let appealTypeValue = getFormCollectionByID(values.appealType); - + let { t } = useTranslation(); return ( @@ -117,7 +131,10 @@ export const statement_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Statement + {getTrans( + docProps.locale, + "statement-statement-label" + )} { fontFamily: "Helvetica-Bold", }} > - For Planning, Conservation area, Listed + {/* For Planning, Conservation area, Listed Building and Advertisement - applications/appeals + applications/appeals */} @@ -148,7 +165,12 @@ export const statement_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Case details + + {getTrans( + docProps.locale, + "statement-case-details-header" + )} + { > 1. - {t( - "myrepresentations:s78-section-question-1" + {getTrans( + docProps.locale, + "s78-section-question-1" )} - : {values.caseRef} @@ -178,7 +200,11 @@ export const statement_pdf = ({ docProps }) => { > 1a. - Representation capacity: + {getTrans( + docProps.locale, + "statement-representation-capacity-label" + )} + :{" "} {values.representationCapacity} @@ -193,7 +219,11 @@ export const statement_pdf = ({ docProps }) => { > 1c. - Representation capacity details: + {getTrans( + docProps.locale, + "statement-representation-capacity-details-label" + )} + : @@ -217,9 +247,12 @@ export const statement_pdf = ({ docProps }) => { marginBottom: 10, }} > - 3. + 2. - Site address/grid ref: + {getTrans( + docProps.locale, + "s78-section-question-3" + )} {values.siteAddress} @@ -232,9 +265,13 @@ export const statement_pdf = ({ docProps }) => { marginBottom: 10, }} > - 4. + 3. - Case Type: + {getTrans( + docProps.locale, + "statement-case-type-label" + )} + : {appealTypeValue.value} @@ -249,7 +286,12 @@ export const statement_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Comments + + {getTrans( + docProps.locale, + "statement-comments-header" + )} + { }} > - 5. + 4. - Statement + {getTrans( + docProps.locale, + "statement-statement-label" + )} @@ -288,7 +333,10 @@ export const statement_pdf = ({ docProps }) => { }} > - Supporting documents + {getTrans( + docProps.locale, + "statement-supporting-documents-header" + )} @@ -299,9 +347,12 @@ export const statement_pdf = ({ docProps }) => { marginBottom: 10, }} > - 11. + 5. - List of attached files + {getTrans( + docProps.locale, + "statement-list-of-attached-files-label" + )} { fontFamily: "Helvetica-Bold", }} > - Declaration + + {getTrans( + docProps.locale, + "statement-declaration-header" + )} + { - Signed: + {getTrans( + docProps.locale, + "statement-signed-label" + )} + : {values.firstname} {values.lastname} @@ -374,7 +434,11 @@ export const statement_pdf = ({ docProps }) => { }} > - Date: + {getTrans( + docProps.locale, + "statement-date-label" + )} + : {signedDate} @@ -389,7 +453,11 @@ export const statement_pdf = ({ docProps }) => { }} > - On behalf of: + {getTrans( + docProps.locale, + "statement-onbehalf-label" + )} + : {values.representationCapacity} diff --git a/components/pdftemplates/writtenStatement_pdf.js b/components/pdftemplates/writtenStatement_pdf.js index 382eec0b..24c81d61 100644 --- a/components/pdftemplates/writtenStatement_pdf.js +++ b/components/pdftemplates/writtenStatement_pdf.js @@ -128,9 +128,9 @@ export const writtenStatement_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - For Planning, Conservation area, Listed + {/* For Planning, Conservation area, Listed Building and Advertisement - applications/appeals + applications/appeals */} diff --git a/locales/cy/myrepresentations.json b/locales/cy/myrepresentations.json index 5ed6b507..f45f5eaa 100644 --- a/locales/cy/myrepresentations.json +++ b/locales/cy/myrepresentations.json @@ -195,5 +195,18 @@ "s78-heading-para-two": "Rhaid i'r ACLl anfon yr holiadur wedi'i gwblhau ac unrhyw atodiadau i PEDW.gwaithachos@llyw.cymru a'r apelydd (neu ei asiant) o fewn 5 diwrnod gwaith i'r dyddiad dechrau a nodir yn ein llythyr cychwyn. ", "section-heading-zero": "Manylion yr Achos", "s78-footnote-one": "* Erthygl 11 o Orchymyn Cynllunio Gwlad a Thref (Gweithdrefn Rheoli Datblygu) (Cymru) 2012; Rheoliad 7 o Reoliadau Cynllunio Gwlad a Thref (Adeiladau Rhestredig ac Ardaloedd Cadwraeth) (Cymru) 2012", - "s78-footnote-two": "** Erthygl 12 o Orchymyn Cynllunio Gwlad a Thref (Gweithdrefn Rheoli Datblygu) (Cymru) 2012; Adran 67/73 o Ddeddf Cynllunio Gwlad a Thref (Adeiladau Rhestredig ac Ardaloedd Cadwraeth) 1990; Rheoliad 10 o Reoliadau Cynllunio Gwlad a Thref (Adeiladau Rhestredig ac Ardaloedd Cadwraeth) (Cymru) 2012" + "s78-footnote-two": "** Erthygl 12 o Orchymyn Cynllunio Gwlad a Thref (Gweithdrefn Rheoli Datblygu) (Cymru) 2012; Adran 67/73 o Ddeddf Cynllunio Gwlad a Thref (Adeiladau Rhestredig ac Ardaloedd Cadwraeth) 1990; Rheoliad 10 o Reoliadau Cynllunio Gwlad a Thref (Adeiladau Rhestredig ac Ardaloedd Cadwraeth) (Cymru) 2012", + "statement-case-type-label": "Math o achos", + "statement-representation-capacity-label": "Capasiti cynrychiolaeth", + "statement-representation-capacity-details-label": "Manylion capasiti cynrychiolaeth", + "statement-statement-label": "Datganiad", + "statement-list-of-attached-files-label": "Rhestr o ffeiliau atodedig", + "statement-supporting-documents-header": "Dogfennau ategol", + "statement-comments-header": "Sylwadau", + "statement-case-details-header": "Manylion yr achos", + "statement-declaration-header": "Datganiad", + "statement-signed-label": "Llofnodwyd", + "statement-date-label": "Dyddiad", + "statement-onbehalf-label": "Ar ran", + "final-comments-label": "Sylwadau terfynol" } \ No newline at end of file diff --git a/locales/en/myrepresentations.json b/locales/en/myrepresentations.json index f5ecba20..34f66a99 100644 --- a/locales/en/myrepresentations.json +++ b/locales/en/myrepresentations.json @@ -196,5 +196,18 @@ "s78-heading-para-two": "The LPA must send the completed questionnaire and any attachments to PEDW.casework@gov.wales and the appellant (or their agent) within 5 working days of the start date specified in our start letter", "section-heading-zero": "Case Details", "s78-footnote-one": "* Article 11 of The Town and Country Planning (Development Management Procedure) (Wales) Order 2012; Regulation 7 of The Town and Country Planning (Listed Buildings and Conservation Areas) (Wales) Regulations 2012", - "s78-footnote-two": "** Article 12 of The Town and Country Planning (Development Management Procedure) (Wales) Order 2012; Section 67/73 of The Town and Country Planning (Listed Buildings and Conservation Areas) Act 1990; Regulation 10 of The Town and Country Planning (Listed Buildings and Conservation Areas) (Wales) Regulations 2012" + "s78-footnote-two": "** Article 12 of The Town and Country Planning (Development Management Procedure) (Wales) Order 2012; Section 67/73 of The Town and Country Planning (Listed Buildings and Conservation Areas) Act 1990; Regulation 10 of The Town and Country Planning (Listed Buildings and Conservation Areas) (Wales) Regulations 2012", + "statement-case-type-label": "Case type", + "statement-representation-capacity-label": "Representation capacity", + "statement-representation-capacity-details-label": "Representation capacity details", + "statement-statement-label": "Statement", + "statement-list-of-attached-files-label": "List of attached files", + "statement-supporting-documents-header": "Supporting documents", + "statement-comments-header": "Comments", + "statement-case-details-header": "Case details", + "statement-declaration-header": "Declaration", + "statement-signed-label": "Signed", + "statement-date-label": "Date", + "statement-onbehalf-label": "On behalf of", + "final-comments-label": "Final comments" } \ No newline at end of file