From 8b90dc59f005ccb394f3392a80dcc28cc0ac73e7 Mon Sep 17 00:00:00 2001 From: 0neGal Date: Tue, 28 Dec 2021 18:16:46 +0100 Subject: if no lang is set, use "en" By error I forgot to include this check... I also added in the ability for it to look for a lang file without the extra locale info on the end, i.e if "en-GB" is not found it'll try "en" --- src/lang.js | 9 +++++++-- src/lang/en-US.json | 21 --------------------- src/lang/en.json | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) delete mode 100644 src/lang/en-US.json create mode 100644 src/lang/en.json (limited to 'src') diff --git a/src/lang.js b/src/lang.js index 4e4e481..266fb8b 100644 --- a/src/lang.js +++ b/src/lang.js @@ -1,10 +1,15 @@ const fs = require("fs"); -var lang = "en-US"; +var lang = "en"; if (fs.existsSync("viper.json")) { lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang; + if (! lang) {lang = "en"} if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) { - lang = "en-US"; + if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) { + lang = lang.replace(/-.*$/, ""); + } else { + lang = "en"; + } } } diff --git a/src/lang/en-US.json b/src/lang/en-US.json deleted file mode 100644 index 2322369..0000000 --- a/src/lang/en-US.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "cli.help.help": "shows this help message", - "cli.help.debug": "opens the dev/debug tools", - "cli.help.cli": "forces the CLI to enable", - "cli.help.update": "updates Northstar from your set game path", - "cli.help.setpath": "sets your game path", - - "cli.setpath.noarg": "No argument provided for --setpath", - - - "gui.welcome": "Welcome to Viper!", - "gui.exit": "Exit", - "gui.update": "Update", - "gui.setpath": "Game Path", - - "gui.launch": "Launch", - "gui.launchvanilla": "Vanilla", - "gui.launchnorthstar": "Northstar", - - "gui.missinggamepath": "Game path is not set! Please select the path!" -} diff --git a/src/lang/en.json b/src/lang/en.json new file mode 100644 index 0000000..2322369 --- /dev/null +++ b/src/lang/en.json @@ -0,0 +1,21 @@ +{ + "cli.help.help": "shows this help message", + "cli.help.debug": "opens the dev/debug tools", + "cli.help.cli": "forces the CLI to enable", + "cli.help.update": "updates Northstar from your set game path", + "cli.help.setpath": "sets your game path", + + "cli.setpath.noarg": "No argument provided for --setpath", + + + "gui.welcome": "Welcome to Viper!", + "gui.exit": "Exit", + "gui.update": "Update", + "gui.setpath": "Game Path", + + "gui.launch": "Launch", + "gui.launchvanilla": "Vanilla", + "gui.launchnorthstar": "Northstar", + + "gui.missinggamepath": "Game path is not set! Please select the path!" +} -- cgit v1.2.3