From 6979958908e0827f6ac1892a71fc362516450e7f Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 4 Sep 2022 22:35:07 +0300 Subject: [PATCH] use localization cache --- js/localization.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/localization.js b/js/localization.js index af020069..24f60d28 100644 --- a/js/localization.js +++ b/js/localization.js @@ -11,12 +11,14 @@ */ function t(key, params, strict = true) { - const s = chrome.i18n.getMessage(key, params); + const s = !params && t.cache[key] + || (t.cache[key] = chrome.i18n.getMessage(key, params)); if (!s && strict) throw `Missing string "${key}"`; return s; } Object.assign(t, { + cache: {}, template: {}, ALLOWED_TAGS: ['a', 'b', 'code', 'i', 'sub', 'sup', 'wbr'], RX_WORD_BREAK: new RegExp([