21187 add bilingual helper function
This commit is contained in:
@@ -79,3 +79,17 @@ export function linkedCasesList(linkedCasesReference) {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export const getBilingualText = (value, locale) => {
|
||||
if (!value) return "";
|
||||
|
||||
// Prefer new delimiter if present
|
||||
const delimiter = value.includes(">>>") ? ">>>" : ";";
|
||||
|
||||
// No delimiter at all → return whole string
|
||||
if (!value.includes(delimiter)) return value;
|
||||
|
||||
const [en, cy] = value.split(delimiter);
|
||||
|
||||
return locale === "cy" ? (cy ?? en) : (en ?? cy);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user