Skip to content

Commit

Permalink
fix type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
csmccarthy committed Oct 24, 2024
1 parent a921aa3 commit 524f259
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hooks/useLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const loadedTranslations: Translations = Object.create(null);
* This is here for a quick fix of our CM UI translation logic. Copied from the monorepo's extract_intl.ts
* This should be removed ASAP (it should be in the intl repo and imported, not in here or extract_intl.ts)
*/
export const TRANSLATE_LOCALE: { [k in LanguageKey]: string } = {
export const TRANSLATE_LOCALE = {
[LanguageKey.EsEs]: 'es',
[LanguageKey.NlNl]: 'nl',
[LanguageKey.NlBe]: 'nl',
Expand Down Expand Up @@ -85,7 +85,7 @@ export const TRANSLATE_LOCALE: { [k in LanguageKey]: string } = {
[LanguageKey.SlSl]: 'sl',
[LanguageKey.MrIn]: 'mr',
[LanguageKey.ZuZa]: 'en',
};
} as { [k in LanguageKey]: string };

/** Mapping of AWS base translation keys to list of browser locales that should use them */
export const INVERTED_TRANSLATE_LOCALE = invertSafe(TRANSLATE_LOCALE);
Expand Down Expand Up @@ -204,7 +204,7 @@ export function pickDefaultLanguage(
*/
const extendedSupportedLanguages = supportedLanguages
.map((lang: ConsentManagerLanguageKey) => getDuplicativeLocalizations(lang))
.flat();
.flat() as ConsentManagerLanguageKey[];
const nearestExtendedLanguage =
getNearestSupportedLanguage(
preferredLanguages,
Expand All @@ -214,8 +214,8 @@ export function pickDefaultLanguage(
let nearestTranslation = nearestExtendedLanguage;
if (!supportedLanguages.includes(nearestTranslation)) {
nearestTranslation = getDuplicativeLocalizations(nearestTranslation).find(
(lang) => supportedLanguages.includes(lang),
);
(lang) => supportedLanguages.includes(lang as ConsentManagerLanguageKey),
) as ConsentManagerLanguageKey;
}
return nearestTranslation;
}
Expand Down

0 comments on commit 524f259

Please sign in to comment.