diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dbbfd80..8897a7f 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -52,7 +52,19 @@ jobs: - name: Build GoofCord run: pnpm run build + - name: Load Electron Cache + uses: actions/cache/restore@v4 + with: + path: .cache + key: electron-zips.stable.${{matrix.os}} + - name: Package GoofCord env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: electron-builder ${{ matrix.arch }} --${{ matrix.name }} ${{ matrix.targets }} --publish=always + + - name: Save Electron Cache + uses: actions/cache/save@v4 + with: + path: .cache + key: electron-zips.stable.${{matrix.os}} \ No newline at end of file diff --git a/src/modules/localization.ts b/src/modules/localization.ts index 2d7d8d3..2ae4d4f 100644 --- a/src/modules/localization.ts +++ b/src/modules/localization.ts @@ -1,9 +1,19 @@ import fs from "node:fs"; import path from "node:path"; +import { ipcMain, ipcRenderer } from "electron"; const lang = "en-US"; -const localization = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "assets", "lang", lang + ".json"), "utf-8")); -const defaultLang = JSON.parse(fs.readFileSync(path.join(__dirname, "..", "assets", "lang", "en-US.json"), "utf-8")); +let localization: object; +let defaultLang: object; +if (process.type === "browser") { + localization = JSON.parse(fs.readFileSync(path.join(__dirname, "assets", "lang", lang + ".json"), "utf-8")); + defaultLang = JSON.parse(fs.readFileSync(path.join(__dirname, "assets", "lang", "en-US.json"), "utf-8")); + ipcMain.on("localization:getObjects", (event) => { + event.returnValue = [localization, defaultLang]; + }); +} else { + [localization, defaultLang] = ipcRenderer.sendSync("localization:getObjects"); +} // Gets localized string. Shortened because it's used very often export function i(key: string) {