diff options
author | Ilya Zverev <zverik@textual.ru> | 2016-10-03 18:53:02 +0300 |
---|---|---|
committer | Ilya Zverev <zverik@textual.ru> | 2016-10-04 11:41:07 +0300 |
commit | 3436b24209f7c6a6e6c009b89ae043c1badd817d (patch) | |
tree | e6c8564bb5c71336b3fd343be81c9bc7f39384d3 /editor | |
parent | 2721527bd6a6af5e06b84f19ce240a704982e83f (diff) |
[editor] Plural of bench is benches
Diffstat (limited to 'editor')
-rw-r--r-- | editor/changeset_wrapper.cpp | 33 |
1 files 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<string> 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(); } |