From 03af804625e340982d3b7aef90722266aed36b3a Mon Sep 17 00:00:00 2001 From: "J.T. Sage" Date: Thu, 27 May 2021 19:20:17 -0400 Subject: [PATCH] Missed a few files. --- lib/translate.js | 72 ++++++++++++++++++++++++------------------------ renderer/ui.js | 45 +++++++++++++++--------------- 2 files changed, 59 insertions(+), 58 deletions(-) diff --git a/lib/translate.js b/lib/translate.js index d292150..53ec065 100644 --- a/lib/translate.js +++ b/lib/translate.js @@ -19,28 +19,28 @@ const path = require('path') module.exports.getSystemLocale = function () { const systemLocale = Intl.DateTimeFormat().resolvedOptions().locale switch ( systemLocale ) { - case "pt-BR" : - return "br" - case "zh-CHT": - case "zh-Hant": - case "zh-HK": - case "zh-MO": - case "zh-TW": - return "ct" - case "zh": - case "zh-CHS": - case "zh-Hans": - case "zh-CN": - case "zh-SG": - return "cs" - case "cs": - return "cz" - case "ja": - return "jp" - case "ko": - return "kr" + case 'pt-BR' : + return 'br' + case 'zh-CHT': + case 'zh-Hant': + case 'zh-HK': + case 'zh-MO': + case 'zh-TW': + return 'ct' + case 'zh': + case 'zh-CHS': + case 'zh-Hans': + case 'zh-CN': + case 'zh-SG': + return 'cs' + case 'cs': + return 'cz' + case 'ja': + return 'jp' + case 'ko': + return 'kr' default : - return systemLocale.slice(0,2) + return systemLocale.slice(0, 2) } } module.exports.translator = class translator { @@ -49,7 +49,7 @@ module.exports.translator = class translator { #langPromise = null mcVersion = null - constructor(locale = "en") { + constructor(locale = 'en') { this.#currentLocale = locale this.#langPromise = this.loadLanguages() @@ -57,7 +57,7 @@ module.exports.translator = class translator { deferCurrentLocale = () => { return this.#currentLocale } get currentLocale() { return this.#currentLocale } - set currentLocale(value) { + set currentLocale(value) { if ( value in this.#translatorStrings ) { this.#currentLocale = value } @@ -65,18 +65,18 @@ module.exports.translator = class translator { async loadLanguages() { - const langJSON = fs.readdirSync(path.join(__dirname, "..", "translations")) + const langJSON = fs.readdirSync(path.join(__dirname, '..', 'translations')) - langJSON.forEach( (thisFile) => { - if ( path.extname(thisFile) === ".json" ) { - const thisLang = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "translations", thisFile))) + langJSON.forEach( (thisFile) => { + if ( path.extname(thisFile) === '.json' ) { + const thisLang = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'translations', thisFile))) this.#translatorStrings[thisLang.language_code] = thisLang } }) } async getLangList() { - return await this.#langPromise.then(() => { + return this.#langPromise.then(() => { const returnArray = [] Object.keys(this.#translatorStrings).forEach((key) => { returnArray.push([key, this.#translatorStrings[key].language_name]) @@ -86,20 +86,20 @@ module.exports.translator = class translator { } async stringLookup(stringID) { - return await this.#langPromise.then(() => { + return this.#langPromise.then(() => { if ( stringID === null ) { return null } - stringID = stringID.toLowerCase() + const lcStringID = stringID.toLowerCase() - if ( stringID === "mc_ver_string" ) { return this.mcVersion } + if ( lcStringID === 'mc_ver_string' ) { return this.mcVersion } - if ( this.#currentLocale in this.#translatorStrings && stringID in this.#translatorStrings[this.#currentLocale] ) { - return this.#translatorStrings[this.#currentLocale][stringID] + if ( this.#currentLocale in this.#translatorStrings && lcStringID in this.#translatorStrings[this.#currentLocale] ) { + return this.#translatorStrings[this.#currentLocale][lcStringID] } - if ( stringID in this.#translatorStrings.en ) { - return this.#translatorStrings.en[stringID] + if ( lcStringID in this.#translatorStrings.en ) { + return this.#translatorStrings.en[lcStringID] } - return stringID + return lcStringID }) } } \ No newline at end of file diff --git a/renderer/ui.js b/renderer/ui.js index 081e520..32805e2 100644 --- a/renderer/ui.js +++ b/renderer/ui.js @@ -10,57 +10,57 @@ const byId = function( id ) { return document.getElementById( id ) } function toggleHideFolderOnlyError() { - const folderOnly = byId("broken_list").querySelectorAll(".just-folder-error") - const status = byId("zip_folder_switch").checked + const folderOnly = byId('broken_list').querySelectorAll('.just-folder-error') + const status = byId('zip_folder_switch').checked folderOnly.forEach((thisBroken) => { if ( status ) { - thisBroken.classList.add("d-none") + thisBroken.classList.add('d-none') } else { - thisBroken.classList.remove("d-none") + thisBroken.classList.remove('d-none') } }) } function toggleExploreColumns () { const columns = [ - "mod_name", - "mod_title", - "mod_version", - "mod_size", - "mod_is_active", - "mod_active_games", - "mod_is_used", - "mod_used_games", - "mod_full_path", - "mod_has_scripts", + 'mod_name', + 'mod_title', + 'mod_version', + 'mod_size', + 'mod_is_active', + 'mod_active_games', + 'mod_is_used', + 'mod_used_games', + 'mod_full_path', + 'mod_has_scripts', ] columns.forEach((thisCol) => { - const theseItems = byId("table_explore_parent").querySelectorAll(".col_"+thisCol) - const colStatus = byId("col_"+thisCol+"_switch").checked + const theseItems = byId('table_explore_parent').querySelectorAll(`.col_${thisCol}`) + const colStatus = byId(`col_${thisCol}_switch`).checked theseItems.forEach((thisRow) => { if ( colStatus === true ) { - thisRow.classList.remove("d-none") + thisRow.classList.remove('d-none') } else { - thisRow.classList.add("d-none") + thisRow.classList.add('d-none') } }) }) } function searchExploreClear() { - byId("explore-search").value = "" + byId('explore-search').value = '' searchExploreTable() } function searchExploreTable() { - const exploreTable = byId("table_explore").querySelectorAll("tbody>tr") - const searchTerm = byId("explore-search").value.toLowerCase() + const exploreTable = byId('table_explore').querySelectorAll('tbody>tr') + const searchTerm = byId('explore-search').value.toLowerCase() // BUG: wont-fix - zebra stripes get screwed up when searching. We'd have to remove them from the table. exploreTable.forEach((thisTD) => { - const testString = (thisTD.childNodes[0].innerText + " " + thisTD.childNodes[1].innerText).toLowerCase() + const testString = (thisTD.childNodes[0].innerText + thisTD.childNodes[1].innerText).toLowerCase() if ( testString.indexOf(searchTerm) > -1 ) { thisTD.classList.remove('d-none') @@ -73,4 +73,5 @@ function searchExploreTable() { window.addEventListener('DOMContentLoaded', () => { toggleExploreColumns() toggleHideFolderOnlyError() + searchExploreClear() }) \ No newline at end of file