{queryLocales.length === 2 &&
equalLocales(queryLocales, [locale, "en-us"]) ? (
Both
) : (
Both
)}
)}
);
}
// Return true if two arrays, independent of case and order are equal.
// E.g. `['foo', 'Bar']` is equal to `['bar', 'FoO']`
function equalLocales(list1: string[], list2: string[]) {
if (list1.length !== list2.length) {
return false;
}
const list1LC = list1.map((x) => x.toLowerCase());
const list2LC = list2.map((x) => x.toLowerCase());
return list1LC.every((x) => list2LC.includes(x));
}