From 3436b24209f7c6a6e6c009b89ae043c1badd817d Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Mon, 3 Oct 2016 18:53:02 +0300 Subject: [PATCH] [editor] Plural of bench is benches --- editor/changeset_wrapper.cpp | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/editor/changeset_wrapper.cpp b/editor/changeset_wrapper.cpp index 9929f0f16c..48ebfecf11 100644 --- a/editor/changeset_wrapper.cpp +++ b/editor/changeset_wrapper.cpp @@ -34,6 +34,8 @@ bool OsmFeatureHasTags(pugi::xml_node const & osmFt) return osmFt.child("tag"); } +string const static kVowels = "aeiouy"; + vector const static kMainTags = {"amenity", "shop", "tourism", "historic", "craft", "emergency", "barrier", "highway", "office", "leisure", "waterway", "natural", "place", "entrance", "building"}; @@ -306,15 +308,10 @@ string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount) // Format a count: "a shop" for single shop, "4 shops" for multiple. if (currentPair.second == 1) { - switch (currentPair.first.front()) - { - case 'a': - case 'e': - case 'i': - case 'y': - case 'o': ss << "an"; break; - default: ss << "a"; - } + if (kVowels.find(currentPair.first.front()) != string::npos) + ss << "an"; + else + ss << "a"; } else { @@ -322,7 +319,25 @@ string ChangesetWrapper::TypeCountToString(TTypeCount const & typeCount) } ss << ' ' << currentPair.first; if (currentPair.second > 1) + { + if (currentPair.first.size() >= 2) + { + string const lastTwo = currentPair.first.substr(currentPair.first.size() - 2); + // "bench" -> "benches", "marsh" -> "marshes", etc. + if (lastTwo.back() == 'x' || lastTwo == "sh" || lastTwo == "ch" || lastTwo == "ss") + { + ss << 'e'; + } + // "library" -> "libraries" + else if (lastTwo.back() == 'y' && kVowels.find(lastTwo.front()) == string::npos) + { + long const pos = ss.tellp(); + ss.seekp(pos - 1); + ss << "ie"; + } + } ss << 's'; + } } return ss.str(); }