Skip to content

Commit

Permalink
Merge pull request #1310 from culturecreates/feature/issue-1187
Browse files Browse the repository at this point in the history
fix: added any value in data as fallback if data dont have any key ma…
  • Loading branch information
AbhishekPAnil authored Sep 10, 2024
2 parents e376af0 + 12961c0 commit 3d17c1f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils/bilingual.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ export const contentLanguageBilingual = ({ calendarContentLanguage, data, requir
* @returns {string} The string data of required content language or an empty string if no data is available.
**/

let contentLanguageKey = contentLanguageKeyMap[calendarContentLanguage[0]];
if (!data) return '';
if (requiredLanguageKey && data[requiredLanguageKey]) {
return data[requiredLanguageKey];
}

let contentLanguageKey = contentLanguageKeyMap[calendarContentLanguage[0]];
if (data[contentLanguageKey] === undefined) {
contentLanguageKey = Object.values(contentLanguageKeyMap).find((lanKey) => data[lanKey] !== undefined);
contentLanguageKey =
Object.values(contentLanguageKeyMap).find((key) => data[key] !== undefined) || Object.keys(data)[0]; // Fallback to the first key in data
}

return data[contentLanguageKey] ?? '';
Expand Down

0 comments on commit 3d17c1f

Please sign in to comment.