(js) Fix SCAYT automatic language selection

This commit is contained in:
Francis Lachapelle
2017-03-07 15:13:04 -05:00
parent 2428c3cb3d
commit 8c7a2cb2eb
4 changed files with 21 additions and 2 deletions

1
NEWS
View File

@@ -12,6 +12,7 @@ Bug fixes
- [core] remove attendees that have the same identity as the organizer (#3905)
- [eas] improved EAS parameters parsing (#4003)
- [eas] properly handle canceled appointments
- [web] fixed SCAYT automatic language selection in HTML editor
2.3.19 (2017-01-09)
-------------------

View File

@@ -533,7 +533,8 @@ function initMailEditor() {
CKEDITOR.replace('text',
{
language : localeCode,
scayt_sLang : localeCode
scayt_disableOptionsStorage : 'lang',
scayt_sLang : scaytLang(localeCode)
}
);
CKEDITOR.on('instanceReady', function(event) {

View File

@@ -715,7 +715,8 @@ function onMailIdentitySignatureClick(event) {
'BGColor'], ['Source']
],
language: localeCode,
scayt_sLang: localeCode });
scayt_disableOptionsStorage : 'lang',
scayt_sLang : scaytLang(localeCode) });
}
}
dialog.mailAccount = this.mailAccount;

View File

@@ -2285,6 +2285,22 @@ function _disposeDialog() {
}
}
// Pickup the first matching language supported by SCAYT
// See http://docs.ckeditor.com/#!/guide/dev_howtos_scayt
function scaytLang(locale) {
var i, langs, lang;
langs = ['en_US', 'en_GB', 'pt_BR', 'da_DK', 'nl_NL', 'en_CA', 'fi_FI', 'fr_FR', 'fr_CA', 'de_DE', 'el_GR', 'it_IT', 'nb_NO', 'pt_PT', 'es_ES', 'sv_SE'];
lang = 'en_US';
for (i = 0; i < langs.length; i++)
if (langs[i].lastIndexOf(locale, 0) == 0) {
lang = langs[i];
break;
}
return lang;
}
function readCookie(name) {
var foundCookie = null;