Merged PR 2449: language helper

Related work items: #23754
This commit is contained in:
Robert Bond
2026-07-01 11:29:15 +00:00
parent 49aa258fd9
commit e864049bec
63 changed files with 4008 additions and 6094 deletions
@@ -0,0 +1,29 @@
import { JSONPath as jsonpath } from "jsonpath-plus";
const hasValue = (value) =>
value !== null && value !== undefined && value !== "";
export const resolveCrmDisplayValue = ({
value,
locale,
translations,
fallbackValue
}) => {
if (!hasValue(value)) {
return fallbackValue;
}
if (locale !== "cy") {
return value;
}
const matches = jsonpath({
path: `$..[?(@ && @.value==${JSON.stringify(String(value))})].value_cy`,
json: translations,
eval: true
});
return matches[0] ?? value;
};
export default resolveCrmDisplayValue;