diff options
author | Arsentiy Milchakov <milcars@mapswithme.com> | 2016-10-04 12:30:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-04 12:30:23 +0300 |
commit | fc814daaf9b1854e97237050f98a4e5cdc475073 (patch) | |
tree | be888832e580aea9d26e4183be311bee5448a716 /editor | |
parent | df382998f6ac1d21e2dfed08c9cc8469b470c4f8 (diff) | |
parent | 3436b24209f7c6a6e6c009b89ae043c1badd817d (diff) |
Merge pull request #4431 from Zverik/benches
[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(); } |