Fix correct spellchecker locale not selected for non en-US locales

app.getLocale() should be called after app.on('init') event.
spellCheckerLocale is removed from defaultPreferences.js
This commit is contained in:
Yuya Ochiai
2018-03-14 23:54:21 +09:00
parent a0ab0255d6
commit bacf11e681
3 changed files with 9 additions and 8 deletions

View File

@@ -15,7 +15,6 @@ const defaultPreferences = {
},
showUnreadBadge: true,
useSpellChecker: true,
spellCheckerLocale: 'en-US',
};
module.exports = defaultPreferences;

View File

@@ -12,11 +12,8 @@ function merge(base, target) {
const defaultPreferences = require('./config/defaultPreferences');
const upgradePreferences = require('./config/upgradePreferences');
function loadDefault(spellCheckerLocale) {
const config = JSON.parse(JSON.stringify(defaultPreferences));
return Object.assign({}, config, {
spellCheckerLocale: spellCheckerLocale || defaultPreferences.spellCheckerLocale || 'en-US',
});
function loadDefault() {
return JSON.parse(JSON.stringify(defaultPreferences));
}
function hasBuildConfigDefaultTeams(config) {

View File

@@ -79,8 +79,7 @@ try {
settings.writeFileSync(configFile, config);
}
} catch (e) {
const spellCheckerLocale = SpellChecker.getSpellCheckerLocale(app.getLocale());
config = settings.loadDefault(null, spellCheckerLocale);
config = settings.loadDefault();
console.log('Failed to read or upgrade config.json', e);
if (!config.teams.length && config.defaultTeam) {
config.teams.push(config.defaultTeam);
@@ -386,6 +385,12 @@ app.on('ready', () => {
return;
}
if (!config.spellCheckerLocale) {
config.spellCheckerLocale = SpellChecker.getSpellCheckerLocale(app.getLocale());
const configFile = app.getPath('userData') + '/config.json';
settings.writeFileSync(configFile, config);
}
const appStateJson = path.join(app.getPath('userData'), 'app-state.json');
appState = new AppStateManager(appStateJson);
if (wasUpdated(appState.lastAppVersion)) {