From kde-commits Mon Apr 30 20:19:35 2018 From: Alex Neundorf Date: Mon, 30 Apr 2018 20:19:35 +0000 To: kde-commits Subject: [kate] addons/search: Search&Replace: try to fix issues with plural in 18np() Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=152511958929074 Git commit bd321190aedfcd4a3a19f215abf13cd3e135138f by Alex Neundorf. Committed on 30/04/2018 at 20:18. Pushed by neundorf into branch 'master'. Search&Replace: try to fix issues with plural in 18np() The number of arguments between singular and plural may differ only by up to one, so build the text together from two strings... M +20 -15 addons/search/plugin_search.cpp https://commits.kde.org/kate/bd321190aedfcd4a3a19f215abf13cd3e135138f diff --git a/addons/search/plugin_search.cpp b/addons/search/plugin_search.= cpp index b3425dd5c..11b141408 100644 --- a/addons/search/plugin_search.cpp +++ b/addons/search/plugin_search.cpp @@ -1535,24 +1535,29 @@ void KatePluginSearchView::updateResultsRootItem() } } = + // since the number of arguments may differ only by one between si= ngular and plural, + // build the string together from two pieces... + QString checkedItemsStr =3D m_curResults->matches <=3D 1 ? QString= () + : i18np("unused", "%1 checked",= checkedItemCount); + switch (m_ui.searchPlaceCombo->currentIndex()) { case CurrentFile: - root->setData(0, Qt::DisplayRole, i18np("One match f= ound in current file", - "%1 matches = (%2 checked) found in current file", - m_curResults->matc= hes, checkedItemCount)); + root->setData(0, Qt::DisplayRole, i18np("One match f= ound in current file%2", + "%1 matches = (%2) found in current file", + m_curResults->matc= hes, checkedItemsStr)); break; case OpenFiles: - root->setData(0, Qt::DisplayRole, i18np("One match f= ound in open files", - "%1 matches = (%2 checked) found in open files", - m_curResults->matc= hes, checkedItemCount)); + root->setData(0, Qt::DisplayRole, i18np("One match f= ound in open files%2", + "%1 matches = (%2) found in open files", + m_curResults->matc= hes, checkedItemsStr)); break; case Folder: - root->setData(0, Qt::DisplayRole, i18np("One match f= ound in folder %2", - "%1 matches = (%3 checked) found in folder %2", + root->setData(0, Qt::DisplayRole, i18np("One match f= ound in folder %2%3", + "%1 matches = (%3) found in folder %2", m_curResults->matc= hes, m_resultBaseDir, - checkedItemCount)); + checkedItemsStr)); break; case Project: { @@ -1560,20 +1565,20 @@ void KatePluginSearchView::updateResultsRootItem() if (m_projectPluginView) { projectName =3D m_projectPluginView->property("pro= jectName").toString(); } - root->setData(0, Qt::DisplayRole, i18np("One mat= ch found in project %2 (%3)", - "%1 matc= hes (%4 checked) found in project %2 (%3)", + root->setData(0, Qt::DisplayRole, i18np("One mat= ch found in project %2 (%3)%4", + "%1 matc= hes (%4) found in project %2 (%3)", m_curResults->= matches, projectName, m_resultBaseDi= r, - checkedItemCou= nt)); + checkedItemsSt= r)); break; } case AllProjects: // "in Open Projects" - root->setData(0, Qt::DisplayRole, i18np("One match f= ound in all open projects (common parent: %2)", - "%1 matches = (%3 checked) found in all open projects (common parent: %2)", + root->setData(0, Qt::DisplayRole, i18np("One match f= ound in all open projects (common parent: %2)%3", + "%1 matches = (%3) found in all open projects (common parent: %2)", m_curResults->matc= hes, m_resultBaseDir, - checkedItemCount)); + checkedItemsStr)); break; } }