Reputation: 11
I'm trying to test localization on a website. I can get Chrome to launch, and the settings page will show whatever I set in ChromeOptions under Language. When I go to check the order of languages based on preference, they don't always match.
The script we're using to support localization grabs the first language from the list of preferred languages in the browser to search for a json to replace all the strings in the website with, thus my problem with the language and list not matching
optionsES_US = webdriver.ChromeOptions()
optionsES_US.add_argument('intl.accept_languages')
optionsES_US.add_argument('--lang=es-US')
driverES_US = webdriver.Chrome(options=optionsES_US)
driverES_US.get(chrome://settings/languages)
es-ES and es-419, Spanish in Spain and Latin America respectively, will show up at the top of their lists
es comes up with Spanish for Spain at the top of the list
es-MX, and es-US both pop up with Latin America at the top of the list
Ideally, I'd like to expect the language set in ChromeOptions to be at the top of the list for languages besides Spanish in Spain and Spanish in Latin America, but I don't know what else I might try.
Upvotes: 1
Views: 1093
Reputation: 21
I think you are looking for "add_experimental_option"
You can try something like the following :)
esoptions = webdriver.ChromeOptions()
esoptions.add_argument('--lang=es-US')
prefs = {'intl.accept_languages': 'es-US'}
esoptions.add_experimental_option("prefs",prefs)
driver = webdriver.Chrome(options=esoptions)
I hope this helps!
Upvotes: 2