From 4067e5c99de5f34bcb8950ce9990ebed968cad0d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Jakse?= Date: Sun, 12 Apr 2020 20:14:20 +0200 Subject: [PATCH] Stop using inline scripts breaking with some CSP setups --- index.html | 36 +----------------------------------- l10n.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 35 deletions(-) create mode 100644 l10n.js 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" +}; -- 2.30.2