added translation lookups for appeal forms

This commit is contained in:
2021-10-07 07:30:46 +01:00
parent 8714d71189
commit 873a7730f1
18 changed files with 4219 additions and 34 deletions
+23 -3
View File
@@ -5,6 +5,8 @@ import xpath from "xpath";
import jsonpath from "jsonpath";
import BuildCheckField from "./buildCheckfield";
import { useSelector, shallowEqual, connect } from "react-redux";
import fieldLookup from "../../data/crmfieldlookuptranslations.json";
import {
setCaseReference,
setCurrentSection,
@@ -51,6 +53,24 @@ let BuildCheckRow = (props) => {
return dateString;
}
const fieldsTranslations = (label) => {
let { t } = useTranslation();
const router = useRouter();
const { locale } = router;
const { appealtypes } = router.query;
let formObj = jsonpath.query(fieldLookup, "$['" + appealtypes + "']");
let labelTrans =
router.locale == "cy"
? jsonpath.query(
formObj,
"$..[?(@.value=='" + label + "')].value_cy"
)
: label;
return labelTrans;
};
return (
<>
{Object.keys(rowXML).map((key, index) => {
@@ -75,7 +95,7 @@ let BuildCheckRow = (props) => {
return (
<div className="govuk-summary-list__row" key={key}>
<dt className="govuk-summary-list__key">
{rows[0].value}
{fieldsTranslations(rows[0].value)}
</dt>
<dd className="govuk-summary-list__value">
{fieldtype[0].value ==
@@ -98,10 +118,10 @@ let BuildCheckRow = (props) => {
updateCurrentSection(whichSection);
}}
>
Change
{t("newappeal:change-link-label")}
<span className="govuk-visually-hidden">
{" "}
name
{fieldsTranslations(rows[0].value)}
</span>
</a>
</dd>
+1 -1
View File
@@ -88,7 +88,7 @@ let BuildCheckSection = (props) => {
data-module="govuk-button"
onClick={() => setCurrentSection(9999)}
>
Submit appeal
{t("newappeal:submit-appeal-button")}
</a>
</div>
</div>
+2 -1
View File
@@ -245,7 +245,8 @@ let CreateCase = (props) => {
);
router.replace(
"/newappeal/" +
(router.locale = "cy" ? "/apelnewydd" : "/newappeal") +
"/" +
appTypeCollection +
"?lpa=" +
values.lpaTypes +