Merge pull request 'test(#257): normalize underscore locale tags in shared frontend loader' (#265) from dev/issue-257-shared-i18n-locale-underscore-guard into main
All checks were successful
CI / test-and-quality (push) Successful in 2m27s
All checks were successful
CI / test-and-quality (push) Successful in 2m27s
This commit was merged in pull request #265.
This commit is contained in:
@@ -8,7 +8,7 @@ export const DEFAULT_LOCALE = lobbyCatalog.locales.default as SupportedLocale;
|
||||
export const SUPPORTED_LOCALES = lobbyCatalog.locales.supported as readonly SupportedLocale[];
|
||||
|
||||
export function normalizeLocale(rawLocale?: string | null): SupportedLocale {
|
||||
const locale = (rawLocale ?? '').trim().toLowerCase();
|
||||
const locale = (rawLocale ?? '').trim().toLowerCase().replace(/_/g, '-');
|
||||
if ((SUPPORTED_LOCALES as readonly string[]).includes(locale)) {
|
||||
return locale as SupportedLocale;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@ describe('shared lobby i18n loader parity', () => {
|
||||
|
||||
it('normalizes browser-style locale tags to supported keyspace locales', () => {
|
||||
expect(normalizeLocale('da-DK')).toBe('da');
|
||||
expect(normalizeLocale('da_DK')).toBe('da');
|
||||
expect(normalizeLocale('en-US')).toBe('en');
|
||||
expect(normalizeLocale('en_US')).toBe('en');
|
||||
expect(normalizeLocale('fr-FR')).toBe('en');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user