Search code examples
javascriptgoogle-chromeinternationalizationlocalenavigator

How to change Chrome settings to test using navigator.language?


I'm trying to internationalize an app and need to test how it behaves in other locales.

However, navigator.language always returns en-US, even if I change language settings in both Chrome and OS X.

What can I do to the browser to force navigator.language to return something like es-MX?

Clarification

I'm trying to make the change as a user, through the GUI, not with code.


Solution

  • As of Sept 2021, on Mac (M1):

    To change window.navigator.language:

    1. Settings > Advanced > Language > Add Language
    2. then bring this language to the top

    To change the language of the user interface:

    (thanks to @AdamBittlingmayer above)

    defaults write com.google.Chrome AppleLanguages '(es, es-ES)'
    

    To verify:

    defaults read com.google.Chrome