74ac90
diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
74ac90
index 1daec44..7167dc9 100644
74ac90
--- a/lisp/textmodes/ispell.el
74ac90
+++ b/lisp/textmodes/ispell.el
74ac90
@@ -574,6 +574,40 @@ re-start Emacs."
74ac90
 		       (coding-system :tag "Coding System")))
74ac90
   :group 'ispell)
74ac90
 
74ac90
+(defvar ispell-hunspell-dictionary-equivs-alist
74ac90
+  '(("american"      "en_US")
74ac90
+    ("brasileiro"    "pt_BR")
74ac90
+    ("british"       "en_GB")
74ac90
+    ("castellano"    "es_ES")
74ac90
+    ("castellano8"   "es_ES")
74ac90
+    ("czech"         "cs_CZ")
74ac90
+    ("dansk"         "da_DK")
74ac90
+    ("deutsch"       "de_DE")
74ac90
+    ("deutsch8"      "de_DE")
74ac90
+    ("english"       "en_US")
74ac90
+    ("esperanto"     "eo")
74ac90
+    ("esperanto-tex" "eo")
74ac90
+    ("finnish"       "fi_FI")
74ac90
+    ("francais7"     "fr_FR")
74ac90
+    ("francais"      "fr_FR")
74ac90
+    ("francais-tex"  "fr_FR")
74ac90
+    ("german"        "de_DE")
74ac90
+    ("german8"       "de_DE")
74ac90
+    ("italiano"      "it_IT")
74ac90
+    ("nederlands"    "nl_NL")
74ac90
+    ("nederlands8"   "nl_NL")
74ac90
+    ("norsk"         "nn_NO")
74ac90
+    ("norsk7-tex"    "nn_NO")
74ac90
+    ("polish"        "pl_PL")
74ac90
+    ("portugues"     "pt_PT")
74ac90
+    ("russian"       "ru_RU")
74ac90
+    ("russianw"      "ru_RU")
74ac90
+    ("slovak"        "sk_SK")
74ac90
+    ("slovenian"     "sl_SI")
74ac90
+    ("svenska"       "sv_SE")
74ac90
+    ("hebrew"        "he_IL"))
74ac90
+  "Alist with matching hunspell dict names for standard dict names in
74ac90
+  `ispell-dictionary-base-alist'.")
74ac90
 
74ac90
 (defvar ispell-dictionary-base-alist
74ac90
   '((nil                                ; default
74ac90
@@ -1112,9 +1146,57 @@ aspell is used along with Emacs).")
74ac90
 		    ispell-encoding8-command)
74ac90
 	       ispell-aspell-dictionary-alist
74ac90
 	     nil))
74ac90
+	  (ispell-dictionary-base-alist ispell-dictionary-base-alist)
74ac90
 	  ispell-base-dicts-override-alist ; Override only base-dicts-alist
74ac90
 	  all-dicts-alist)
74ac90
 
74ac90
+      ;; While ispell and aspell (through aliases) use the traditional
74ac90
+      ;; dict naming originally expected by ispell.el, hunspell
74ac90
+      ;; uses locale based names with no alias.  We need to map
74ac90
+      ;; standard names to locale based names to make default dict
74ac90
+      ;; definitions available for hunspell.
74ac90
+      (if ispell-really-hunspell
74ac90
+	  (let (tmp-dicts-alist)
74ac90
+	    (dolist (adict ispell-dictionary-base-alist)
74ac90
+	      (let* ((dict-name (nth 0 adict))
74ac90
+		     (dict-equiv
74ac90
+		      (cadr (assoc dict-name
74ac90
+				   ispell-hunspell-dictionary-equivs-alist)))
74ac90
+		     (ispell-args (nth 5 adict))
74ac90
+		     (ispell-args-has-d (member "-d" ispell-args))
74ac90
+		     skip-dict)
74ac90
+		;; Remove "-d" option from `ispell-args' if present
74ac90
+		(if ispell-args-has-d
74ac90
+		    (let ((ispell-args-after-d
74ac90
+			   (cdr (cdr ispell-args-has-d)))
74ac90
+			  (ispell-args-before-d
74ac90
+			   (butlast ispell-args (length ispell-args-has-d))))
74ac90
+		      (setq ispell-args
74ac90
+			    (nconc ispell-args-before-d
74ac90
+				   ispell-args-after-d))))
74ac90
+		;; Unless default dict, re-add "-d" option with the mapped value
74ac90
+		(if dict-name
74ac90
+		    (if dict-equiv
74ac90
+			(nconc ispell-args (list "-d" dict-equiv))
74ac90
+		      (message
74ac90
+		       "ispell-set-spellchecker-params: Missing hunspell equiv for \"%s\". Skipping."
74ac90
+		       dict-name)
74ac90
+		      (setq skip-dict t)))
74ac90
+
74ac90
+		(unless skip-dict
74ac90
+		  (add-to-list 'tmp-dicts-alist
74ac90
+			       (list
74ac90
+				dict-name      ; dict name
74ac90
+				(nth 1 adict)  ; casechars
74ac90
+				(nth 2 adict)  ; not-casechars
74ac90
+				(nth 3 adict)  ; otherchars
74ac90
+				(nth 4 adict)  ; many-otherchars-p
74ac90
+				ispell-args    ; ispell-args
74ac90
+				(nth 6 adict)  ; extended-character-mode
74ac90
+				(nth 7 adict)  ; dict encoding
74ac90
+				))))
74ac90
+	      (setq ispell-dictionary-base-alist tmp-dicts-alist))))
74ac90
+
74ac90
       (run-hooks 'ispell-initialize-spellchecker-hook)
74ac90
 
74ac90
       ;; Add dicts to ``ispell-dictionary-alist'' unless already present.