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