Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function main() {
const lang = preferredLangs[0];
const translations = loadTranslations(lang);


contextMenu({
showSelectAll: false,
showSaveImageAs: true,
Expand Down
13 changes: 12 additions & 1 deletion src/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,25 @@ export function loadTranslations(locale) {
let translations = {};
try {
const filename = locale.split("-")[0];
const data = readFileSync(path.join(import.meta.dirname, "..", "locales", `${filename}.json`), "utf-8");
const data = tryLoadFile(filename) || tryLoadFile("en");
console.log("DATA", data);
translations = JSON.parse(data);
} catch (err) {
consola.error("cannot load translations", locale);
}
return translations;
}

export function tryLoadFile(name) {
const localesDir = path.join(import.meta.dirname, "..", "locales");
const filePath = path.join(localesDir, `${name}.json`);
try {
return readFileSync(filePath, "utf-8");
} catch {
return null;
}
}

export function loadConfig() {
const file = path.join(app.getPath("userData"), "config.json");
let config, configError;
Expand Down