0d783c
diff -up comm-esr31/mozilla/editor/composer/src/nsEditorSpellCheck.cpp.dict-fix comm-esr31/mozilla/editor/composer/src/nsEditorSpellCheck.cpp
0d783c
--- comm-esr31/mozilla/editor/composer/src/nsEditorSpellCheck.cpp.dict-fix	2014-11-27 23:16:41.000000000 +0100
0d783c
+++ comm-esr31/mozilla/editor/composer/src/nsEditorSpellCheck.cpp	2014-12-11 13:06:02.679106492 +0100
0d783c
@@ -102,6 +102,23 @@ GetLoadContext(nsIEditor* aEditor)
0d783c
 }
0d783c
 
0d783c
 /**
0d783c
+ * Helper function for converting underscore to dash in dictionary name,
0d783c
+ * ie. en_CA to en-CA. This is required for some Linux distributions which
0d783c
+ * use underscore as separator in system-wide installed dictionaries.
0d783c
+ * We use it for nsStyleUtil::DashMatchCompare.
0d783c
+ */
0d783c
+static nsString
0d783c
+GetDictNameWithDash(const nsAString& aDictName)
0d783c
+{
0d783c
+  nsString dictNameWithDash(aDictName);
0d783c
+  int32_t underScore = dictNameWithDash.FindChar('_');
0d783c
+  if (underScore != -1) {
0d783c
+    dictNameWithDash.Replace(underScore, 1, '-');
0d783c
+  }
0d783c
+  return dictNameWithDash;
0d783c
+}
0d783c
+
0d783c
+/**
0d783c
  * Fetches the dictionary stored in content prefs and maintains state during the
0d783c
  * fetch, which is asynchronous.
0d783c
  */
0d783c
@@ -603,8 +620,8 @@ nsEditorSpellCheck::SetCurrentDictionary
0d783c
     } else {
0d783c
       langCode.Assign(aDictionary);
0d783c
     }
0d783c
-
0d783c
-    if (mPreferredLang.IsEmpty() || !nsStyleUtil::DashMatchCompare(mPreferredLang, langCode, comparator)) {
0d783c
+    if (mPreferredLang.IsEmpty() ||
0d783c
+        !nsStyleUtil::DashMatchCompare(GetDictNameWithDash(mPreferredLang), langCode, comparator)) {
0d783c
       // When user sets dictionary manually, we store this value associated
0d783c
       // with editor url.
0d783c
       StoreCurrentDictionary(mEditor, aDictionary);
0d783c
@@ -790,8 +807,8 @@ nsEditorSpellCheck::DictionaryFetched(Di
0d783c
 
0d783c
       // try dictionary.spellchecker preference if it starts with langCode (and
0d783c
       // if we haven't tried it already)
0d783c
-      if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) && 
0d783c
-          nsStyleUtil::DashMatchCompare(preferedDict, langCode, comparator)) {
0d783c
+      if (!preferedDict.IsEmpty() && !dictName.Equals(preferedDict) &&
0d783c
+          nsStyleUtil::DashMatchCompare(GetDictNameWithDash(preferedDict), langCode, comparator)) {
0d783c
         rv = SetCurrentDictionary(preferedDict);
0d783c
       }
0d783c
 
0d783c
@@ -819,8 +836,7 @@ nsEditorSpellCheck::DictionaryFetched(Di
0d783c
             // We have already tried it
0d783c
             continue;
0d783c
           }
0d783c
-
0d783c
-          if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) &&
0d783c
+          if (nsStyleUtil::DashMatchCompare(GetDictNameWithDash(dictStr), langCode, comparator) &&
0d783c
               NS_SUCCEEDED(SetCurrentDictionary(dictStr))) {
0d783c
               break;
0d783c
           }