Am 18.02.2011 um 10:55 schrieb Jürgen Spitzmüller: > Stephan Witt wrote: >> Yes, but then IMHO we should rename Language::id() to >> Language::hunspellID()... > > But Aspell uses this id() as well, doesn't it?
I meant to do it like the attached patch. Stephan
Index: src/Language.h =================================================================== --- src/Language.h (Revision 37726) +++ src/Language.h (Arbeitskopie) @@ -58,7 +58,7 @@ /// set variety (needed for rc.spellchecker_alt_lang) void setVariety(std::string const v) { variety_ = v; } /// create a unique ID from lang code and variety - std::string const id() const { + std::string const hunspellID() const { return variety_.empty() ? code_ : code_ + "-" + variety_; } /// preamble settings after babel was called std::string const & babel_postsettings() const { return babel_postsettings_; } Index: src/AspellChecker.cpp =================================================================== --- src/AspellChecker.cpp (Revision 37726) +++ src/AspellChecker.cpp (Arbeitskopie) @@ -270,14 +270,14 @@ initSessionDictionary(m, pd); } - spellers_[lang->id()] = m; + spellers_[lang->lang()] = m; return m.e_speller ? to_aspell_speller(m.e_speller) : 0; } AspellSpeller * AspellChecker::Private::speller(Language const * lang) { - Spellers::iterator it = spellers_.find(lang->id()); + Spellers::iterator it = spellers_.find(lang->lang()); if (it != spellers_.end()) return to_aspell_speller(it->second.e_speller); @@ -307,7 +307,7 @@ if (!pd) return; pd->remove(word.word()); - Spellers::iterator it = spellers_.find(word.lang()->id()); + Spellers::iterator it = spellers_.find(word.lang()->lang()); if (it != spellers_.end()) { initSessionDictionary(it->second, pd); } @@ -316,7 +316,7 @@ void AspellChecker::Private::insert(WordLangTuple const & word) { - Spellers::iterator it = spellers_.find(word.lang()->id()); + Spellers::iterator it = spellers_.find(word.lang()->lang()); if (it != spellers_.end()) { AspellSpeller * speller = to_aspell_speller(it->second.e_speller); aspell_speller_add_to_session(speller, to_utf8(word.word()).c_str(), -1); @@ -380,7 +380,7 @@ void AspellChecker::accept(WordLangTuple const & word) { - Spellers::iterator it = d->spellers_.find(word.lang()->id()); + Spellers::iterator it = d->spellers_.find(word.lang()->lang()); if (it != d->spellers_.end()) { AspellSpeller * speller = to_aspell_speller(it->second.e_speller); aspell_speller_add_to_session(speller, to_utf8(word.word()).c_str(), -1); Index: src/HunspellChecker.cpp =================================================================== --- src/HunspellChecker.cpp (Revision 37726) +++ src/HunspellChecker.cpp (Arbeitskopie) @@ -139,9 +139,9 @@ } LYXERR(Debug::FILES, "check hunspell path: " << hpath << " for language " << lang); - string h_path = addName(hpath, lang->code() + "-" + lang->variety()); + string h_path = addName(hpath, lang->hunspellID()); // first we try lang code+variety - if (!lang->variety().empty() && haveLanguageFiles(h_path)) { + if (lang->hunspellID() != lang->code() && haveLanguageFiles(h_path)) { hpath = h_path; return true; } @@ -178,7 +178,7 @@ Hunspell * HunspellChecker::Private::speller(Language const * lang) { - Spellers::iterator it = spellers_.find(lang->id()); + Spellers::iterator it = spellers_.find(lang->lang()); if (it != spellers_.end()) return it->second; @@ -189,7 +189,7 @@ Hunspell * HunspellChecker::Private::addSpeller(Language const * lang,string & path) { if (!haveDictionary(lang, path)) { - spellers_[lang->id()] = 0; + spellers_[lang->lang()] = 0; return 0; } @@ -197,7 +197,7 @@ FileName const dict(path + ".dic"); Hunspell * h = new Hunspell(affix.absFileName().c_str(), dict.absFileName().c_str()); LYXERR(Debug::FILES, "Hunspell speller for langage " << lang << " at " << dict << " found"); - spellers_[lang->id()] = h; + spellers_[lang->lang()] = h; return h; }