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 {
|
||||
const dtfLocale = new Intl.DateTimeFormat().resolvedOptions().locale;
|
||||
if (!newLocales.includes(dtfLocale)) {
|
||||
newLocales.push(dtfLocale);
|
||||
newLocales.unshift(dtfLocale);
|
||||
}
|
||||
} catch {}
|
||||
return newLocales;
|
||||
|
|
|
@ -95,10 +95,11 @@ test.describe('DateTimeFormat locale combination behavior', () => {
|
|||
expect(navigator.language).toBe('en-GB');
|
||||
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;
|
||||
// Should resolve to en-GB since the locale combination logic works
|
||||
expect(resolvedLocale).toBe('en-GB');
|
||||
const envDefault = new Intl.DateTimeFormat().resolvedOptions().locale;
|
||||
expect([envDefault, 'en-GB', 'en']).toContain(resolvedLocale);
|
||||
});
|
||||
|
||||
test('should handle different formatting options', () => {
|
||||
|
|
Ładowanie…
Reference in New Issue