|
|
|
@ -24,25 +24,31 @@ function getLocaleMessages(locale) {
|
|
|
|
|
return JSON.parse(fs.readFileSync(targetFile, 'utf-8'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load locale - if we can't load messages for the current locale, we
|
|
|
|
|
// default to 'en'
|
|
|
|
|
//
|
|
|
|
|
// possible locales:
|
|
|
|
|
// https://github.com/electron/electron/blob/master/docs/api/locales.md
|
|
|
|
|
let localeName = normalizeLocaleName(app.getLocale());
|
|
|
|
|
let messages;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
messages = getLocaleMessages(localeName);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log('Problem loading messages for locale ', localeName, e.stack);
|
|
|
|
|
console.log('Falling back to en locale');
|
|
|
|
|
|
|
|
|
|
localeName = 'en';
|
|
|
|
|
messages = getLocaleMessages(localeName);
|
|
|
|
|
function load() {
|
|
|
|
|
// Load locale - if we can't load messages for the current locale, we
|
|
|
|
|
// default to 'en'
|
|
|
|
|
//
|
|
|
|
|
// possible locales:
|
|
|
|
|
// https://github.com/electron/electron/blob/master/docs/api/locales.md
|
|
|
|
|
let localeName = normalizeLocaleName(app.getLocale());
|
|
|
|
|
let messages;
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
messages = getLocaleMessages(localeName);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.log('Problem loading messages for locale ', localeName, e.stack);
|
|
|
|
|
console.log('Falling back to en locale');
|
|
|
|
|
|
|
|
|
|
localeName = 'en';
|
|
|
|
|
messages = getLocaleMessages(localeName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name: localeName,
|
|
|
|
|
messages
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
name: localeName,
|
|
|
|
|
messages
|
|
|
|
|
}
|
|
|
|
|
load: load
|
|
|
|
|
};
|
|
|
|
|