kopia lustrzana https://github.com/cheeaun/phanpy
Prioritize Intl's locale instead of navigator.languages
rodzic
55745f5b51
commit
75b8f0cf02
|
@ -6,7 +6,7 @@ function initLocales() {
|
||||||
try {
|
try {
|
||||||
const dtfLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
const dtfLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
||||||
if (!newLocales.includes(dtfLocale)) {
|
if (!newLocales.includes(dtfLocale)) {
|
||||||
newLocales.push(dtfLocale);
|
newLocales.unshift(dtfLocale);
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
return newLocales;
|
return newLocales;
|
||||||
|
|
|
@ -95,10 +95,11 @@ test.describe('DateTimeFormat locale combination behavior', () => {
|
||||||
expect(navigator.language).toBe('en-GB');
|
expect(navigator.language).toBe('en-GB');
|
||||||
expect(formatted).toBeTruthy();
|
expect(formatted).toBeTruthy();
|
||||||
|
|
||||||
// Verify that the DateTimeFormat uses en-GB (British formatting)
|
// Verify the negotiation:
|
||||||
|
// Environment default may be prioritized by implementation, otherwise user region should be respected.
|
||||||
const resolvedLocale = dtf.resolvedOptions().locale;
|
const resolvedLocale = dtf.resolvedOptions().locale;
|
||||||
// Should resolve to en-GB since the locale combination logic works
|
const envDefault = new Intl.DateTimeFormat().resolvedOptions().locale;
|
||||||
expect(resolvedLocale).toBe('en-GB');
|
expect([envDefault, 'en-GB', 'en']).toContain(resolvedLocale);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should handle different formatting options', () => {
|
test('should handle different formatting options', () => {
|
||||||
|
|
Ładowanie…
Reference in New Issue