mirror of
https://github.com/ethauvin/kotlin-pluralizer.git
synced 2025-04-25 00:37:12 -07:00
check uncountables against the lower-cased string
This commit is contained in:
parent
322fdd6d0e
commit
3177a1ff16
1 changed files with 2 additions and 2 deletions
|
@ -45,7 +45,7 @@ fun String.singularize(count: Int): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.pluralizer(): 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() }
|
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())
|
var found = Pattern.compile(rule.component1(), Pattern.CASE_INSENSITIVE).matcher(this).replaceAll(rule.component2())
|
||||||
val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) }
|
val endsWith = exceptions().firstOrNull { this.endsWith(it.component1()) }
|
||||||
|
@ -56,7 +56,7 @@ private fun String.pluralizer(): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.singularizer(): String {
|
private fun String.singularizer(): String {
|
||||||
if (unCountable().contains(this)) {
|
if (unCountable().contains(this.toLowerCase())) {
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) }
|
val exceptions = exceptions().firstOrNull() { this.equals(it.component2()) }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue