From 4cb67634e0b686ce67a59e2be01f27dde2ccc3d8 Mon Sep 17 00:00:00 2001 From: Josh <8677174+bijij@users.noreply.github.com> Date: Mon, 17 Jul 2023 18:49:25 +1000 Subject: [PATCH] Fix some issues --- .eslintrc.json | 5 +---- html/options.html | 10 ---------- js/background.base.js | 6 +++++- js/localise.js | 13 +++++++++++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 73483e1..5690227 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,10 +22,7 @@ "SwitchCase": 1 } ], - "linebreak-style": [ - "error", - "unix" - ], + "linebreak-style": "off", "quotes": [ "error", "single" diff --git a/html/options.html b/html/options.html index 57737a9..ac9cf33 100644 --- a/html/options.html +++ b/html/options.html @@ -76,15 +76,5 @@ - \ No newline at end of file diff --git a/js/background.base.js b/js/background.base.js index 0c2b4d9..c5dfac6 100644 --- a/js/background.base.js +++ b/js/background.base.js @@ -1,6 +1,10 @@ 'use-strict'; -import { toI18n } from './localise.js'; +export function toI18n(str) { + return str.replace(/__MSG_(\w+)__/g, function (match, v1) { + return v1 ? chrome.i18n.getMessage(v1) : ''; + }); +} // Default options const defaultOptions = { diff --git a/js/localise.js b/js/localise.js index 1b993eb..17e5586 100644 --- a/js/localise.js +++ b/js/localise.js @@ -1,12 +1,21 @@ 'use-strict'; -export function toI18n(str) { +function toI18n(str) { return str.replace(/__MSG_(\w+)__/g, function (match, v1) { return v1 ? chrome.i18n.getMessage(v1) : ''; }); } -export function localiseObject(obj, tag) { +function localiseObject(obj, tag) { var msg = toI18n(tag); if (msg != tag) obj.innerHTML = msg; } + +var data = document.querySelectorAll('[data-localise]'); + +for (var i = 0; i < data.length; i++) { + var obj = data[i]; + var tag = obj.getAttribute('data-localise').toString(); + + localiseObject(obj, tag); +}