aboutsummaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/ps-app.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/assets/js/ps-app.js b/assets/js/ps-app.js
index 7675ec4..33f4f99 100644
--- a/assets/js/ps-app.js
+++ b/assets/js/ps-app.js
@@ -28,15 +28,26 @@
.append('<button id="lang-switch" title="Read in English">EN</button>')
$('#lang-switch').click(function(e) {
var lang = $('html').attr('lang')
+ setLang(lang == 'fr' ? 'en' : 'fr')
+ return false
+ })
+
+ // Use ?lang=XX if available
+ var URLParams = new URLSearchParams(window.location.search);
+ if (URLParams.has('lang')) {
+ setLang(URLParams.get('lang'))
+ }
+
+ // Translate to target lang
+ function setLang(lang) {
if (lang == 'fr') {
- $('html').attr('lang', 'en')
- $(e.target).html('FR').attr('title', 'Lire en français')
- } else {
$('html').attr('lang', 'fr')
- $(e.target).html('EN').attr('title', 'Read in English')
+ $('#lang-switch').html('EN').attr('title', 'Read in English')
+ } else {
+ $('html').attr('lang', 'en')
+ $('#lang-switch').html('FR').attr('title', 'Lire en français')
}
- return false
- })
+ }
});