Skip to content

Commit

Permalink
feat(mosip#656): [Pooja|Vijay] render demographic details based on th…
Browse files Browse the repository at this point in the history
…e language selected and handled compatibility between 3 and 2 letter language code
  • Loading branch information
Pooja Babusing authored and Pooja Babusing committed Mar 27, 2023
1 parent 1839ed4 commit c2c441e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
7 changes: 1 addition & 6 deletions components/VcItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,7 @@ function getLocalizedField(rawField: string | LocalizedField) {
const locales: LocalizedField[] = JSON.parse(JSON.stringify(rawField));
const currentLanguage = i18n.language;
if (locales.length == 1) return locales[0]?.value;
const responseval = getVCDetailsForCurrentLanguage(
locales,
currentLanguage
);
console.log('Finalll valu>>>>>>>>>', responseval);
return responseval;
return getVCDetailsForCurrentLanguage(locales, currentLanguage);
} catch (e) {
return '';
}
Expand Down
14 changes: 4 additions & 10 deletions i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,17 @@ function getLanguageCode(code: string) {
return language;
}

function getVCDetailsForCurrentLanguage(locales, currentLanguage) {
console.log('Map>>>>>>>>>', languageCodeMap);
export function getVCDetailsForCurrentLanguage(locales, currentLanguage) {
const supportedLanguages = Object.keys(SUPPORTED_LANGUAGES);
supportedLanguages.forEach((supportedLanguage) => {
for (const index in supportedLanguages) {
const supportedLanguage = supportedLanguages[index];
if (supportedLanguage == currentLanguage) {
console.log('inside if>>>>>>>>>>>>>>>>');
const vcDetailsForCurrentLanguage = locales.filter(
(obj) => obj.language === languageCodeMap[currentLanguage]
);
console.log(
'VC response val>>>>>>>>',
vcDetailsForCurrentLanguage[0]?.value
);
return vcDetailsForCurrentLanguage[0]?.value;
}
});
}
}

// This method gets the value from iso-639-3 package, which contains key value pairs of three letter language codes[key] and two letter langugae code[value]. These values are according to iso standards.
Expand All @@ -72,7 +67,6 @@ function getThreeLetterLanguageCode(twoLetterLanguageCode) {
let threeLetterLanguageCode = Object.keys(iso6393To1).find(
(key) => iso6393To1[key] === twoLetterLanguageCode
);
console.log('Pooja threeLetterLanguageCode ', threeLetterLanguageCode);
if (!threeLetterLanguageCode) {
threeLetterLanguageCode = Object.keys(iso6393To2T).find(
(key) => iso6393To2T[key] === twoLetterLanguageCode
Expand Down

0 comments on commit c2c441e

Please sign in to comment.