removing useless function & calling reloadLang properly (#52)
All checks were successful
Build and test backend / Build-backend (push) Successful in 2m8s
Build and test backend / Test-backend (push) Successful in 1m25s
deploy to production / deploy-frontend (push) Successful in 32s
deploy to production / deploy-backend (push) Successful in 2m17s
Build and test FrontEnd / Build-frontend (push) Successful in 25s

Reviewed-on: #52
Reviewed-by: Maxime <231026@umons.ac.be>
Reviewed-by: Wal <karpinskiwal@gmail.com>
Co-authored-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
Co-committed-by: Anthony Debucquoy <debucquoy.anthony@gmail.com>
This commit is contained in:
Debucquoy Anthony 2024-03-05 20:28:23 +01:00 committed by Debucquoy Anthony
parent dcd1fad6ac
commit 24a54bdee4

View File

@ -22,7 +22,7 @@ let langs;
* *
* @return :string The translated text * @return :string The translated text
*/ */
function i18n(key, options) { export default function i18n(key, options) {
let ret = langs[key]; let ret = langs[key];
if(options != null){ if(options != null){
for (let key in options) { for (let key in options) {
@ -32,14 +32,6 @@ function i18n(key, options) {
return ret; return ret;
} }
async function reloadLang(){
langs = await loadLangs();
}
reloadLang();
export default i18n;
// //
// Those functions are utility functions use by previous exported functions. // 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 * @param select the language to load. could be null to fetch the cookies for an answer
* if nothing is found. default to EN.txt * 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 != null ? lang : getCookie("lang");
lang = lang != "" ? lang : default_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); filteredLines[line.substr(0, split)] = line.substr(split+1, line.length);
}; };
} }
return filteredLines; langs = filteredLines;
} }
await loadLangs();