From 24a54bdee48a603aa14368cb8c9eb0928a16128d Mon Sep 17 00:00:00 2001 From: Anthony Debucquoy Date: Tue, 5 Mar 2024 20:28:23 +0100 Subject: [PATCH] removing useless function & calling reloadLang properly (#52) Reviewed-on: https://git.herisson.ovh/PGL/Clyde/pulls/52 Reviewed-by: Maxime <231026@umons.ac.be> Reviewed-by: Wal Co-authored-by: Anthony Debucquoy Co-committed-by: Anthony Debucquoy --- frontend/src/i18n.js | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 02fba50..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,14 +32,6 @@ function i18n(key, options) { return ret; } -async function reloadLang(){ - langs = await loadLangs(); -} -reloadLang(); - -export default i18n; - - // // Those functions are utility functions use by previous exported functions. // @@ -65,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; @@ -80,5 +72,6 @@ async function loadLangs(lang){ filteredLines[line.substr(0, split)] = line.substr(split+1, line.length); }; } - return filteredLines; + langs = filteredLines; } +await loadLangs();