From: Raphaƫl Jakse Date: Sun, 12 Apr 2020 18:14:20 +0000 (+0200) Subject: Stop using inline scripts breaking with some CSP setups X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=4067e5c99de5f34bcb8950ce9990ebed968cad0d;p=trivabble.git Stop using inline scripts breaking with some CSP setups --- diff --git a/index.html b/index.html index c853eba..9ff2d86 100644 --- a/index.html +++ b/index.html @@ -8,41 +8,7 @@ - - + diff --git a/l10n.js b/l10n.js new file mode 100644 index 0000000..a5bee0a --- /dev/null +++ b/l10n.js @@ -0,0 +1,31 @@ +window.libD = { + l10n: function () { + "use strict"; + var t = []; + + var f = function (lang, orig, translated) { + if (!orig) { + return ( + (libD.lang && t[libD.lang] && t[libD.lang][lang]) + ? t[libD.lang][lang] + : lang // lang is the default string + ); + } + + if (!t[lang]) { + t[lang] = []; + } + + t[lang][orig] = translated; + }; + + return f; + }, + lang: ( + window.navigator && ( + (navigator.language || navigator.userLanguage) + ? (navigator.language || navigator.userLanguage).split("-")[0].toLowerCase() + : "en" + ) + ) || "en" +};