Verified Commit fa11477e authored by Thibaut Broggi's avatar Thibaut Broggi
Browse files

Fix language choice for server-side generation

parent 7e635425
Pipeline #1509 passed with stage
in 39 seconds
...@@ -14,7 +14,7 @@ app.set('view engine', 'pug'); ...@@ -14,7 +14,7 @@ app.set('view engine', 'pug');
app.use(express.static('./static')); app.use(express.static('./static'));
app.use(function(req, res, next) { app.use(function(req, res, next) {
let locale = req.query.lang || req.headers['accept-language'] || ''; let locale = req.query.changeLang || req.query.lang || req.headers['accept-language'] || '';
req.i18n = new i18n(); req.i18n = new i18n();
if (locale.indexOf('en') !== -1 if (locale.indexOf('en') !== -1
&& locale.indexOf('fr') !== -1) && locale.indexOf('fr') !== -1)
......
...@@ -22,6 +22,7 @@ html(lang=locale) ...@@ -22,6 +22,7 @@ html(lang=locale)
=_('Soutenez La Quadrature du Net !') =_('Soutenez La Quadrature du Net !')
body body
form(action="./generate.png" target="_blank") form(action="./generate.png" target="_blank")
input(type="hidden" name="lang" value=locale)
nav nav
a a
img(src="./imgs/logo_lqdn.svg" alt="LQDN") img(src="./imgs/logo_lqdn.svg" alt="LQDN")
...@@ -106,9 +107,9 @@ html(lang=locale) ...@@ -106,9 +107,9 @@ html(lang=locale)
=_('GÉNÉRER') =_('GÉNÉRER')
main main
div#langPicker div#langPicker
button(type="submit" name="lang" value="fr" formaction="" formtarget="_self")#frButton button(type="submit" name="changeLang" value="fr" formaction="" formtarget="_self")#frButton
=_('Français') =_('Français')
button(type="submit" name="lang" value="en" formaction="" formtarget="_self")#enButton button(type="submit" name="changeLang" value="en" formaction="" formtarget="_self")#enButton
=_('Anglais') =_('Anglais')
div div
noscript noscript
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment