1
0
Fork 0
mirror of https://github.com/ethauvin/kotlin-pluralizer.git synced 2025-04-25 00:37:12 -07:00

Merge pull request #2 from marwanad/lower-case-check-for-uncountables

check uncountables against the lower-cased string
This commit is contained in:
César Ferreira 2017-01-30 10:45:24 +00:00 committed by GitHub
commit 5af7c33746

View file

@ -45,7 +45,7 @@ fun String.singularize(count: Int): String {
}
private fun String.pluralizer(): String {
if (unCountable().contains(this)) return this
if (unCountable().contains(this.toLowerCase())) return this
val rule = pluralizeRules().last { Pattern.compile(it.component1(), Pattern.CASE_INSENSITIVE).matcher(this).find() }
var found = Pattern.compile(rule.component1(), Pattern.CASE_INSENSITIVE).matcher(this).replaceAll(rule.component2())
val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) }
@ -56,7 +56,7 @@ private fun String.pluralizer(): String {
}
private fun String.singularizer(): String {
if (unCountable().contains(this)) {
if (unCountable().contains(this.toLowerCase())) {
return this
}
val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) }