fetch google's search langs rather than ui langs

This commit is contained in:
Marc Abonce Seguin 2020-09-20 23:01:06 -07:00 committed by Alexandre Flament
parent c86504b47a
commit ecf5899153
3 changed files with 482 additions and 1441 deletions

File diff suppressed because it is too large Load diff

View file

@ -282,11 +282,11 @@ def _fetch_supported_languages(resp):
ret_val = {} ret_val = {}
dom = html.fromstring(resp.text) dom = html.fromstring(resp.text)
radio_buttons = eval_xpath(dom, '//*[@id="langSec"]//input[@name="lang"]') radio_buttons = eval_xpath(dom, '//*[@id="langSec"]//input[@name="lr"]')
for x in radio_buttons: for x in radio_buttons:
name = x.get("data-name") name = x.get("data-name")
code = x.get("value") code = x.get("value").split('_')[-1]
ret_val[code] = {"name": name} ret_val[code] = {"name": name}
return ret_val return ret_val

View file

@ -3,13 +3,9 @@
# this file is generated automatically by utils/fetch_languages.py # this file is generated automatically by utils/fetch_languages.py
language_codes = \ language_codes = \
( ('af-ZA', 'Afrikaans', '', 'Afrikaans'), ( ('af-ZA', 'Afrikaans', '', 'Afrikaans'),
('am-ET', 'አማርኛ', '', 'Amharic'),
('ar-EG', 'العربية', '', 'Arabic'), ('ar-EG', 'العربية', '', 'Arabic'),
('az-AZ', 'Azərbaycan', '', 'Azerbaijani'),
('be-BY', 'Беларуская', '', 'Belarusian'), ('be-BY', 'Беларуская', '', 'Belarusian'),
('bg-BG', 'Български', '', 'Bulgarian'), ('bg-BG', 'Български', '', 'Bulgarian'),
('bn-BD', 'বাংলা', '', 'Bangla'),
('bs-BA', 'Bosanski', '', 'Bosnian'),
('ca-ES', 'Català', '', 'Catalan'), ('ca-ES', 'Català', '', 'Catalan'),
('cs-CZ', 'Čeština', '', 'Czech'), ('cs-CZ', 'Čeština', '', 'Czech'),
('da-DK', 'Dansk', '', 'Danish'), ('da-DK', 'Dansk', '', 'Danish'),
@ -36,7 +32,6 @@ language_codes = \
('et-EE', 'Eesti', '', 'Estonian'), ('et-EE', 'Eesti', '', 'Estonian'),
('fa-IR', 'فارسی', '', 'Persian'), ('fa-IR', 'فارسی', '', 'Persian'),
('fi-FI', 'Suomi', '', 'Finnish'), ('fi-FI', 'Suomi', '', 'Finnish'),
('fo-FO', 'Føroyskt', '', 'Faroese'),
('fr', 'Français', '', 'French'), ('fr', 'Français', '', 'French'),
('fr-BE', 'Français', 'Belgique', 'French'), ('fr-BE', 'Français', 'Belgique', 'French'),
('fr-CA', 'Français', 'Canada', 'French'), ('fr-CA', 'Français', 'Canada', 'French'),
@ -50,20 +45,11 @@ language_codes = \
('is-IS', 'Íslenska', '', 'Icelandic'), ('is-IS', 'Íslenska', '', 'Icelandic'),
('it-IT', 'Italiano', '', 'Italian'), ('it-IT', 'Italiano', '', 'Italian'),
('ja-JP', '日本語', '', 'Japanese'), ('ja-JP', '日本語', '', 'Japanese'),
('ka-GE', 'ქართული', '', 'Georgian'),
('kk-KZ', 'Қазақ Тілі', '', 'Kazakh'),
('km-KH', 'ខ្មែរ', '', 'Khmer'),
('ko-KR', '한국어', '', 'Korean'), ('ko-KR', '한국어', '', 'Korean'),
('ky-KG', 'Кыргызча', '', 'Kyrgyz'),
('lo-LA', 'ລາວ', '', 'Lao'),
('lt-LT', 'Lietuvių', '', 'Lithuanian'), ('lt-LT', 'Lietuvių', '', 'Lithuanian'),
('lv-LV', 'Latviešu', '', 'Latvian'), ('lv-LV', 'Latviešu', '', 'Latvian'),
('mk-MK', 'Македонски', '', 'Macedonian'),
('mn-MN', 'Монгол', '', 'Mongolian'),
('ms-MY', 'Melayu', '', 'Malay'), ('ms-MY', 'Melayu', '', 'Malay'),
('mt-MT', 'Malti', '', 'Maltese'),
('nb-NO', 'Norsk Bokmål', '', 'Norwegian Bokmål'), ('nb-NO', 'Norsk Bokmål', '', 'Norwegian Bokmål'),
('ne-NP', 'नेपाली', '', 'Nepali'),
('nl', 'Nederlands', '', 'Dutch'), ('nl', 'Nederlands', '', 'Dutch'),
('nl-BE', 'Nederlands', 'België', 'Dutch'), ('nl-BE', 'Nederlands', 'België', 'Dutch'),
('nl-NL', 'Nederlands', 'Nederland', 'Dutch'), ('nl-NL', 'Nederlands', 'Nederland', 'Dutch'),
@ -73,23 +59,14 @@ language_codes = \
('pt-PT', 'Português', 'Portugal', 'Portuguese'), ('pt-PT', 'Português', 'Portugal', 'Portuguese'),
('ro-RO', 'Română', '', 'Romanian'), ('ro-RO', 'Română', '', 'Romanian'),
('ru-RU', 'Русский', '', 'Russian'), ('ru-RU', 'Русский', '', 'Russian'),
('rw-RW', 'Kinyarwanda', '', 'Kinyarwanda'),
('si-LK', 'සිංහල', '', 'Sinhala'),
('sk-SK', 'Slovenčina', '', 'Slovak'), ('sk-SK', 'Slovenčina', '', 'Slovak'),
('sl-SI', 'Slovenščina', '', 'Slovenian'), ('sl-SI', 'Slovenščina', '', 'Slovenian'),
('so-SO', 'Soomaali', '', 'Somali'),
('sq-AL', 'Shqip', '', 'Albanian'),
('sr-RS', 'Srpski', '', 'Serbian'), ('sr-RS', 'Srpski', '', 'Serbian'),
('sv-SE', 'Svenska', '', 'Swedish'), ('sv-SE', 'Svenska', '', 'Swedish'),
('sw-TZ', 'Kiswahili', '', 'Swahili'), ('sw-TZ', 'Kiswahili', '', 'Swahili'),
('tg-TJ', 'Тоҷикӣ', '', 'Tajik'),
('th-TH', 'ไทย', '', 'Thai'), ('th-TH', 'ไทย', '', 'Thai'),
('ti-ET', 'ትግርኛ', '', 'Tigrinya'),
('tk-TM', 'Türkmen Dili', '', 'Turkmen'),
('tr-TR', 'Türkçe', '', 'Turkish'), ('tr-TR', 'Türkçe', '', 'Turkish'),
('uk-UA', 'Українська', '', 'Ukrainian'), ('uk-UA', 'Українська', '', 'Ukrainian'),
('ur-PK', 'اردو', '', 'Urdu'),
('uz-UZ', 'OZbek', '', 'Uzbek'),
('vi-VN', 'Tiếng Việt', '', 'Vietnamese'), ('vi-VN', 'Tiếng Việt', '', 'Vietnamese'),
('zh', '中文', '', 'Chinese'), ('zh', '中文', '', 'Chinese'),
('zh-CN', '中文', '中国', 'Chinese'), ('zh-CN', '中文', '中国', 'Chinese'),