Commit caa532d0 authored by Andreas Heimann's avatar Andreas Heimann

added localization

parent ad9202e7
const electron = require('electron');
const path = require('path');
const fs = require('fs');
class Locale {
constructor(localeToLoad) {
this.localePath = path.join(__dirname, "..", "..", "locale", localeToLoad + '.json');
this.fallbackPath = path.join(__dirname, "..", "..", "locale", 'en.json');
// Fallback to "en" if language is not supported
if(fs.existsSync(this.localePath)) {
this.path = this.localePath;
} else {
this.path = this.fallbackPath;
}
this.strings = parseDataFile(this.path);
console.log("Loaded Locale " + localeToLoad);
}
get(key) {
return this.strings[key];
}
}
function parseDataFile(filePath) {
try {
return JSON.parse(fs.readFileSync(filePath));
} catch(error) {
throw error;
}
}
module.exports = Locale;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment