- hunspell_path += "/" + lang;
- // replace '_' with '-' as this is the convention used by hunspell.
- hunspell_path[hunspell_path.size() - 3] = '-';
- FileName const affix(hunspell_path + ".aff");
- FileName const dict(hunspell_path + ".dic");
- if (!affix.isReadableFile()) {
- // FIXME: We should indicate somehow that this language is not
- // supported.
- LYXERR(Debug::FILES, "Hunspell affix file " << affix << " does not exist");
- return 0;
+ if (lookup(lang)) return true;
+
+ string d_name = HunspellDictionaryName(lang);
+
+ LYXERR(Debug::FILES, "check hunspell path: " << hpath
+ << " for language " << lang->lang() << " with name " << d_name);
+
+ string h_path = addName(hpath, d_name);
+ // first we try lang code+variety
+ if (haveLanguageFiles(h_path)) {
+ LYXERR(Debug::FILES, " found " << h_path);
+ hpath = h_path;
+ return true;
+ }
+ // another try with code, '_' replaced by '-'
+ h_path = addName(hpath, subst(lang->code(), '_', '-'));
+ if (!haveLanguageFiles(h_path))
+ return false;
+ LYXERR(Debug::FILES, " found " << h_path);
+ hpath = h_path;
+ return true;
+}
+
+
+bool HunspellChecker::Private::haveDictionary(Language const * lang)
+{
+ bool result = false;
+
+ setUserPath(lyxrc.hunspelldir_path);
+ for (int p = 0; !result && p < maxLookupSelector(); ++p) {
+ string lpath = dictPath(p);
+ result = haveDictionary(lang, lpath);