[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kate] addons/search: Search&Replace: try to fix issues with plural in 18np()
From:       Alex Neundorf <null () kde ! org>
Date:       2018-04-30 20:19:35
Message-ID: E1fDFGp-0006Wv-Rx () code ! kde ! org
[Download RAW message or body]

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 singular and \
plural, +        // build the string together from two pieces...
+        QString checkedItemsStr = m_curResults->matches <= 1 ? QString()
+                                           : i18np("unused", "%1 checked", \
checkedItemCount); +
         switch (m_ui.searchPlaceCombo->currentIndex())
         {
             case CurrentFile:
-                root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in \
                current file</i></b>",
-                                                        "<b><i>%1 matches (%2 \
                checked) found in current file</i></b>",
-                                                        m_curResults->matches, \
checkedItemCount)); +                root->setData(0, Qt::DisplayRole, \
i18np("<b><i>One match found in current file</i></b>%2", +                            \
"<b><i>%1 matches (%2) found in current file</i></b>", +                              \
m_curResults->matches, checkedItemsStr));  break;
             case OpenFiles:
-                root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in \
                open files</i></b>",
-                                                        "<b><i>%1 matches  (%2 \
                checked) found in open files</i></b>",
-                                                        m_curResults->matches, \
checkedItemCount)); +                root->setData(0, Qt::DisplayRole, \
i18np("<b><i>One match found in open files</i></b>%2", +                              \
"<b><i>%1 matches (%2) found in open files</i></b>", +                                \
m_curResults->matches, checkedItemsStr));  break;
             case Folder:
-                root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in \
                folder %2</i></b>",
-                                                        "<b><i>%1 matches  (%3 \
checked) found in folder %2</i></b>", +                root->setData(0, \
Qt::DisplayRole, i18np("<b><i>One match found in folder %2</i></b>%3", +              \
                "<b><i>%1 matches  (%3) found in folder %2</i></b>",
                                                         m_curResults->matches,
                                                         m_resultBaseDir,
-                                                        checkedItemCount));
+                                                        checkedItemsStr));
                 break;
             case Project:
                 {
@@ -1560,20 +1565,20 @@ void KatePluginSearchView::updateResultsRootItem()
                     if (m_projectPluginView) {
                         projectName = \
m_projectPluginView->property("projectName").toString();  }
-                    root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found \
                in project %2 (%3)</i></b>",
-                                                            "<b><i>%1 matches  (%4 \
checked) found in project %2 (%3)</i></b>", +                    root->setData(0, \
Qt::DisplayRole, i18np("<b><i>One match found in project %2 (%3)</i></b>%4", +        \
                "<b><i>%1 matches (%4) found in project %2 (%3)</i></b>",
                                                             m_curResults->matches,
                                                             projectName,
                                                             m_resultBaseDir,
-                                                            checkedItemCount));
+                                                            checkedItemsStr));
                     break;
                 }
             case AllProjects: // "in Open Projects"
-                root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in \
                all open projects (common parent: %2)</i></b>",
-                                                        "<b><i>%1 matches  (%3 \
checked) found in all open projects (common parent: %2)</i></b>", +                \
root->setData(0, Qt::DisplayRole, i18np("<b><i>One match found in all open projects \
(common parent: %2)</i></b>%3", +                                                     \
                "<b><i>%1 matches (%3) found in all open projects (common parent: \
                %2)</i></b>",
                                                         m_curResults->matches,
                                                         m_resultBaseDir,
-                                                        checkedItemCount));
+                                                        checkedItemsStr));
                 break;
         }
     }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic