+ delete_aspell_dict_info_enumeration(dels);
+ LYXERR(Debug::FILES, "aspell dictionary: " << lang << (have ? " yes" : " no"));
+ return have;
+}
+
+
+bool AspellChecker::Private::checkAspellData(AspellConfig * config,
+ string const & basepath, string const & datapath, string const & dictpath,
+ string const & lang, string const & variety)
+{
+ FileName base(basepath);
+ bool have_dict = base.isDirectory() ;
+
+ if (have_dict) {
+ FileName data(addPath(base.absFileName(), datapath));
+ FileName dict(addPath(base.absFileName(), dictpath));
+ have_dict = dict.isDirectory() && data.isDirectory();
+ if (have_dict) {
+ LYXERR(Debug::FILES, "aspell dict-dir: " << dict);
+ LYXERR(Debug::FILES, "aspell data-dir: " << data);
+ aspell_config_replace(config, "dict-dir", dict.absFileName().c_str());
+ aspell_config_replace(config, "data-dir", data.absFileName().c_str());
+ have_dict = isValidDictionary(config, lang, variety);
+ }
+ }
+ return have_dict ;
+}
+
+
+AspellConfig * AspellChecker::Private::getConfig(string const & lang, string const & variety)
+{
+ AspellConfig * config = new_aspell_config();
+ bool have_dict = false;
+ string const sysdir = lyx::support::package().system_support().absFileName() ;
+ string const userdir = lyx::support::package().user_support().absFileName() ;
+
+ LYXERR(Debug::FILES, "aspell user dir: " << userdir);
+ have_dict = checkAspellData(config, userdir, dataDirectory(), dictDirectory(), lang, variety);
+ if (!have_dict) {
+ LYXERR(Debug::FILES, "aspell sysdir dir: " << sysdir);
+ have_dict = checkAspellData(config, sysdir, dataDirectory(), dictDirectory(), lang, variety);
+ }
+ if (!have_dict) {
+ // check for package data of OS installation
+ have_dict = checkAspellData(config, osPackageBase(), osPackageDataDirectory(), osPackageDictDirectory(), lang, variety);
+ }