aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/index.html29
-rw-r--r--src/app/main.css6
-rw-r--r--src/app/main.js2
-rw-r--r--src/app/settings.js19
-rw-r--r--src/lang.js11
-rw-r--r--src/lang/en.json7
-rw-r--r--src/lang/es.json2
-rw-r--r--src/lang/fr.json2
-rw-r--r--src/utils.js2
9 files changed, 74 insertions, 6 deletions
diff --git a/src/app/index.html b/src/app/index.html
index 8ad5ecf..e0718a8 100644
--- a/src/app/index.html
+++ b/src/app/index.html
@@ -36,7 +36,7 @@
</button>
</div>
<div class="options">
- <h2>Northstar</h2>
+ <h2>%%gui.settings.title.ns%%</h2>
<div class="option" name="nsargs">
<div class="text">
%%gui.settings.nsargs.title%%
@@ -48,7 +48,32 @@
<input>
</div>
</div>
- <h2>Updates</h2>
+ <h2>%%gui.settings.title.language%%</h2>
+ <div class="option" name="autolang">
+ <div class="text">
+ %%gui.settings.autolang.title%%
+ <div class="desc">
+ %%gui.settings.autolang.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <button class="switch off"></button>
+ </div>
+ </div>
+ <div class="option" name="forcedlang">
+ <div class="text">
+ %%gui.settings.forcedlang.title%%
+ <div class="desc">
+ %%gui.settings.forcedlang.desc%%
+ </div>
+ </div>
+ <div class="actions">
+ <select>
+ <option value="test">Test</option>
+ </select>
+ </div>
+ </div>
+ <h2>%%gui.settings.title.updates%%</h2>
<div class="option" name="autoupdate">
<div class="text">
%%gui.settings.autoupdate.title%%
diff --git a/src/app/main.css b/src/app/main.css
index 3f542ec..87d89e0 100644
--- a/src/app/main.css
+++ b/src/app/main.css
@@ -129,7 +129,7 @@ button {
transition: 0.15s ease-in-out;
}
-.popup .el, .popup #search, .option .actions input, .popup #close, .popup .misc button {
+.popup .el, .popup #search, .option .actions select, .option .actions input, .popup #close, .popup .misc button {
color: white;
display: flex;
align-items: center;
@@ -149,7 +149,7 @@ button {
display: flex;
}
-.popup #search, .option .actions input {
+.popup #search, .option .actions input, .option .actions select {
border: none;
outline: none;
transition: filter 0.15s ease-in-out;
@@ -292,7 +292,7 @@ button {
margin-top: calc(var(--padding) / 3);
}
-.option .actions input {
+.option .actions input, .option .actions select {
width: 100%;
margin: 0px;
--spacing: calc(var(--padding) / 3);
diff --git a/src/app/main.js b/src/app/main.js
index 1688ab2..9206ae6 100644
--- a/src/app/main.js
+++ b/src/app/main.js
@@ -11,6 +11,8 @@ var settings = {
nsargs: "",
gamepath: "",
nsupdate: true,
+ autolang: true,
+ forcedlang: "en",
autoupdate: true,
zip: "/northstar.zip",
lang: navigator.language,
diff --git a/src/app/settings.js b/src/app/settings.js
index 902e57b..853cd0b 100644
--- a/src/app/settings.js
+++ b/src/app/settings.js
@@ -58,6 +58,8 @@ var Settings = {
} else {
opts[optName] = input;
}
+ } else if (options[i].querySelector(".actions select")) {
+ opts[optName] = options[i].querySelector(".actions select").value;
} else if (options[i].querySelector(".actions .switch")) {
if (options[i].querySelector(".actions .switch.on")) {
opts[optName] = true;
@@ -74,6 +76,23 @@ var Settings = {
for (let i = 0; i < options.length; i++) {
let optName = options[i].getAttribute("name");
+ if (optName == "forcedlang") {
+ let div = options[i].querySelector("select");
+
+ div.innerHTML = "";
+ let langs = fs.readdirSync(__dirname + "/../lang");
+ for (let i in langs) {
+ title = JSON.parse(fs.readFileSync(__dirname + `/../lang/${langs[i]}`, "utf8"))["lang.title"];
+ if (title) {
+ div.innerHTML += `<option value="${langs[i].replace(/\..*$/, '')}">${title}</option>`
+ }
+
+ }
+
+ div.value = settings.forcedlang;
+ continue;
+ }
+
if (settings[optName] != undefined) {
switch(typeof settings[optName]) {
case "string":
diff --git a/src/lang.js b/src/lang.js
index 8174174..041ef35 100644
--- a/src/lang.js
+++ b/src/lang.js
@@ -7,8 +7,16 @@ var langObj = {};
function _loadTranslation() {
if (fs.existsSync("viper.json")) {
- lang = JSON.parse(fs.readFileSync("viper.json", "utf8")).lang;
+ opts = JSON.parse(fs.readFileSync("viper.json", "utf8"));
+ lang = opts.lang;
+
if (! lang) {lang = "en"}
+
+ if (opts.autolang == false) {
+ lang = opts.forcedlang;
+ if (! lang) {lang = "en"}
+ }
+
if (! fs.existsSync(__dirname + `/lang/${lang}.json`)) {
if (fs.existsSync(__dirname + `/lang/${lang.replace(/-.*$/, "")}.json`)) {
lang = lang.replace(/-.*$/, "");
@@ -19,6 +27,7 @@ function _loadTranslation() {
} else {
lang = "en";
}
+
langObj = JSON.parse(fs.readFileSync(__dirname + `/lang/${lang}.json`, "utf8"));
}
diff --git a/src/lang/en.json b/src/lang/en.json
index 8defc7d..501eadd 100644
--- a/src/lang/en.json
+++ b/src/lang/en.json
@@ -1,4 +1,6 @@
{
+ "lang.title": "English",
+
"cli.help.help": "shows this help message",
"cli.help.debug": "opens the dev/debug tools",
"cli.help.version": "outputs version info",
@@ -82,9 +84,14 @@
"gui.settings.save": "Save",
"gui.settings.discard": "Discard",
"gui.settings.title.ns": "Northstar",
+ "gui.settings.title.language": "Language",
"gui.settings.title.updates": "Updates",
"gui.settings.nsargs.title": "Launch options",
"gui.settings.nsargs.desc": "Here you can add launch options for Northstar/Titanfall.",
+ "gui.settings.autolang.title": "Auto-Detect Language",
+ "gui.settings.autolang.desc": "When enabled, Viper tries to automatically detect your system language, when disabled you can manually change the language below.",
+ "gui.settings.forcedlang.title": "Language",
+ "gui.settings.forcedlang.desc": "When \"Auto-Detect Language\" is disabled, this will decide the language. Requires a restart to take effect.",
"gui.settings.autoupdate.title": "Viper Auto-Updates",
"gui.settings.autoupdate.desc": "Viper will automatically keep itself up-to-date.",
"gui.settings.nsupdate.title": "Northstar Auto-Updates",
diff --git a/src/lang/es.json b/src/lang/es.json
index a5b3685..18c00a5 100644
--- a/src/lang/es.json
+++ b/src/lang/es.json
@@ -1,4 +1,6 @@
{
+ "lang.title": "Spanish - Española",
+
"cli.help.help": "muestra este mensaje de ayuda",
"cli.help.debug": "habre las herramientas de desarrollador/depuración ",
"cli.help.version": "muestra la información de la versión",
diff --git a/src/lang/fr.json b/src/lang/fr.json
index c1797e4..018676c 100644
--- a/src/lang/fr.json
+++ b/src/lang/fr.json
@@ -1,4 +1,6 @@
{
+ "lang.title": "French - Français",
+
"cli.help.help": "affiche ce message d'aide",
"cli.help.debug": "affiche les outils de développement",
"cli.help.version": "retourne des informations sur la version du logiciel",
diff --git a/src/utils.js b/src/utils.js
index 7c1c22b..92197d1 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -23,6 +23,8 @@ var settings = {
gamepath: "",
lang: "en-US",
nsupdate: true,
+ autolang: true,
+ forcedlang: "en",
autoupdate: true,
nsargs: "-multiple",
zip: "/northstar.zip",