diff --git a/aegisub/options.cpp b/aegisub/options.cpp index 20c7b4d5e..7b26cc218 100644 --- a/aegisub/options.cpp +++ b/aegisub/options.cpp @@ -95,7 +95,7 @@ void OptionsManager::LoadDefaults() { // Dictionary SetText(_T("Dictionaries path"),_T("dictionaries")); - SetText(_T("Dictionary language"),_T("en_US")); + SetText(_T("Spell checker language"),_T("en_US")); SetText(_T("Thesaurus language"),_T("en_US")); // Video Options diff --git a/aegisub/spellchecker_hunspell.cpp b/aegisub/spellchecker_hunspell.cpp index 3a329c4f8..e5c0f1864 100644 --- a/aegisub/spellchecker_hunspell.cpp +++ b/aegisub/spellchecker_hunspell.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include "spellchecker_hunspell.h" #include "main.h" #include "utils.h" @@ -52,7 +53,7 @@ HunspellSpellChecker::HunspellSpellChecker() { hunspell = NULL; conv = NULL; - SetLanguage(Options.AsText(_T("Dictionary Language"))); + SetLanguage(Options.AsText(_T("Spell checker Language"))); } diff --git a/aegisub/subs_edit_ctrl.cpp b/aegisub/subs_edit_ctrl.cpp index c1163a2ab..0206cd914 100644 --- a/aegisub/subs_edit_ctrl.cpp +++ b/aegisub/subs_edit_ctrl.cpp @@ -515,7 +515,7 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) { wxArrayString langs = spellchecker->GetLanguageList(); // This probably should be cached... if (langs.Count()) { // Current language - wxString curLang = Options.AsText(_T("Dictionary Language")); + wxString curLang = Options.AsText(_T("Spell checker language")); // Languages wxMenu *languageMenu = new wxMenu(); @@ -526,12 +526,12 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) { info = wxLocale::FindLanguageInfo(langs[i]); if (info) name = info->Description; else name = langs[i]; - cur = languageMenu->AppendRadioItem(EDIT_MENU_DIC_LANGS+i,name); + cur = languageMenu->AppendCheckItem(EDIT_MENU_DIC_LANGS+i,name); if (langs[i] == curLang) cur->Check(); } - menu.AppendSubMenu(languageMenu,_("Language")); + menu.AppendSubMenu(languageMenu,_("Spell checker language")); } - else menu.Append(EDIT_MENU_DIC_LANGUAGE,_("No Dictionaries Available"))->Enable(false); + else menu.Append(EDIT_MENU_DIC_LANGUAGE,_("No dictionaries available"))->Enable(false); menu.AppendSeparator(); } @@ -588,6 +588,28 @@ void SubsTextEditCtrl::ShowPopupMenu(int activePos) { // No suggestions if (!result.size()) menu.Append(EDIT_MENU_THESAURUS,_("No thesaurus suggestions"))->Enable(false); + // Language list + wxArrayString langs = thesaurus->GetLanguageList(); // This probably should be cached... + if (langs.Count()) { + // Current language + wxString curLang = Options.AsText(_T("Thesaurus language")); + + // Languages + wxMenu *languageMenu = new wxMenu(); + wxMenuItem *cur; + wxString name; + const wxLanguageInfo *info; + for (unsigned int i=0;iDescription; + else name = langs[i]; + cur = languageMenu->AppendCheckItem(EDIT_MENU_THES_LANGS+i,name); + if (langs[i].Mid(3) == curLang) cur->Check(); + } + menu.AppendSubMenu(languageMenu,_("Thesaurus language")); + } + else menu.Append(EDIT_MENU_THES_LANGUAGE,_("No thesauruses available"))->Enable(false); + // Separator menu.AppendSeparator(); } @@ -812,7 +834,7 @@ void SubsTextEditCtrl::OnSetDicLanguage(wxCommandEvent &event) { // Set dictionary int index = event.GetId() - EDIT_MENU_DIC_LANGS; spellchecker->SetLanguage(langs[index]); - Options.SetText(_T("Dictionary language"),langs[index]); + Options.SetText(_T("Spell checker language"),langs[index]); Options.Save(); // Update styling diff --git a/aegisub/thesaurus_myspell.cpp b/aegisub/thesaurus_myspell.cpp index 55b79b651..53a4fa60a 100644 --- a/aegisub/thesaurus_myspell.cpp +++ b/aegisub/thesaurus_myspell.cpp @@ -36,19 +36,22 @@ /////////// // Headers +#include +#include +#include #include "thesaurus_myspell.h" #include "mythes.hxx" #include "main.h" +#include "options.h" +#include "utils.h" /////////////// // Constructor MySpellThesaurus::MySpellThesaurus() { - wxString idxpath = AegisubApp::folderName + _T("dictionaries/th_en_US.idx"); - wxString datpath = AegisubApp::folderName + _T("dictionaries/th_en_US.dat"); - mythes = new MyThes(idxpath.mb_str(wxConvLocal),datpath.mb_str(wxConvLocal)); conv = NULL; - if (mythes) conv = new wxCSConv(wxString(mythes->get_th_encoding(),wxConvUTF8)); + mythes = NULL; + SetLanguage(Options.AsText(_T("Thesaurus Language"))); } @@ -90,7 +93,30 @@ void MySpellThesaurus::Lookup(wxString word,ThesaurusEntryArray &result) { ///////////////////// // Get language list wxArrayString MySpellThesaurus::GetLanguageList() { + // Get dir name + wxString path = DecodeRelativePath(Options.AsText(_T("Dictionaries path")),AegisubApp::folderName) + _T("/"); wxArrayString list; + + // Get file lists + wxArrayString idx; + wxDir::GetAllFiles(path,&idx,_T("*.idx"),wxDIR_FILES); + wxArrayString dat; + wxDir::GetAllFiles(path,&dat,_T("*.dat"),wxDIR_FILES); + + // For each idxtionary match, see if it can find the corresponding .dat + for (unsigned int i=0;iget_th_encoding(),wxConvUTF8)); }