-
Notifications
You must be signed in to change notification settings - Fork 55
Description
It would be useful if BiDi clients could fully emulate the browser’s locale, including key functionalities such as:
-
Accept-Language
HTTP Headers:- Allow the browser to send the appropriate
Accept-Language
header according to the emulated locale settings.
- Allow the browser to send the appropriate
-
JavaScript APIs (
Date
,Intl
):- Ensure that JavaScript Date and Internationalization APIs (
Intl
) reflect the correct locale-based formats (e.g., date, currency, numbers).
- Ensure that JavaScript Date and Internationalization APIs (
-
Navigator.language
:- Properly simulate the
navigator.language
value in the emulated environment.
- Properly simulate the
Expected Behavior:
The emulation should consistently apply the locale across:
- HTTP Headers: Emulating
Accept-Language
based on the locale. - JS APIs: Reflecting the locale in Date formatting and
Intl
APIs for things like number and currency formatting. - Navigator Properties: Ensuring that
navigator.language
matches the emulated locale.
Use Case:
Many modern web applications use locale information for rendering content, formatting dates/numbers, and providing localized experiences to users. Having full locale emulation is critical for testing applications in different regions and languages to ensure proper functionality.
Potential Implementation:
-
Accept-Language
Header:- Similar to the ability to set custom HTTP headers via
page.setExtraHTTPHeaders()
, but tied to the locale setting of the browser.
- Similar to the ability to set custom HTTP headers via
-
Intl
andDate
APIs:- Ensure that JavaScript's
Date
andIntl
APIs automatically reflect the locale and language settings passed during browser initialization (e.g.,page.setLocale()
).
- Ensure that JavaScript's
-
Navigator.language
:- Override the
navigator.language
property so that it correctly reflects the locale setting (e.g.,en-US
,fr-FR
).
- Override the
Impact:
Implementing this feature would significantly improve localization and internationalization (i18n) testing for web applications, as it would allow a more realistic and complete emulation of how the browser behaves with respect to different locales.