From bd15a54ae3ff4e57617731bd995f8d139c9e943f Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 12 Mar 2014 09:13:46 -0700 Subject: [PATCH] Use proper plural forms for some UI strings --- src/dialog_selection.cpp | 44 ++++++++++++++---------------------- src/dialog_style_manager.cpp | 7 +++--- src/font_file_lister.cpp | 8 +++++-- 3 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/dialog_selection.cpp b/src/dialog_selection.cpp index d09384c06..434dcfdae 100644 --- a/src/dialog_selection.cpp +++ b/src/dialog_selection.cpp @@ -34,9 +34,9 @@ #include "selection_controller.h" #include "utils.h" -#include #include #include +#include #include #include @@ -187,42 +187,32 @@ void DialogSelection::Process(wxCommandEvent&) { con->selectionController->GetSelectedSet(old_sel); wxString message; - size_t count = 0; + size_t count; switch (action) { case ACTION_SET: - new_sel = matches; - switch (count = new_sel.size()) { - case 0: message = _("Selection was set to no lines"); break; - case 1: message = _("Selection was set to one line"); break; - default: message = wxString::Format(_("Selection was set to %u lines"), (unsigned)count); - } + new_sel = std::move(matches); + message = (count = new_sel.size()) + ? wxString::Format(wxPLURAL("Selection was set to one line", "Selection was set to %u lines", count), (unsigned)count) + : _("Selection was set to no lines"); break; case ACTION_ADD: - set_union(old_sel.begin(), old_sel.end(), matches.begin(), matches.end(), inserter(new_sel, new_sel.begin())); - switch (count = new_sel.size() - old_sel.size()) { - case 0: message = _("No lines were added to selection"); break; - case 1: message = _("One line was added to selection"); break; - default: message = wxString::Format(_("%u lines were added to selection"), (unsigned)count); - } + boost::set_union(old_sel, matches, inserter(new_sel, new_sel.begin())); + message = (count = new_sel.size() - old_sel.size()) + ? wxString::Format(wxPLURAL("One line was added to selection", "%u lines were added to selection", count), (unsigned)count) + : _("No lines were added to selection"); break; case ACTION_SUB: - set_difference(old_sel.begin(), old_sel.end(), matches.begin(), matches.end(), inserter(new_sel, new_sel.begin())); - switch (count = old_sel.size() - new_sel.size()) { - case 0: message = _("No lines were removed from selection"); break; - case 1: message = _("One line was removed from selection"); break; - default: message = wxString::Format(_("%u lines were removed from selection"), (unsigned)count); - } - break; + boost::set_difference(old_sel, matches, inserter(new_sel, new_sel.begin())); + goto sub_message; case ACTION_INTERSECT: - set_intersection(old_sel.begin(), old_sel.end(), matches.begin(), matches.end(), inserter(new_sel, new_sel.begin())); - switch (count = old_sel.size() - new_sel.size()) { - case 0: message = _("No lines were removed from selection"); break; - case 1: message = _("One line was removed from selection"); break; - default: message = wxString::Format(_("%u lines were removed from selection"), (unsigned)count); - } + boost::set_intersection(old_sel, matches, inserter(new_sel, new_sel.begin())); + sub_message: + message = (count = old_sel.size() - new_sel.size()) + ? wxString::Format(wxPLURAL("One line was removed from selection", "%u lines were removed from selection", count), (unsigned)count) + : _("No lines were removed from selection"); break; } diff --git a/src/dialog_style_manager.cpp b/src/dialog_style_manager.cpp index ca90d17ef..da2bdc13f 100644 --- a/src/dialog_style_manager.cpp +++ b/src/dialog_style_manager.cpp @@ -144,10 +144,9 @@ void add_styles(Func1 name_checker, Func2 style_adder) { } int confirm_delete(int n, wxWindow *parent, wxString const& title) { - wxString message = n == 1 ? - _("Are you sure you want to delete this style?") : - wxString::Format(_("Are you sure you want to delete these %d styles?"), n); - return wxMessageBox(message, title, wxYES_NO | wxICON_EXCLAMATION, parent); + return wxMessageBox( + wxString::Format(wxPLURAL("Are you sure you want to delete this style?", "Are you sure you want to delete these %d styles?", n), n), + title, wxYES_NO | wxICON_EXCLAMATION, parent); } int get_single_sel(wxListBox *lb) { diff --git a/src/font_file_lister.cpp b/src/font_file_lister.cpp index 5bbfbb1e0..9db36b8a6 100644 --- a/src/font_file_lister.cpp +++ b/src/font_file_lister.cpp @@ -203,9 +203,13 @@ std::vector FontCollector::GetFontPaths(const AssFile *file) { if (missing == 0) status_callback(_("All fonts found.\n"), 1); else - status_callback(wxString::Format(_("%d fonts could not be found.\n"), missing), 2); + status_callback(wxString::Format(wxPLURAL("One font could not be found\n", "%d fonts could not be found.\n", missing), missing), 2); if (missing_glyphs != 0) - status_callback(wxString::Format(_("%d fonts were found, but were missing glyphs used in the script.\n"), missing_glyphs), 2); + status_callback(wxString::Format(wxPLURAL( + "One font was found, but was missing glyphs used in the script.\n", + "%d fonts were found, but were missing glyphs used in the script.\n", + missing_glyphs), + missing_glyphs), 2); return paths; }