diff --git a/static/skin/i18n.js b/static/skin/i18n.js
index a5ce72d2b..72d7d3b20 100644
--- a/static/skin/i18n.js
+++ b/static/skin/i18n.js
@@ -69,6 +69,17 @@ function $t(msgId, params={}) {
}
}
+function getCookie(cookieName) {
+ const name = cookieName + "=";
+ let result;
+ decodeURIComponent(document.cookie).split('; ').forEach(val => {
+ if (val.indexOf(name) === 0) {
+ result = val.substring(name.length);
+ }
+ });
+ return result;
+}
+
const DEFAULT_UI_LANGUAGE = 'en';
@@ -76,10 +87,13 @@ Translations.load(DEFAULT_UI_LANGUAGE, /*asDefault=*/true);
function getUserLanguage() {
return new URLSearchParams(window.location.search).get('userlang')
+ || getCookie('userlang')
|| DEFAULT_UI_LANGUAGE;
}
function setUserLanguage(lang, callback) {
+ const rootPath = new URL('..', import.meta.url).pathname.replace(/\/$/, '');
+ document.cookie = `userlang=${lang};path=${rootPath};max-age=31536000`;
Translations.load(lang);
Translations.whenReady(callback);
}
diff --git a/test/server.cpp b/test/server.cpp
index 00160d2ad..d208e5f9a 100644
--- a/test/server.cpp
+++ b/test/server.cpp
@@ -59,7 +59,7 @@ const ResourceCollection resources200Compressible{
{ DYNAMIC_CONTENT, "/ROOT/skin/favicon/favicon.ico" },
{ STATIC_CONTENT, "/ROOT/skin/favicon/favicon.ico?cacheid=fba03a27" },
{ DYNAMIC_CONTENT, "/ROOT/skin/i18n.js" },
- { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=eb41f5ce" },
+ { STATIC_CONTENT, "/ROOT/skin/i18n.js?cacheid=dcf3d584" },
{ DYNAMIC_CONTENT, "/ROOT/skin/index.css" },
{ STATIC_CONTENT, "/ROOT/skin/index.css?cacheid=0f9ba34e" },
{ DYNAMIC_CONTENT, "/ROOT/skin/index.js" },
@@ -300,7 +300,7 @@ R"EXPECTEDRESULT(
-
+