Change JSONC to JSON.
This commit is contained in:
parent
ef249519e7
commit
b0c4218bcc
34 changed files with 2644 additions and 4181 deletions
|
@ -10,7 +10,6 @@ import {networkInterfaces} from "os";
|
|||
import * as mm from 'music-metadata';
|
||||
import fetch from 'electron-fetch'
|
||||
import {wsapi} from "./wsapi";
|
||||
import {jsonc} from "jsonc";
|
||||
import {AppImageUpdater, NsisUpdater} from "electron-updater";
|
||||
import {utils} from './utils';
|
||||
const AdmZip = require("adm-zip");
|
||||
|
@ -488,15 +487,15 @@ export class BrowserWindow {
|
|||
});
|
||||
|
||||
ipcMain.on("get-i18n-listing", event => {
|
||||
let i18nFiles = readdirSync(join(__dirname, "../../src/i18n")).filter(file => file.endsWith(".jsonc"));
|
||||
let i18nFiles = readdirSync(join(__dirname, "../../src/i18n")).filter(file => file.endsWith(".json"));
|
||||
// read all the files and parse them
|
||||
let i18nListing = []
|
||||
for (let i = 0; i < i18nFiles.length; i++) {
|
||||
const i18n: { [index: string]: Object } = jsonc.parse(readFileSync(join(__dirname, `../../src/i18n/${i18nFiles[i]}`), "utf8"));
|
||||
const i18n: { [index: string]: Object } = JSON.parse(readFileSync(join(__dirname, `../../src/i18n/${i18nFiles[i]}`), "utf8"));
|
||||
i18nListing.push({
|
||||
"code": i18nFiles[i].replace(".jsonc", ""),
|
||||
"nameNative": i18n["i18n.languageName"] ?? i18nFiles[i].replace(".jsonc", ""),
|
||||
"nameEnglish": i18n["i18n.languageNameEnglish"] ?? i18nFiles[i].replace(".jsonc", ""),
|
||||
"code": i18nFiles[i].replace(".json", ""),
|
||||
"nameNative": i18n["i18n.languageName"] ?? i18nFiles[i].replace(".json", ""),
|
||||
"nameEnglish": i18n["i18n.languageNameEnglish"] ?? i18nFiles[i].replace(".json", ""),
|
||||
"category": i18n["i18n.category"] ?? "",
|
||||
"authors": i18n["i18n.authors"] ?? ""
|
||||
})
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import {jsonc} from "jsonc";
|
||||
import {Store} from "./store";
|
||||
import {BrowserWindow as bw} from "./browserwindow";
|
||||
import {app} from "electron";
|
||||
|
@ -16,6 +15,7 @@ export class utils {
|
|||
mainPath: path.join(__dirname, "../../src/main"),
|
||||
resourcePath: path.join(__dirname, "../../resources"),
|
||||
i18nPath: path.join(__dirname, "../../src/i18n"),
|
||||
i18nPathSrc: path.join(__dirname, "../../src/il8n/source"),
|
||||
ciderCache: path.resolve(app.getPath("userData"), "CiderCache"),
|
||||
themes: path.resolve(app.getPath("userData"), "Themes"),
|
||||
plugins: path.resolve(app.getPath("userData"), "Plugins"),
|
||||
|
@ -37,10 +37,10 @@ export class utils {
|
|||
* @returns {string | Object} The locale value.
|
||||
*/
|
||||
static getLocale(language: string, key?: string): string | object {
|
||||
let i18n: { [index: string]: Object } = jsonc.parse(fs.readFileSync(path.join(this.paths.i18nPath, "en_US.jsonc"), "utf8"));
|
||||
let i18n: { [index: string]: Object } = JSON.parse(fs.readFileSync(path.join(this.paths.i18nPath, "en_US.json"), "utf8"));
|
||||
|
||||
if (language !== "en_US" && fs.existsSync(path.join(this.paths.i18nPath, `${language}.jsonc`))) {
|
||||
i18n = Object.assign(i18n, jsonc.parse(fs.readFileSync(path.join(this.paths.i18nPath, `${language}.jsonc`), "utf8")));
|
||||
if (language !== "en_US" && fs.existsSync(path.join(this.paths.i18nPath, `${language}.json`))) {
|
||||
i18n = Object.assign(i18n, JSON.parse(fs.readFileSync(path.join(this.paths.i18nPath, `${language}.json`), "utf8")));
|
||||
}
|
||||
|
||||
if (key) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue