Merge pull request #731 from yuya-oc/fix-spellchecker
Fix correct spellchecker locale is not selected for non en-US locales
This commit is contained in:
@@ -15,7 +15,6 @@ const defaultPreferences = {
|
|||||||
},
|
},
|
||||||
showUnreadBadge: true,
|
showUnreadBadge: true,
|
||||||
useSpellChecker: true,
|
useSpellChecker: true,
|
||||||
spellCheckerLocale: 'en-US',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = defaultPreferences;
|
module.exports = defaultPreferences;
|
||||||
|
@@ -12,11 +12,8 @@ function merge(base, target) {
|
|||||||
const defaultPreferences = require('./config/defaultPreferences');
|
const defaultPreferences = require('./config/defaultPreferences');
|
||||||
const upgradePreferences = require('./config/upgradePreferences');
|
const upgradePreferences = require('./config/upgradePreferences');
|
||||||
|
|
||||||
function loadDefault(spellCheckerLocale) {
|
function loadDefault() {
|
||||||
const config = JSON.parse(JSON.stringify(defaultPreferences));
|
return JSON.parse(JSON.stringify(defaultPreferences));
|
||||||
return Object.assign({}, config, {
|
|
||||||
spellCheckerLocale: spellCheckerLocale || defaultPreferences.spellCheckerLocale || 'en-US',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasBuildConfigDefaultTeams(config) {
|
function hasBuildConfigDefaultTeams(config) {
|
||||||
|
@@ -79,8 +79,7 @@ try {
|
|||||||
settings.writeFileSync(configFile, config);
|
settings.writeFileSync(configFile, config);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const spellCheckerLocale = SpellChecker.getSpellCheckerLocale(app.getLocale());
|
config = settings.loadDefault();
|
||||||
config = settings.loadDefault(null, spellCheckerLocale);
|
|
||||||
console.log('Failed to read or upgrade config.json', e);
|
console.log('Failed to read or upgrade config.json', e);
|
||||||
if (!config.teams.length && config.defaultTeam) {
|
if (!config.teams.length && config.defaultTeam) {
|
||||||
config.teams.push(config.defaultTeam);
|
config.teams.push(config.defaultTeam);
|
||||||
@@ -386,6 +385,12 @@ app.on('ready', () => {
|
|||||||
return;
|
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');
|
const appStateJson = path.join(app.getPath('userData'), 'app-state.json');
|
||||||
appState = new AppStateManager(appStateJson);
|
appState = new AppStateManager(appStateJson);
|
||||||
if (wasUpdated(appState.lastAppVersion)) {
|
if (wasUpdated(appState.lastAppVersion)) {
|
||||||
|
@@ -3,6 +3,28 @@ const path = require('path');
|
|||||||
const SpellChecker = require('../../src/main/SpellChecker');
|
const SpellChecker = require('../../src/main/SpellChecker');
|
||||||
|
|
||||||
describe('main/Spellchecker.js', function() {
|
describe('main/Spellchecker.js', function() {
|
||||||
|
describe('getSpellCheckerLocale()', () => {
|
||||||
|
it('should return recognized locale', () => {
|
||||||
|
SpellChecker.getSpellCheckerLocale('en').should.equal('en-US');
|
||||||
|
SpellChecker.getSpellCheckerLocale('en-US').should.equal('en-US');
|
||||||
|
|
||||||
|
SpellChecker.getSpellCheckerLocale('fr').should.equal('fr-FR');
|
||||||
|
SpellChecker.getSpellCheckerLocale('fr-FR').should.equal('fr-FR');
|
||||||
|
|
||||||
|
SpellChecker.getSpellCheckerLocale('de').should.equal('de-DE');
|
||||||
|
SpellChecker.getSpellCheckerLocale('de-DE').should.equal('de-DE');
|
||||||
|
|
||||||
|
SpellChecker.getSpellCheckerLocale('es').should.equal('es-ES');
|
||||||
|
SpellChecker.getSpellCheckerLocale('es-ES').should.equal('es-ES');
|
||||||
|
|
||||||
|
SpellChecker.getSpellCheckerLocale('nl').should.equal('nl-NL');
|
||||||
|
SpellChecker.getSpellCheckerLocale('nl-NL').should.equal('nl-NL');
|
||||||
|
|
||||||
|
SpellChecker.getSpellCheckerLocale('ja').should.equal('en-US');
|
||||||
|
SpellChecker.getSpellCheckerLocale('ja-JP').should.equal('en-US');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('en-US', function() {
|
describe('en-US', function() {
|
||||||
let spellchecker = null;
|
let spellchecker = null;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user