diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt index ddcb33227805ce645ad63934f2a1ddb174e392f5..3025ea0fe535a22b9c8e5b59b68a674b84363334 100644 --- a/.cspell-project-words.txt +++ b/.cspell-project-words.txt @@ -20,6 +20,7 @@ latlon maxx maxy miny +newss Octahedroid starthours tablefield diff --git a/src/LanguageInflector.php b/src/LanguageInflector.php index 4f079df2c61891a78f8cdb7487c1a7ef230bcf76..5e811564fa57f4e1f3e7bebb1d69f197c3c7c733 100644 --- a/src/LanguageInflector.php +++ b/src/LanguageInflector.php @@ -19,8 +19,6 @@ use Drupal\Core\Config\ImmutableConfig; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; -use function Symfony\Component\String\u; - /** * Language inflector service. */ @@ -174,10 +172,13 @@ class LanguageInflector { &$plural, ]); - // Failsafe pluralize if singular and plural are the same. + // Failsafe pluralize if singular and plural are the same. Eg: + // - The singular of news is news. + // - The plural of news is news. + // So we add _items to the plural to make it news_items. + // Which works better than newss. if ($plural === $singular) { - $suffix = (string) $this->t('items'); - $plural .= '_' . u($suffix)->ascii()->lower()->toString(); + $plural .= '_items'; } return $plural; diff --git a/src/Wrapper/EntityTypeWrapper.php b/src/Wrapper/EntityTypeWrapper.php index b1fe75ccfe233ca6cae571c5ed19a72e69d6693f..6bdb71c3ec4e2342c543a762a1d45318e4fc8ac3 100644 --- a/src/Wrapper/EntityTypeWrapper.php +++ b/src/Wrapper/EntityTypeWrapper.php @@ -130,6 +130,7 @@ class EntityTypeWrapper { $singular = $this->inflector->singularize($this->entity->id()); return u($singular) + ->ascii() ->title() ->prepend($this->entityTypePlugin->getPrefix()) ->camel() @@ -137,10 +138,7 @@ class EntityTypeWrapper { } /** - * Type of this entity and bundle, plural. Eg paragraphTexts. - * - * Some words are the same in singular and plural. - * Eg News, Sheep. Add ...Items and hope for the best. + * Type of this entity and bundle, plural. Eg paragraphTexts. newsItems. * * @return string * The GraphQL type name of the entity type, plural. @@ -152,6 +150,7 @@ class EntityTypeWrapper { $plural = $this->inflector->pluralize($singular); return u($plural) + ->ascii() ->title() ->prepend($this->entityTypePlugin->getPrefix()) ->camel()