From 08552da757140f0ad32f64cf7ca6e6dda25f8682 Mon Sep 17 00:00:00 2001 From: rdbsolutions Date: Thu, 2 Nov 2023 10:14:32 +0000 Subject: [PATCH] welsh trans for questionnaire --- components/case/representation/index.js | 1 + .../representation/representationElements.js | 57 +-- .../case/representation/representationLPA.js | 4 +- .../representationLPAQuestionnaire_s78.js | 11 +- components/pdftemplates/enforcement_pdf.js | 1 + .../pdftemplates/lpaQuestionnaire_pdf.js | 380 +++++++++++------- locales/cy/myrepresentations.json | 10 +- locales/en/myrepresentations.json | 10 +- pages/api/file/generatepdf.js | 17 +- 9 files changed, 297 insertions(+), 194 deletions(-) diff --git a/components/case/representation/index.js b/components/case/representation/index.js index 09d933a6..192b589a 100644 --- a/components/case/representation/index.js +++ b/components/case/representation/index.js @@ -552,6 +552,7 @@ let MakeRepresentation = (props) => { : isLPA ? "lpa" : values.representationCapacity, + "locale": locale, })); console.log(values); currentView.representationSubmit != true diff --git a/components/case/representation/representationElements.js b/components/case/representation/representationElements.js index 3c1c4359..ea7fc8e1 100644 --- a/components/case/representation/representationElements.js +++ b/components/case/representation/representationElements.js @@ -123,7 +123,7 @@ export const RenderCondtionalRadioList = ({ ...custom }) => { const required = (value) => (value ? undefined : "Required"); - + let { t } = useTranslation(); return ( <>
- {value == "Yes" && options[key] == "Yes" && ( -
+ {value == + t("myrepresentations:questionnaire-yes") && + options[key] == + t( + "myrepresentations:questionnaire-yes" + ) && (
- - + + +
- - )} + )} ))} @@ -244,6 +249,8 @@ export const RenderLPACondtionalRadioList = ({ }) => { const required = (value) => (value ? undefined : "Required"); + console.log(error); + return ( <>
-
{onBehalfOfLPA} { id="signedDate" label={t("myrepresentations:s78-section-question-date")} component={RenderDatePicker} - validate={[required]} + //validate={[required]} errorMsg="Select a date" dateStart="0" dateEnd="1-y" + locale={locale} /> + ss )} diff --git a/components/pdftemplates/enforcement_pdf.js b/components/pdftemplates/enforcement_pdf.js index 3dd50d16..955f2a66 100644 --- a/components/pdftemplates/enforcement_pdf.js +++ b/components/pdftemplates/enforcement_pdf.js @@ -10,6 +10,7 @@ import ReactPDF, { } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { getFormCollectionByID } from "../../components/utils"; +import useTranslation from "next-translate/useTranslation"; const styles = StyleSheet.create({ page: { diff --git a/components/pdftemplates/lpaQuestionnaire_pdf.js b/components/pdftemplates/lpaQuestionnaire_pdf.js index 55ad84ba..0d84e633 100644 --- a/components/pdftemplates/lpaQuestionnaire_pdf.js +++ b/components/pdftemplates/lpaQuestionnaire_pdf.js @@ -10,6 +10,21 @@ import ReactPDF, { } from "@react-pdf/renderer"; import Html from "react-pdf-html"; import { getFormCollectionByID } from "../../components/utils"; +import getT from "next-translate/getT"; +import useTranslation from "next-translate/useTranslation"; + +import transLookupCY from "../../locales/cy/myrepresentations.json"; +import transLookupEN from "../../locales/en/myrepresentations.json"; +import jsonpath from "jsonpath"; + +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: { @@ -87,7 +102,8 @@ const styles = StyleSheet.create({ }); export const lpaQuestionnaire_pdf = ({ docProps }) => { - console.log(docProps); + // console.log(docProps); + function formatDates(dateObj) { var dateObj = new Date(dateObj); var dd = String(dateObj.getDate()).padStart(2, "0"); @@ -112,7 +128,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Local Planning Authority Questionnaire + {getTrans( + docProps.locale, + "lpa-questionnaire-heading" + )} { fontFamily: "Helvetica-Bold", }} > - For Planning, Conservation area, Listed - Building and Advertisement - applications/appeals + {getTrans( + docProps.locale, + "s78-heading-para-one" + )} @@ -137,10 +157,7 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { - 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. + {getTrans(docProps.locale, "s78-heading-para-two")} @@ -150,7 +167,12 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Case details + + {getTrans( + docProps.locale, + "section-heading-zero" + )} + { > 1. - {t( - "myrepresentations:s78-section-question-1" + {getTrans( + docProps.locale, + "s78-section-question-1" )} - : {values.caseRef} @@ -180,10 +202,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 2. - {t( - "myrepresentations:s78-section-question-2" + {getTrans( + docProps.locale, + "s78-section-question-2" )} - : {values.lpaRef} @@ -198,7 +220,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 3. - Site address/grid ref: + {getTrans( + docProps.locale, + "s78-section-question-3" + )} {values.siteAddress} @@ -213,7 +238,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 4. - Case Type: + {getTrans( + docProps.locale, + "s78-section-question-4" + )} {appealTypeValue.value} @@ -229,7 +257,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - {t("myrepresentations:s78-section-heading-one")} + {getTrans( + docProps.locale, + "s78-section-heading-one" + )} @@ -250,8 +281,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 5. - Which procedure do you consider the - appeal should follow? + {getTrans( + docProps.locale, + "s78-section-question-5" + )} {values.procedureType} @@ -275,8 +308,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 6. - Will the Inspector need to enter the appeal - site/property? + {getTrans( + docProps.locale, + "s78-section-question-6" + )} {values.enterToView} @@ -299,9 +334,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 7. - Do you consider that the Inspector needs - to enter neighbouring private - land/property to view the site? + {getTrans( + docProps.locale, + "s78-section-question-7" + )} {values.enterNeighbouringLandToViewSite} @@ -335,12 +371,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 8. - If access to private land/buildings is - required, are you content for the - Inspector to visit the site on an - ‘access required’ basis, with only the - landowner or their representative - present? + {getTrans( + docProps.locale, + "s78-section-question-8" + )} { @@ -375,9 +409,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 9. - Are you aware of any health and safety - issues which would need to be considered - when the Inspector visits the site? + {getTrans( + docProps.locale, + "s78-section-question-9" + )} {values.healthAndSafetyIssues} @@ -410,8 +445,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { - LPA contact for site visit, hearing or - inquiry arrangements: + {getTrans( + docProps.locale, + "s78-section-question-10" + )} @@ -430,7 +467,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Supporting documents + {getTrans( + docProps.locale, + "s78-section-heading-two" + )} @@ -443,7 +483,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 11. - LPA case file and representations + {getTrans( + docProps.locale, + "s78-section-question-11" + )} @@ -460,8 +503,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 12. - LPA’s adopted local development plan and - Proposals Map + {getTrans( + docProps.locale, + "s78-section-question-12" + )} @@ -478,8 +523,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 13. - Adopted local guidance relevant to the - proposal: + {getTrans( + docProps.locale, + "s78-section-question-13" + )} @@ -496,8 +543,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 14. - If applicable, do you intend to submit a - full statement at the 4- week stage? + {getTrans( + docProps.locale, + "s78-section-question-14" + )} {values.LPAintentionToSubmitFullStatement} @@ -513,7 +562,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Statutory considerations + {getTrans( + docProps.locale, + "s78-section-heading-three" + )} @@ -526,8 +578,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 15. - Is all or part of the site within an Area of - Outstanding Natural Beauty? + {getTrans( + docProps.locale, + "s78-section-question-15" + )} {values.AONB} @@ -549,8 +603,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 16. - Does the site include any public rights - of way? + {getTrans( + docProps.locale, + "s78-section-question-16" + )} {values.ROW} @@ -580,8 +636,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 17. - Is all or part of the site within a - Conservation Area? + {getTrans( + docProps.locale, + "s78-section-question-17" + )} {values.conservationArea}{" "} @@ -611,10 +669,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 18. - Would the proposal involve works to, or - affect the setting of, a listed - building, Scheduled Monument or other - designated historic asset? + {getTrans( + docProps.locale, + "s78-section-question-18" + )} {values.affectListedBuilding} @@ -646,8 +704,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 19. - Is any part of the site subject to a - Tree Preservation Order? + {getTrans( + docProps.locale, + "s78-section-question-19" + )} {values.TPO} @@ -677,10 +737,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 20. - Is the site within or likely to affect - an International or National Designated - Site for nature conservation (as defined - in Planning Policy Wales)? + {getTrans( + docProps.locale, + "s78-section-question-20" + )} {values.natureConservationSite} @@ -712,8 +772,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 21. - Are any protected species likely to be - affected by the proposal? + {getTrans( + docProps.locale, + "s78-section-question-21" + )} {values.protectedSpecies} @@ -736,9 +798,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 22. - Does the case involve persons claiming - Gypsy/Traveller status, whether or not this - is accepted by the LPA? + {getTrans( + docProps.locale, + "s78-section-question-22" + )} {values.gypsyTravellerInvolvment} @@ -760,11 +823,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 23. - Have you received comments or directions - from any government department/agency or - statutory undertaker, including in - response to a statutory notification or - consultation? + {getTrans( + docProps.locale, + "s78-section-question-23" + )} {values.governmentDepartmentComments} @@ -791,7 +853,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Suggested considerations + {getTrans( + docProps.locale, + "s78-section-heading-four" + )} @@ -804,11 +869,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > 24. - Review the following standard conditions and - advise whether they would be necessary if - permission/consent is granted (not - applicable to Advertisement consent - proposals): + {getTrans( + docProps.locale, + "s78-section-question-24" + )} { > a) - The development shall begin not later than - five years from the date of this decision. + {getTrans( + docProps.locale, + "s78-section-question-24a" + )} { @@ -845,14 +911,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { b) - The development shall be carried out in - accordance with the following approved - plans and documents: - ............................ Reason: To - ensure the development is carried out in - accordance with the approved documents, - plans and drawings submitted with the - application. + {getTrans( + docProps.locale, + "s78-section-question-24b" + )} { @@ -880,12 +942,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > c) - No development shall take place until a - scheme for biodiversity enhancement has been - submitted to and agreed in writing by the - local planning authority. Development shall - be carried out in accordance with the - approved details. + {getTrans( + docProps.locale, + "s78-section-question-24c" + )} {values.developmentNotTakePlaceBiodiversity} @@ -900,18 +960,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > d) - No development shall take place until a - scheme to enable the provision of gigabit - capable broadband infrastructure from the - site boundary to the dwellings/buildings - hereby permitted has been submitted to and - agreed in writing by the local planning - authority. Development shall be carried out - in accordance with the approved details. - Reason: To support the roll-out of digital - communications infrastructure across Wales - in accordance with Policy 13 of Future - Wales. + {getTrans( + docProps.locale, + "s78-section-question-24d" + )} {values.developmentNotTakePlaceBroadband} @@ -933,9 +985,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 25. - Do you consider other conditions, or - amended versions of the above standard - conditions, to be necessary? + {getTrans( + docProps.locale, + "s78-section-question-25" + )} {values.developmentAnyOtherConditions} @@ -962,8 +1015,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Before sending, have you attached or provided a - web link to: + {getTrans( + docProps.locale, + "s78-section-heading-five" + )} @@ -983,9 +1038,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 26. - A copy of the applicant’s certificate - confirming that they notified persons - with an interest in the land?* + {getTrans( + docProps.locale, + "s78-section-question-26" + )} {values.copyOfApplicantsCertificate} @@ -1016,9 +1072,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 27. - Evidence of any publicity given to the - application, including site notices and - local advertisement?** + {getTrans( + docProps.locale, + "s78-section-question-27" + )} {values.advertismentGiven} @@ -1048,9 +1105,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 28. - A copy of the letter with which you - notified people of the appeal AND a list - of the people you notified? + {getTrans( + docProps.locale, + "s78-section-question-28" + )} { @@ -1083,9 +1141,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 29. - The LPA’s Environmental Impact - Assessment Screening Opinion, if - applicable? + {getTrans( + docProps.locale, + "s78-section-question-29" + )} {values.lpaEIAOS} @@ -1116,9 +1175,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 30. - Advertisement consent proposals only: A - true copy of the Discontinuance Notice - (if one has been issued)? + {getTrans( + docProps.locale, + "s78-section-question-30" + )} { @@ -1154,10 +1214,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 31. - Details of other appeals or applications - relating to the site, or a nearby site, - which are still being considered by PEDW - or the Welsh Ministers? + {getTrans( + docProps.locale, + "s78-section-question-31" + )} {values.detailsOfOtherAppeals} @@ -1190,9 +1250,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 32. - Details of any previous appeal decision - relating to the site or a nearby site - referred to by the LPA or applicant? + {getTrans( + docProps.locale, + "s78-section-question-32" + )} {values.detailsOfPreviousAppeals} @@ -1225,8 +1286,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { 33. - Any other relevant information that we - should know about? + {getTrans( + docProps.locale, + "s78-section-question-33" + )} {values.otherRelevantInformation} @@ -1251,7 +1314,13 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { fontFamily: "Helvetica-Bold", }} > - Declaration + + {" "} + {getTrans( + docProps.locale, + "s78-section-heading-seven" + )} + { - Signed: + {getTrans( + docProps.locale, + "s78-section-question-signed" + )} {values.caseOfficer} @@ -1285,7 +1357,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Date: + {getTrans( + docProps.locale, + "s78-section-question-date" + )} {formatDates(values.signedDate)} @@ -1300,7 +1375,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - On behalf of: + {getTrans( + docProps.locale, + "s78-section-question-onbehalf" + )} {values.onBehalfOfLPA} @@ -1315,7 +1393,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { }} > - Supporting documents + {getTrans( + docProps.locale, + "lpa-list-supporting-documents-heading" + )} @@ -1328,7 +1409,10 @@ export const lpaQuestionnaire_pdf = ({ docProps }) => { > - List of attached files + {getTrans( + docProps.locale, + "lpa-list-supporting-documents-list" + )} { - * 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 + {getTrans(docProps.locale, "s78-footnote-one")} - ** 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 + {getTrans(docProps.locale, "s78-footnote-two")}{" "} diff --git a/locales/cy/myrepresentations.json b/locales/cy/myrepresentations.json index f59a4a9f..e732b67d 100644 --- a/locales/cy/myrepresentations.json +++ b/locales/cy/myrepresentations.json @@ -184,5 +184,13 @@ "enf-section-question-onbehalf": "Ar ran", "enf-section-question-date": "Dyddiad", "questionnaire-yes": "Oes", - "questionnaire-no": "Nac ydw" + "questionnaire-no": "Nac ydw", + "lpa-questionnaire-heading": "Awdurdod Cynllunio Lleol Holiadur", + "lpa-list-supporting-documents-heading": " Rhestr o ddogfennau ategol", + "lpa-list-supporting-documents-list": " Rhestr o'r ffeiliau sydd wedi'u hatodi ", + "s78-heading-para-one": "Ar gyfer ceisiadau/apeliadau Cynllunio, Ardal Gadwraeth, Adeilad Rhestredig a Hysbysebu", + "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" } \ No newline at end of file diff --git a/locales/en/myrepresentations.json b/locales/en/myrepresentations.json index f4aafebd..5c4ebbe4 100644 --- a/locales/en/myrepresentations.json +++ b/locales/en/myrepresentations.json @@ -184,5 +184,13 @@ "enf-section-question-onbehalf": "On behalf of", "enf-section-question-date": "Date", "questionnaire-yes": "Yes", - "questionnaire-no": "No" + "questionnaire-no": "No", + "lpa-questionnaire-heading": "Local Planning Authority Questionnaire", + "lpa-list-supporting-documents-heading": "List of Supporting documents", + "lpa-list-supporting-documents-list": "List of attached files", + "s78-heading-para-one": "For Planning, Conservation area, Listed Building and Advertisement applications/appeals", + "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" } \ No newline at end of file diff --git a/pages/api/file/generatepdf.js b/pages/api/file/generatepdf.js index a48d15a0..4f79998e 100644 --- a/pages/api/file/generatepdf.js +++ b/pages/api/file/generatepdf.js @@ -106,8 +106,7 @@ import { other_pdf } from "../../../components/pdftemplates/other_pdf"; export default function handler(req, res) { var checkHash = req.query.hash; - - let reqBodyobj = JSON.parse(req.body); + let reqBodyobj = req.body; //JSON.parse(req.body); console.log( "//////////////////////\nreqBodyobj" + @@ -125,6 +124,7 @@ export default function handler(req, res) { var caseRef = reqBodyobj.caseRef; var representationType = reqBodyobj.representationType; var repRaiser = reqBodyobj.lastname; + var localeSelect = reqBodyobj.locale; //console.log("there are files:", Object.keys(req.files).length); var checkquerypath = "/api/file/generatepdf"; @@ -135,24 +135,25 @@ export default function handler(req, res) { // Create Document Component const MyDocument = (values) => { + console.log(values.docProps.locale); switch (values.docProps.representationType) { case "Questionnaire": - return lpaQuestionnaire_pdf(values); + return lpaQuestionnaire_pdf(values, values.docProps.locale); break; case "Final comments": - return finalComments_pdf(values); + return finalComments_pdf(values, values.docProps.locale); break; case "Statement": - return statement_pdf(values); + return statement_pdf(values, values.docProps.locale); break; case "Written statement": - return writtenStatement_pdf(values); + return writtenStatement_pdf(values, values.docProps.locale); break; case "Other": - return other_pdf(values); + return other_pdf(values, values.docProps.locale); break; default: - return other_pdf(values); + return other_pdf(values, values.docProps.locale); } };