User language control via userlang query param

This is a draft commit enabling the testing of the support for
kiwix-serve internationalization.
This commit is contained in:
Veloman Yunkan
2022-01-17 00:28:24 +04:00
committed by Matthieu Gautier
parent 507e111f34
commit e4a0a029ff
7 changed files with 33 additions and 4 deletions

8
static/i18n/hy.json Normal file
View File

@ -0,0 +1,8 @@
{
"@metadata": {
"authors": [
]
},
"name":"Հայերեն",
"suggest-full-text-search": "որոնել '{{{SEARCH_TERMS}}}'..."
}

View File

@ -1 +1,2 @@
i18n/en.json
i18n/hy.json

View File

@ -12,9 +12,10 @@ jq(document).ready(() => {
? (new URLSearchParams(window.location.search)).get('content')
: window.location.pathname.split(`${root}/`)[1].split('/')[0];
const userlang = (new URLSearchParams(window.location.search)).get('userlang') || "en";
$( "#kiwixsearchbox" ).autocomplete({
source: `${root}/suggest?content=${bookName}`,
source: `${root}/suggest?content=${bookName}&userlang=${userlang}`,
dataType: "json",
cache: false,