diff --git a/src/editortab.h b/src/editortab.h --- a/src/editortab.h +++ b/src/editortab.h @@ -292,6 +292,7 @@ void displayWordCount(); void clearTranslatedEntries(); + void launchPology(); void openPhasesWindow(); diff --git a/src/editortab.cpp b/src/editortab.cpp --- a/src/editortab.cpp +++ b/src/editortab.cpp @@ -462,6 +462,9 @@ ADD_ACTION_SHORTCUT("file_cleartarget", i18nc("@action:inmenu", "Clear all translated entries"), Qt::CTRL + Qt::ALT + Qt::Key_D) connect(action, &QAction::triggered, this, &EditorTab::clearTranslatedEntries); + ADD_ACTION_SHORTCUT("file_pology", i18nc("@action:inmenu", "Launch the pology command on this file"), Qt::CTRL + Qt::ALT + Qt::Key_P) + connect(action, &QAction::triggered, this, &EditorTab::launchPology); + ADD_ACTION_SHORTCUT("file_xliff2odf", i18nc("@action:inmenu", "Merge translation into OpenDocument"), Qt::CTRL + Qt::Key_Backslash) connect(action, &QAction::triggered, this, &EditorTab::mergeIntoOpenDocument); connect(this, &EditorTab::xliffFileOpened, action, &QAction::setVisible); @@ -1395,6 +1398,14 @@ CompletionStorage::instance()->scanCatalog(m_catalog); } +void EditorTab::launchPology() +{ + QString command = Project::instance()->local()->pologyCommandFile().replace(QStringLiteral("%f"), currentFilePath()); + KProcess* m_pologyProcess = new KProcess; + m_pologyProcess->setShellCommand(command); + m_pologyProcess->start(); +} + void EditorTab::clearTranslatedEntries() { switch (KMessageBox::warningYesNoCancel(this, diff --git a/src/editorui.rc b/src/editorui.rc --- a/src/editorui.rc +++ b/src/editorui.rc @@ -1,5 +1,5 @@ - + &File @@ -22,6 +22,7 @@ + diff --git a/src/project/prefs_project_pology.ui b/src/project/prefs_project_pology.ui --- a/src/project/prefs_project_pology.ui +++ b/src/project/prefs_project_pology.ui @@ -16,45 +16,64 @@ QFormLayout::ExpandingFieldsGrow - - - Enable Pology verification - - - - - - - Pology command at entry level: - - - false - - - kcfg_PologyCommandEntry - - - - - - - The Pology command to run in order to check a single entry - - + + + Enable Pology verification + + + + + + + The Pology command to run in order to check a single entry. Use the following placeholders in order to set-up the commands: %u is the entry number, %f is the file name. For instance: python /home/translator/i18n/pology/scripts/posieve.py -u %u check_rules %f + + + true + + + + + + + + 611 + 100 + + + + The Pology command to run in order to check a single entry. + + Please enter here the Pology command to be run in order to check a single entry - - - - - - - Use the following placeholders in order to set-up the commands: %u is the entry number, %f is the file name. For instance: python /home/translator/i18n/pology/scripts/posieve.py -u %u check_rules %f - - - true - - - + + + + + + + The Pology command to run in order to check a whole file. This command should include "-s lokalize", placeholder %f is the file name. For instance: python /home/translator/i18n/pology/scripts/posieve.py -s lokalize check_rules %f + + + true + + + + + + + + 611 + 100 + + + + The Pology command to run in order to check a whole file. + + + Please enter here the Pology command to be run in order to check a whole file + + + diff --git a/src/project/projectlocal.kcfg b/src/project/projectlocal.kcfg --- a/src/project/projectlocal.kcfg +++ b/src/project/projectlocal.kcfg @@ -26,5 +26,6 @@ false + diff --git a/src/project/projecttab.h b/src/project/projecttab.h --- a/src/project/projecttab.h +++ b/src/project/projecttab.h @@ -89,6 +89,7 @@ void setFilterRegExp(); void setFocus(); void scanFilesToTM(); + void pologyOnFiles(); void searchInFiles(bool templ = false); void searchInFilesInclTempl(); void openFile(); diff --git a/src/project/projecttab.cpp b/src/project/projecttab.cpp --- a/src/project/projecttab.cpp +++ b/src/project/projecttab.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -261,6 +262,9 @@ menu->addAction(i18nc("@action:inmenu", "Add to translation memory"), this, SLOT(scanFilesToTM())); menu->addAction(i18nc("@action:inmenu", "Search in files"), this, SLOT(searchInFiles())); + if (Project::instance()->local()->pologyEnabled()) { + menu->addAction(i18nc("@action:inmenu", "Launch Pology on files"), this, SLOT(pologyOnFiles())); + } if (QDir(Project::instance()->templatesRoot()).exists()) menu->addAction(i18nc("@action:inmenu", "Search in files (including templates)"), this, SLOT(searchInFilesInclTempl())); @@ -296,6 +300,25 @@ emit searchRequested(files); } +void ProjectTab::pologyOnFiles() +{ + QStringList files = m_browser->selectedItems(); + QString templatesRoot = Project::instance()->templatesRoot(); + QString filesAsString = QString(); + int i = files.size(); + while (--i >= 0) { + if (files.at(i).startsWith(templatesRoot)) + files.removeAt(i); + else if (files.at(i).endsWith(QStringLiteral(".po"))) + filesAsString += files.at(i) + QStringLiteral(" "); + } + + QString command = Project::instance()->local()->pologyCommandFile().replace(QStringLiteral("%f"), filesAsString); + KProcess* m_pologyProcess = new KProcess; + m_pologyProcess->setShellCommand(command); + m_pologyProcess->start(); +} + void ProjectTab::searchInFilesInclTempl() { searchInFiles(true);