Catalog *SourceDigger::Dig(const wxArrayString& paths, const wxArrayString& excludePaths, const wxArrayString& keywords, const wxString& charset) { ExtractorsDB db; db.Read(wxConfig::Get()); m_progressInfo->UpdateMessage(_("Scanning files...")); wxArrayString *all_files = FindFiles(paths, excludePaths, db); if (all_files == NULL) return NULL; TempDirectory tmpdir; wxArrayString partials; for (size_t i = 0; i < db.Data.size(); i++) { if ( all_files[i].empty() ) continue; // no files of this kind m_progressInfo->UpdateMessage( // TRANSLATORS: '%s' is replaced with the kind of the files (e.g. C++, PHP, ...) wxString::Format(_("Parsing %s files..."), db.Data[i].Name.c_str())); if (!DigFiles(tmpdir, partials, all_files[i], db.Data[i], keywords, charset)) { delete[] all_files; return NULL; } } delete[] all_files; if ( partials.empty() ) return NULL; // couldn't parse any source files wxString mergedFile = tmpdir.CreateFileName("merged.pot"); if ( !ConcatCatalogs(partials, mergedFile) ) return NULL; Catalog *c = new Catalog(mergedFile, Catalog::CreationFlag_IgnoreHeader); if ( !c->IsOk() ) { wxLogError(_("Failed to load extracted catalog.")); delete c; return NULL; } return c; }
CatalogPtr SourceDigger::Dig(const wxArrayString& paths, const wxArrayString& excludePaths, const wxArrayString& keywords, const wxString& charset, UpdateResultReason& reason) { ExtractorsDB db; db.Read(wxConfig::Get()); m_progressInfo->UpdateMessage(_("Scanning files...")); wxArrayString *all_files = FindFiles(paths, PathsToMatch(excludePaths), db); if (all_files == nullptr) { reason = UpdateResultReason::NoSourcesFound; return nullptr; } TempDirectory tmpdir; wxArrayString partials; for (size_t i = 0; i < db.Data.size(); i++) { if ( all_files[i].empty() ) continue; // no files of this kind m_progressInfo->UpdateMessage( // TRANSLATORS: '%s' is replaced with the kind of the files (e.g. C++, PHP, ...) wxString::Format(_("Parsing %s files..."), db.Data[i].Name.c_str())); if (!DigFiles(tmpdir, partials, all_files[i], db.Data[i], keywords, charset)) { delete[] all_files; return nullptr; } } delete[] all_files; wxString mergedFile; if ( !ConcatCatalogs(partials, tmpdir, &mergedFile) ) return nullptr; // couldn't parse any source files CatalogPtr c = std::make_shared<Catalog>(mergedFile, Catalog::CreationFlag_IgnoreHeader); if ( !c->IsOk() ) { wxLogError(_("Failed to load extracted catalog.")); return nullptr; } return c; }