E5FF Add some more non-countable English nouns by paullallier · Pull Request #52526 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions src/Symfony/Component/String/Inflector/EnglishInflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class EnglishInflector implements InflectorInterface
private const PLURAL_MAP = [
// First entry: plural suffix, reversed
// Second entry: length of plural suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: singular suffix, normal

Expand Down Expand Up @@ -162,7 +162,7 @@ final class EnglishInflector implements InflectorInterface
private const SINGULAR_MAP = [
// First entry: singular suffix, reversed
// Second entry: length of singular suffix
// Third entry: Whether the suffix may succeed a vocal
// Third entry: Whether the suffix may succeed a vowel
// Fourth entry: Whether the suffix may succeed a consonant
// Fifth entry: plural suffix, normal

Expand Down Expand Up @@ -343,15 +343,30 @@ final class EnglishInflector implements InflectorInterface
// deer
'reed',

// equipment
'tnempiuqe',

// feedback
'kcabdeef',

// fish
'hsif',

// health
'htlaeh',

// history
'yrotsih',

// info
'ofni',

// information
'noitamrofni',

// money
'yenom',

// moose
'esoom',

Expand All @@ -363,6 +378,9 @@ final class EnglishInflector implements InflectorInterface

// species
'seiceps',

// traffic
'ciffart',
];

/**
Expand Down Expand Up @@ -399,14 +417,14 @@ public function singularize(string $plural): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $pluralLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
$nextIsVowel = false !== strpos('aeiou', $lowerPluralRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down Expand Up @@ -479,14 +497,14 @@ public function pluralize(string $singular): array
if ($j === $suffixLength) {
// Is there any character preceding the suffix in the plural string?
if ($j < $singularLength) {
$nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
$nextIsVowel = false !== strpos('aeiou', $lowerSingularRev[$j]);

if (!$map[2] && $nextIsVocal) {
// suffix may not succeed a vocal but next char is one
if (!$map[2] && $nextIsVowel) {
// suffix may not succeed a vowel but next char is one
break;
}

if (!$map[3] && !$nextIsVocal) {
if (!$map[3] && !$nextIsVowel) {
// suffix may not succeed a consonant but next char is one
break;
}
Expand Down
0