From 6674505ca8e2ed91d1092d5d393f3566843a0533 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Mon, 4 Mar 2024 23:44:07 +0100 Subject: [PATCH 1/2] removing useless function --- frontend/src/i18n.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 02fba50..655bad5 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -32,11 +32,6 @@ function i18n(key, options) { return ret; } -async function reloadLang(){ - langs = await loadLangs(); -} -reloadLang(); - export default i18n; @@ -80,5 +75,6 @@ async function loadLangs(lang){ filteredLines[line.substr(0, split)] = line.substr(split+1, line.length); }; } - return filteredLines; + langs = filteredLines; } +await loadLangs(); -- 2.48.1 From 85523a56d91bbd24d2e9a5ea0f70d1c1b1353ce9 Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 5 Mar 2024 16:16:33 +0100 Subject: [PATCH 2/2] better export notation and exporting reloadLang in case it has to be done manually --- frontend/src/i18n.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 655bad5..a72ceee 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -22,7 +22,7 @@ let langs; * * @return :string The translated text */ -function i18n(key, options) { +export default function i18n(key, options) { let ret = langs[key]; if(options != null){ for (let key in options) { @@ -32,9 +32,6 @@ function i18n(key, options) { return ret; } -export default i18n; - - // // Those functions are utility functions use by previous exported functions. // @@ -60,7 +57,7 @@ function getCookie(key){ * @param select the language to load. could be null to fetch the cookies for an answer * if nothing is found. default to EN.txt */ -async function loadLangs(lang){ +export async function loadLangs(lang){ lang = lang != null ? lang : getCookie("lang"); lang = lang != "" ? lang : default_lang; -- 2.48.1