Add country and interface lang to autocomplete (#866)

main
João 2022-10-26 18:20:21 +02:00 committed by GitHub
parent 6ca51ecdcb
commit e99db8db26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -188,6 +188,8 @@ class Request:
config.lang_search if config.lang_search else '' config.lang_search if config.lang_search else ''
) )
self.country = config.country if config.country else ''
# For setting Accept-language Header # For setting Accept-language Header
self.lang_interface = '' self.lang_interface = ''
if config.accept_language: if config.accept_language:
@ -244,7 +246,11 @@ class Request:
""" """
ac_query = dict(q=query) ac_query = dict(q=query)
if self.language: if self.language:
ac_query['hl'] = self.language ac_query['lr'] = self.language
if self.country:
ac_query['gl'] = self.country
if self.lang_interface:
ac_query['hl'] = self.lang_interface
response = self.send(base_url=AUTOCOMPLETE_URL, response = self.send(base_url=AUTOCOMPLETE_URL,
query=urlparse.urlencode(ac_query)).text query=urlparse.urlencode(ac_query)).text