From 25141804cb3aaed6dfe345aa9ef63bd8641bdfcf Mon Sep 17 00:00:00 2001 From: Burak Date: Thu, 28 Sep 2023 03:51:11 +0300 Subject: [PATCH] Cached translation support for LibraryTypes and TagTypes. extra checks added --- src/Configuration.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Configuration.php b/src/Configuration.php index 4da6c7b..55b54b6 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -263,11 +263,11 @@ public function libraryTypes(array $types): static public function getLibraryTypes(): ?array { - if ($this->translatedLibraryTypes === null && $this->libraryTypes) { + if ($this->translatedLibraryTypes === null && $this->libraryTypes && function_exists('__')) { $this->translatedLibraryTypes = array_map('__', $this->libraryTypes); } - return $this->translatedLibraryTypes; + return $this->translatedLibraryTypes ?? $this->libraryTypes; } public function tagTypes(array $types): static @@ -281,11 +281,11 @@ public function tagTypes(array $types): static public function getTagTypes(): ?array { - if ($this->translatedTagTypes === null && $this->tagTypes) { + if ($this->translatedTagTypes === null && $this->tagTypes && function_exists('__')) { $this->translatedTagTypes = array_map('__', $this->tagTypes); } - return $this->translatedTagTypes; + return $this->translatedTagTypes ?? $this->tagTypes; } public function uriPrefix(array $prefix): static