diff --git a/languages/en.json b/languages/en.json
index 9dc3e9e..78ec32f 100644
--- a/languages/en.json
+++ b/languages/en.json
@@ -1,4 +1,5 @@
{
+ "fullLangName": "English",
"appName": "GrassClipper",
"playOfficial": "Play Official",
diff --git a/resources/index.html b/resources/index.html
index 9658db2..c4ecadc 100644
--- a/resources/index.html
+++ b/resources/index.html
@@ -62,6 +62,16 @@
Enable to server launcher tile for launcher a local Grasscutter instance.
+
+
+ Language
+
+
+
+ Select your language!
+
+
diff --git a/resources/js/index.js b/resources/js/index.js
index 00f9ccf..a3f9844 100644
--- a/resources/js/index.js
+++ b/resources/js/index.js
@@ -410,6 +410,9 @@ async function openSettings() {
killSwitch.checked = config.enableKillswitch
serverLaunch.checked = config.serverLaunchPanel
+ // Load languages
+ getLanguages()
+
// Check for updates
//checkForUpdatesAndShow()
}
@@ -492,6 +495,35 @@ async function toggleServerLaunchSection() {
Neutralino.storage.setData('config', JSON.stringify(config))
}
+async function getLanguages() {
+ const languageFiles = (await filesystem.readDirectory(`${NL_CWD}/languages`)).filter(file => file.entry.endsWith('.json'))
+
+
+ // Load all languages as options
+ for (const file of languageFiles) {
+ const fullLanguageName = JSON.parse(await filesystem.readFile(`${NL_CWD}/languages/${file.entry}`)).fullLangName
+ const lang = file.entry.split('.json')[0]
+
+ const option = document.createElement('option')
+ option.value = lang
+ option.innerHTML = fullLanguageName
+
+ document.querySelector('#languageSelect').appendChild(option)
+ }
+}
+
+async function handleLanguageChange(elm) {
+ const list = elm
+ const config = await getCfg()
+
+ // Set language in config
+ config.language = list.value
+ Neutralino.storage.setData('config', JSON.stringify(config))
+
+ // Force refresh of application, no need for restart!
+ window.location.reload()
+}
+
/**
* Set the game folder by opening a folder picker
*/
diff --git a/resources/js/translation.js b/resources/js/translation.js
index b02bf8f..bcf78ec 100644
--- a/resources/js/translation.js
+++ b/resources/js/translation.js
@@ -15,7 +15,7 @@ async function doTranslation() {
const localization = await filesystem.readFile(`${NL_CWD}/languages/${config.language}.json`)
localeObj = JSON.parse(localization)
- const set = (id, localeString) => document.getElementById(id).innerHTML = localeString
+ const set = (id, localeString) => document.getElementById(id).innerHTML = localeString || 'UNKNOWN'
// Begin filling in values
set('titleSection', localeObj.appName)
diff --git a/resources/style/index.css b/resources/style/index.css
index bb8ab8d..1da6c9c 100644
--- a/resources/style/index.css
+++ b/resources/style/index.css
@@ -51,7 +51,7 @@ body {
#settingsPanel {
width: 35%;
- height: 60%;
+ height: 70%;
}
#fullSettingsTitle {