Bug 1464605 - Remember spell check language in mailnews composer. r=IanN
authorFelix Haernstroem <filleeeh@gmail.com>
Thu, 13 Dec 2018 15:37:18 +0100
changeset 33273 6b7c8000a821
parent 33272 aad2453b9a23
child 33274 4b28c50a8eea
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersIanN
bugs1464605
Bug 1464605 - Remember spell check language in mailnews composer. r=IanN
suite/mailnews/compose/MsgComposeCommands.js
--- a/suite/mailnews/compose/MsgComposeCommands.js
+++ b/suite/mailnews/compose/MsgComposeCommands.js
@@ -2143,34 +2143,44 @@ function OnShowDictionaryMenu(aTarget)
   if (languages.length > 0)
     languages[0].setAttribute("checked", true);
 }
 
 function ChangeLanguage(event)
 {
   // We need to change the dictionary language and if we are using inline spell check,
   // recheck the message
-
   var spellChecker = InlineSpellCheckerUI.mInlineSpellChecker.spellChecker;
   if (spellChecker.GetCurrentDictionary() != event.target.value)
   {
     spellChecker.SetCurrentDictionary(event.target.value);
 
+    ComposeChangeLanguage(event.target.value)
+  }
+  event.stopPropagation();
+}
+
+function ComposeChangeLanguage(aLang)
+{
+  if (document.documentElement.getAttribute("lang") != aLang) {
+
     // Update the document language as well.
     // This is needed to synchronize the subject.
-    document.documentElement.setAttribute("lang", event.target.value);
+    document.documentElement.setAttribute("lang", aLang);
+
+    // Update spellchecker pref
+    Services.prefs.setCharPref("spellchecker.dictionary", aLang);
 
     // now check the document and the subject over again with the new dictionary
     if (InlineSpellCheckerUI.enabled)
     {
       InlineSpellCheckerUI.mInlineSpellChecker.spellCheckRange(null);
       GetMsgSubjectElement().inputField.parentNode.spellCheckerUI.mInlineSpellChecker.spellCheckRange(null);
     }
   }
-  event.stopPropagation();
 }
 
 function ToggleReturnReceipt(target)
 {
     var msgCompFields = gMsgCompose.compFields;
     if (msgCompFields)
     {
         msgCompFields.returnReceipt = ! msgCompFields.returnReceipt;