From 17947210b3fc9bac6ea2219655c73af07113690e Mon Sep 17 00:00:00 2001 From: Alystrasz Date: Sat, 8 Jan 2022 15:00:38 +0100 Subject: [fix] translation file is only loaded is current context didn't set up lang variable --- src/lang.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lang.js b/src/lang.js index 3e0ca42..8174174 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,7 +1,7 @@ const fs = require("fs"); const enLang = JSON.parse(fs.readFileSync(__dirname + `/lang/en.json`, "utf8")); -let lang = "en"; +let lang = ""; var langObj = {}; @@ -16,13 +16,16 @@ function _loadTranslation() { lang = "en"; } } + } else { + lang = "en"; } langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8")); } module.exports = (string) => { - _loadTranslation(); + if (lang === "") + _loadTranslation(); if (langObj[string]) { return langObj[string]; -- cgit v1.2.3