Merged PR 2420: added welsh translations of api endpoints

added welsh translations of api endpoints

Related work items: #23879
This commit is contained in:
Robert Bond
2026-06-23 10:38:24 +00:00
parent d7bb1acb10
commit 6d0bc35612
13 changed files with 171 additions and 119 deletions
+1
View File
@@ -44,6 +44,7 @@ const Case = (props) => {
showLoginCheck={props.showLoginCheck}
eventsObj={props.eventsObj}
mediaObj={props.mediaObj}
mapTarget={props.mapTarget}
/>
{showRepresentations == true && (
<RepresentationList
+6 -3
View File
@@ -66,7 +66,7 @@ import CaseNoticeBanner from "./caseNoticeBanner";
import WatchModal from "./watchmodal";
import EIADetails from "./eia";
import GoogleMapComponent from "../mapping";
import MapComponent from "../mapping";
import OSPoint from "ospoint";
const CaseSummary = (props) => {
@@ -95,7 +95,8 @@ const CaseSummary = (props) => {
currentView,
messagesObj,
docsOffline,
ticketnumber
ticketnumber,
mapTarget
} = props;
const showLoginCheck =
@@ -1533,9 +1534,11 @@ const CaseSummary = (props) => {
width: "100%"
}}
>
<GoogleMapComponent
<MapComponent
center={center}
zoom={zoom}
locale={router.locale}
mapTarget={mapTarget}
/>
{/* <OSMapComponent center={center} zoom={zoom} /> */}
</div>
+2 -6
View File
@@ -7,7 +7,7 @@ import SummaryCard from "../summary/components/SummaryCard";
import SummaryRow from "../summary/components/SummaryRow";
import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue";
import GoogleMapComponent from "../../mapping/";
import MapComponent from "../../mapping/";
import OSPoint from "ospoint";
import { getBilingualText } from "../summary/utils/helpers";
@@ -71,11 +71,7 @@ const Pinswg_dnsid = (props) => {
width: "100%"
}}
>
<GoogleMapComponent
center={center}
zoom={zoom}
/>
{/* <OSMapComponent center={center} zoom={zoom} /> */}
<MapComponent center={center} zoom={zoom} />
</div>
</div>
)}
@@ -7,7 +7,7 @@ import SummaryCard from "../summary/components/SummaryCard";
import SummaryRow from "../summary/components/SummaryRow";
import { getCaseLpaDisplayLines } from "../../utils/getCaseLpaDisplayValue";
import GoogleMapComponent from "../../mapping";
import MapComponent from "../../mapping";
import OSPoint from "ospoint";
+7 -35
View File
@@ -1,7 +1,7 @@
import { he } from "date-fns/locale";
import GoogleMapReact from "google-map-react";
const GoogleMapComponent = (props) => {
const { center, zoom } = props;
const MapComponent = (props) => {
const { center, zoom, locale, mapTarget } = props;
let data = [center];
@@ -23,31 +23,8 @@ const GoogleMapComponent = (props) => {
}
};
// console.log(
// "https://datamap.gov.wales/maps/pedw-dev/embed?center=" +
// props.center.lng +
// "," +
// props.center.lat +
// "&zoom=12#/"
// );
return (
// <GoogleMapReact
// options={function (maps) {
// return {
// overviewMapControl: true,
// mapTypeControl: true,
// };
// }}
// bootstrapURLKeys={{
// key: "AIzaSyCzeVrHt544bp_72YCFkw21eDsmI2JEsQo",
// }}
// defaultCenter={center}
// defaultZoom={zoom}
// yesIWantToUseGoogleMapApiInternals
// onGoogleApiLoaded={({ map, maps }) => ModelsMap(map, maps)}
// ></GoogleMapReact>
<>
{" "}
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
<a
@@ -62,21 +39,16 @@ const GoogleMapComponent = (props) => {
className="govuk-link govuk-link--no-underline govuk-!-font-size-14 "
target="_blank"
>
See this map on Datamap Wales
{locale === "cy"
? "Gweler y map hwn ar Datamap Cymru"
: "See this map on Datamap Wales "}
</a>
</div>
</div>
<div className="govuk-grid-row">
<div className="govuk-grid-column-full">
<iframe
src={
"https://datamap.gov.wales/maps/pedw-dev/embed?center=" +
props.center.lng +
"," +
props.center.lat +
"&zoom=7#/"
}
//src={"https://datamap.gov.wales/maps/pedw-dev/embed#/"}
src={`https://${locale === "cy" ? "mapdata.llyw.cymru" : "datamap.gov.wales"}/maps/${mapTarget}/embed?center=${center.lng},${center.lat}&zoom=7#/`}
width={"100%"}
style={{ maxHeight: "400px" }}
height={"500px"}
@@ -88,4 +60,4 @@ const GoogleMapComponent = (props) => {
);
};
export default GoogleMapComponent;
export default MapComponent;
+6 -5
View File
@@ -429,7 +429,8 @@ const DNSSearchResults = (props) => {
href={
router.locale == "cy"
? myportal == true
? "/fymhorth/dns"
? "/fymhorth/dns/" +
item.ticketnumber
: "/dns/" +
item.ticketnumber
: myportal == true
@@ -913,7 +914,7 @@ const DNSSearchResults = (props) => {
<div className="govuk-grid-column-full">
<div className="map-container map-container--expanded">
<iframe
src={`https://datamap.gov.wales/maps/${mapTarget}/embed?center=-3.6553189192727347,52.214962933659415&zoom=2#/`}
src={`https://${locale === "cy" ? "mapdata.llyw.cymru" : "datamap.gov.wales"}/maps/${mapTarget}/embed?center=-3.6553189192727347,52.214962933659415&zoom=2#/`}
width="100%"
height="600"
frameBorder="0"
@@ -924,7 +925,7 @@ const DNSSearchResults = (props) => {
className="govuk-link map-expand-link"
onClick={() => setIsMapExpanded(false)}
>
Reduce map
{t("dnsApplications:reduce-map-link")}
</button>
</div>
</div>
@@ -992,7 +993,7 @@ const DNSSearchResults = (props) => {
<div className="govuk-grid-column-one-half">
<div className="map-container">
<iframe
src={`https://datamap.gov.wales/maps/${mapTarget}/embed?center=-3.6553189192727347,52.214962933659415&zoom=2#/`}
src={`https://${locale === "cy" ? "mapdata.llyw.cymru" : "datamap.gov.wales"}/maps/${mapTarget}/embed?center=-3.6553189192727347,52.214962933659415&zoom=2#/`}
width="100%"
height="500"
frameBorder="0"
@@ -1005,7 +1006,7 @@ const DNSSearchResults = (props) => {
className="govuk-link map-expand-link mapSizeButton"
onClick={() => setIsMapExpanded(true)}
>
Enlarge map
{t("dnsApplications:enlarge-map-link")}
</button>
</div>
)}
+3 -1
View File
@@ -13,5 +13,7 @@
"result-list-heading-label-application": "Cais",
"result-list-heading-label-developer": "Datblygwr",
"result-list-heading-label-type": "Math",
"result-list-heading-label-status": "Statws"
"result-list-heading-label-status": "Statws",
"enlarge-map-link": "Ehangu'r map",
"reduce-map-link": "Lleihau'r map"
}
+3 -1
View File
@@ -13,5 +13,7 @@
"result-list-heading-label-application": "Application",
"result-list-heading-label-developer": "Developer",
"result-list-heading-label-type": "Type",
"result-list-heading-label-status": "Status"
"result-list-heading-label-status": "Status",
"enlarge-map-link": "Enlarge map",
"reduce-map-link": "Reduce map"
}
+7 -7
View File
@@ -14,7 +14,7 @@ export function middleware(request) {
font-src 'self' https://pro.fontawesome.com/ https://fonts.gstatic.com/ ;
object-src 'none';
base-uri 'self';
frame-src https://datamap.gov.wales/ https://www.youtube.com https://www.youtube-nocookie.com;
frame-src https://datamap.gov.wales/ https://mapdata.llyw.cymru/ https://www.youtube.com https://www.youtube-nocookie.com;
form-action 'self' ` +
process.env.NEXTAUTH_URL +
`;
@@ -49,17 +49,17 @@ export function middleware(request) {
// CSP policy
requestHeaders.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue,
contentSecurityPolicyHeaderValue
);
const response = NextResponse.next({
request: {
headers: requestHeaders,
},
headers: requestHeaders
}
});
response.headers.set(
"Content-Security-Policy",
contentSecurityPolicyHeaderValue,
contentSecurityPolicyHeaderValue
);
// XSS protection (legacy)
@@ -77,13 +77,13 @@ export function middleware(request) {
// Permissions lockdown
response.headers.set(
"Permissions-Policy",
"geolocation=(), camera=(), microphone=(), fullscreen=(self)",
"geolocation=(), camera=(), microphone=(), fullscreen=(self)"
);
// Enforce HTTPS via HSTS
response.headers.set(
"Strict-Transport-Security",
"max-age=63072000; includeSubDomains; preload",
"max-age=63072000; includeSubDomains; preload"
);
return response;
+59 -55
View File
@@ -22,32 +22,32 @@ const nextBuildId = require("next-build-id");
const securityHeaders = [
{
key: "X-DNS-Prefetch-Control",
value: "on",
value: "on"
},
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
value: "SAMEORIGIN"
},
{
key: "X-Content-Type-Options",
value: "nosniff",
value: "nosniff"
},
{
key: "X-Permitted-Cross-Domain-Policies",
value: "none",
value: "none"
},
{
key: "Referrer-Policy",
value: "origin-when-cross-origin", //no-referrer
value: "origin-when-cross-origin" //no-referrer
},
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
value: "max-age=63072000; includeSubDomains; preload"
},
{
key: "X-XSS-Protection",
value: "1; mode=block",
},
value: "1; mode=block"
}
// {
// key: "Content-Security-Policy",
// value: "frame-src 'self'; child-src 'self';object-src 'none'; script-src 'self' 'https://www.googletagmanager.com' unsafe-inline",
@@ -61,11 +61,11 @@ module.exports = {
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
ignoreDuringBuilds: true
},
reactStrictMode: false,
env: {
BUILD_ID_ENV: buildId,
BUILD_ID_ENV: buildId
},
swcMinify: false,
sassOptions: {
@@ -73,16 +73,16 @@ module.exports = {
"/styles/sass",
"node_modules/govuk-frontend/govuk/all",
"/styles/sass/patterns",
"/styles/sass/welshgov",
], // @import 'variables'; # loads (src/styles/varialbes.scss), you got it..
"/styles/sass/welshgov"
] // @import 'variables'; # loads (src/styles/varialbes.scss), you got it..
},
async headers() {
return [
{
// Apply these headers to all routes in your application.
source: "/(.*)?",
headers: securityHeaders,
},
headers: securityHeaders
}
];
},
generateBuildId: () => buildId,
@@ -91,71 +91,75 @@ module.exports = {
return [
{
source: "/ceisiadaudns",
destination: "/dnsapplications",
destination: "/dnsapplications"
},
{
source: "/manyliondns",
destination: "/dnsdetails",
destination: "/dnsdetails"
},
{
source: "/canlyniadauchwilio",
destination: "/searchresults",
destination: "/searchresults"
},
{
source: "/fymhorth/canlyniadauchwilio",
destination: "/myportal/searchresults",
destination: "/myportal/searchresults"
},
{
source: "/cyswllt",
destination: "/contactus",
destination: "/contactus"
},
{
source: "/fymhorth/cyswllt",
destination: "/myportal/contactus",
destination: "/myportal/contactus"
},
{
source: "/chwiliouwch",
destination: "/advancedsearch",
destination: "/advancedsearch"
},
{
source: "/chwiliadcyfeiriadau",
destination: "/addresssearch",
destination: "/addresssearch"
},
{
source: "/fymhorth/chwiliouwch",
destination: "/myportal/advancedsearch",
destination: "/myportal/advancedsearch"
},
{
source: "/fymhorth/chwiliadcyfeiriadau",
destination: "/myportal/addresssearch",
destination: "/myportal/addresssearch"
},
{
source: "/canlyniadauchwiliouwch",
destination: "/advancedsearchresults",
destination: "/advancedsearchresults"
},
{
source: "/canlyniadaucyfeiriadau",
destination: "/addresssearchresults",
destination: "/addresssearchresults"
},
{
source: "/fymhorth/canlyniadauchwiliouwch",
destination: "/myportal/advancedsearchresults",
destination: "/myportal/advancedsearchresults"
},
{
source: "/fymhorth/canlyniadaucyfeiriadau",
destination: "/myportal/addresssearchresults",
destination: "/myportal/addresssearchresults"
},
{
source: "/fymhorth/dns/:slug",
destination: "/myportal/dns/:slug"
},
{
source: "/fymhorth",
destination: "/myportal",
destination: "/myportal"
},
{
source: "/achos",
destination: "/case",
destination: "/case"
},
{
source: "/achos/:slug",
destination: "/case/:slug",
destination: "/case/:slug"
},
// {
// source: "/achos/id/:slug",
@@ -163,11 +167,11 @@ module.exports = {
// },
{
source: "/fymhorth/achos",
destination: "/myportal/case",
destination: "/myportal/case"
},
{
source: "/fymhorth/ceisiadaudns",
destination: "/myportal/dnsapplications",
destination: "/myportal/dnsapplications"
},
// {
// source: "/fymhorth/achos/id/:slug",
@@ -175,84 +179,84 @@ module.exports = {
// },
{
source: "/fymhorth/achos/:slug",
destination: "/myportal/case/:slug",
destination: "/myportal/case/:slug"
},
{
source: "/fymhorth/gweldpopeth",
destination: "/myportal/viewall",
destination: "/myportal/viewall"
},
{
source: "/fymhorth/:slug",
destination: "/myportal/:slug",
destination: "/myportal/:slug"
},
{
source: "/fymhorth/cynrychiolaeth",
destination: "/myportal/representation",
destination: "/myportal/representation"
},
{
source: "/manylionpellach",
destination: "/furtherdetails",
destination: "/furtherdetails"
},
{
source: "/allgofnodi",
destination: "/logout",
destination: "/logout"
},
{
source: "/apelnewydd",
destination: "/newappeal",
destination: "/newappeal"
},
{
source: "/apelnewydd/:path*",
destination: "/newappeal/:path*",
destination: "/newappeal/:path*"
},
{
source: "/cyfrif/cofrestr",
destination: "/account/register",
destination: "/account/register"
},
{
source: "/help/cwcis",
destination: "/help/cookies",
destination: "/help/cookies"
},
{
source: "/hygyrchedd",
destination: "/accessibility",
destination: "/accessibility"
},
{
source: "/preifatrwydd",
destination: "/privacy",
destination: "/privacy"
},
{
source: "/manylion-am-gwcis",
destination: "/details-about-cookies",
destination: "/details-about-cookies"
},
{
source: "/telerau-ac-amodau",
destination: "/terms-and-conditions",
destination: "/terms-and-conditions"
},
{
source: "/awd/mewngofnodi",
destination: "/auth/signin",
destination: "/auth/signin"
},
{
source: "/awd/mewngofnodi/ebost",
destination: "/auth/signin/email",
destination: "/auth/signin/email"
},
{
source: "/awd/gwall",
destination: "/auth/error",
destination: "/auth/error"
},
{
source: "/awd/gwirio-cais",
destination: "/auth/verify-request",
destination: "/auth/verify-request"
},
{
source: "/cyfrif/cofrestr",
destination: "/account/register",
destination: "/account/register"
},
{
source: "/awd/gwirio-cais",
destination: "/auth/verify-request",
},
destination: "/auth/verify-request"
}
// {
// source: "/cy:path*",
@@ -260,5 +264,5 @@ module.exports = {
// },
];
},
...nextTranslate(),
...nextTranslate()
};
+70 -2
View File
@@ -2,6 +2,8 @@ import { consoleLogger } from "../../../actions/core/logger";
import OSPoint from "ospoint";
import { respondError, respondSuccess } from "../middleware/apiResponse";
import { relayGetData } from "../middleware/relayForwarding";
import transLookup from "../../../data/lookuptranslations.json";
import { JSONPath as jsonpath } from "jsonpath-plus";
const renameKeys = (obj) => {
const keyMappings = {
@@ -52,7 +54,31 @@ const renameKeys = (obj) => {
obj.pinswg_sipscase[
"statuscode@OData.Community.Display.V1.FormattedValue"
];
renamedObj.description = obj.pinswg_sipscase.description;
//renamedObj.description = obj.pinswg_sipscase.description;
const descriptionText = obj?.pinswg_sipscase?.description || "";
let description = descriptionText;
let description_cy = null;
// Split on >>> first, otherwise ;
const parts = descriptionText.includes(">>>")
? descriptionText.split(">>>")
: descriptionText.includes(";")
? descriptionText.split(";")
: null;
if (parts && parts.length >= 2) {
description = parts[0].trim();
description_cy = parts.slice(1).join(" ").trim();
}
renamedObj.description = description;
if (description_cy) {
renamedObj.description_cy = description_cy;
}
renamedObj.incidentId = obj.pinswg_sipscase.incidentid;
}
@@ -63,7 +89,31 @@ const renameKeys = (obj) => {
obj.pinswg_DNSIds[
"statuscode@OData.Community.Display.V1.FormattedValue"
];
renamedObj.description = obj.pinswg_DNSIds.description;
//renamedObj.description = obj.pinswg_DNSIds.description;
const descriptionText = obj?.pinswg_DNSIds?.description || "";
let description = descriptionText;
let description_cy = null;
// Split on >>> first, otherwise ;
const parts = descriptionText.includes(">>>")
? descriptionText.split(">>>")
: descriptionText.includes(";")
? descriptionText.split(";")
: null;
if (parts && parts.length >= 2) {
description = parts[0].trim();
description_cy = parts.slice(1).join(" ").trim();
}
renamedObj.description = description;
if (description_cy) {
renamedObj.description_cy = description_cy;
}
renamedObj.incidentId = obj.pinswg_DNSIds.incidentid;
}
@@ -82,6 +132,24 @@ const renameKeys = (obj) => {
renamedObj.northing = String(renamedObj.northing);
}
renamedObj.lpaDisplayName_cy = jsonpath({
path:
'$..[?(@ && @.value=="' +
renamedObj.lpaDisplayName +
'")].value_cy',
json: transLookup,
eval: true
})[0];
renamedObj.statusCodeDescription_cy = jsonpath({
path:
'$..[?(@ && @.value=="' +
renamedObj.statusCodeDescription +
'")].value_cy',
json: transLookup,
eval: true
})[0];
return renamedObj;
};
@@ -37,7 +37,7 @@ export default async function ApiProxy(req, res) {
const queryUrl =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$select=modifiedon,pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode,pinswg_representationsubmitted,pinswg_representationtype&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
"&$select=pinswg_emailnotifications,modifiedon,pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode,pinswg_representationsubmitted,pinswg_representationtype&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
return relayGet({
queryUrl,
+5 -2
View File
@@ -38,7 +38,8 @@ const CaseHome = (props) => {
pages,
setSearchResults,
setSearchDetails,
searchResultsObj
searchResultsObj,
mapTarget
} = props;
let { t, lang } = useTranslation();
@@ -113,6 +114,7 @@ const CaseHome = (props) => {
showMaps={props.showMaps}
eventsObj={props.searchResultsObj.eventsObj}
mediaObj={props.searchResultsObj.mediaObj}
mapTarget={props.mapTarget}
/>
</div>
<Footer
@@ -261,7 +263,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
docsOffline: process.env.DOCAPI_OFFLINE || false,
messagesObj: messagesObj,
showFilteredDocs: process.env.SHOWFILTERDOCS || false,
showMaps: process.env.SHOWMAPS
showMaps: process.env.SHOWMAPS,
mapTarget: process.env.MAP_TARGET || "pedw-dev"
}
};
}