Fix choosing languges function

Searching for english is now giving all pages results.
Instead searching for a specific language different from english
is correctly returning only translated pages for the selected language.
This commit is contained in:
Alice Ferrazzi 2018-08-19 10:22:04 +09:00
parent 5f0888b8f4
commit ff2eac9f6b

View file

@ -4,7 +4,7 @@
Gentoo Wiki Gentoo Wiki
@website https://wiki.gentoo.org @website https://wiki.gentoo.org
@provide-api no (Mediawiki provides API, but Arch Wiki blocks access to it @provide-api yes
@using-api no @using-api no
@results HTML @results HTML
@stable no (HTML can change) @stable no (HTML can change)
@ -38,15 +38,20 @@ def locale_to_lang_code(locale):
lang_urls= { lang_urls= {
'en': { 'en': {
'base': 'https://wiki.gentoo.org', 'base': 'https://wiki.gentoo.org',
'search': '/index.php?title=Special:Search&offset={offset}&{query}&profile=translation&languagefilter={language}' 'search': '/index.php?title=Special:Search&offset={offset}&{query}'
},
'others': {
'base': 'https://wiki.gentoo.org',
'search': '/index.php?title=Special:Search&offset={offset}&{query}\
&profile=translation&languagefilter={language}'
} }
} }
# get base & search URLs for selected language # get base & search URLs for selected language
def get_lang_urls(language): def get_lang_urls(language):
if language in lang_urls: if language != 'en':
return lang_urls[language] return lang_urls['others']
return lang_urls['en'] return lang_urls['en']