Files
pedwfrontend/components/elements/helpers/translationHelpers.js
T

37 lines
811 B
JavaScript

import { JSONPath as jsonpath } from "jsonpath-plus";
export const getFieldTranslation = ({
label,
locale,
appealtypes,
fieldLookup
}) => {
let formObj = jsonpath({
path: "$['" + appealtypes + "']",
json: fieldLookup,
eval: true
});
return locale == "cy"
? jsonpath({
path: '$..[?(@ && @.value=="' + label + '")].value_cy',
json: formObj,
eval: true
})[0]
: label;
};
export const getPickListTranslation = ({
optionValue,
locale,
pickListLookup
}) => {
return locale == "cy"
? jsonpath({
path: '$..[?(@ && @.value=="' + optionValue + '")].value_cy',
json: pickListLookup,
eval: true
})
: optionValue;
};