From 20343f115d22f1abe9cf7c37b00935c035d2e176 Mon Sep 17 00:00:00 2001
From: Al Munnings <al.munnings@gmail.com>
Date: Thu, 3 Apr 2025 21:12:23 +1100
Subject: [PATCH 1/2] Ensure ascii on items fallback

---
 src/LanguageInflector.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/LanguageInflector.php b/src/LanguageInflector.php
index 604d1541..4f079df2 100644
--- a/src/LanguageInflector.php
+++ b/src/LanguageInflector.php
@@ -19,6 +19,8 @@ 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,7 +176,8 @@ class LanguageInflector {
 
     // Failsafe pluralize if singular and plural are the same.
     if ($plural === $singular) {
-      $plural .= '_' . $this->t('items');
+      $suffix = (string) $this->t('items');
+      $plural .= '_' . u($suffix)->ascii()->lower()->toString();
     }
 
     return $plural;
-- 
GitLab


From 51e4e8690aa48ad353bd93610fb041279bab68e9 Mon Sep 17 00:00:00 2001
From: Al Munnings <al.munnings@gmail.com>
Date: Tue, 22 Apr 2025 08:55:44 +1000
Subject: [PATCH 2/2] Issue #3516611 by almunnings, davidiio: Disabling
 singulizarize break graphQL

---
 .cspell-project-words.txt         |  1 +
 src/LanguageInflector.php         | 11 ++++++-----
 src/Wrapper/EntityTypeWrapper.php |  7 +++----
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/.cspell-project-words.txt b/.cspell-project-words.txt
index ddcb3322..3025ea0f 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 4f079df2..5e811564 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 b1fe75cc..6bdb71c3 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()
-- 
GitLab