From 44c925a8ab565eb3d907048b1f780cf3bf5d6f63 Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Mon, 9 Dec 2024 05:42:16 +0100 Subject: [PATCH] manually fix some strings --- src/LiturgyOfTheDay.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/LiturgyOfTheDay.php b/src/LiturgyOfTheDay.php index d5a705a..04ee9a4 100644 --- a/src/LiturgyOfTheDay.php +++ b/src/LiturgyOfTheDay.php @@ -43,9 +43,14 @@ class LiturgyOfTheDay private array $LitCalData = []; private array $LitCalFeed = []; private \IntlDateFormatter $monthDayFmt; + private const MANUAL_FIXES = [ + 'it' => [ + '/SOLENNITÀ di Immacolata Concezione/' => "SOLENNITÀ dell'Immacolata Concezione", + ], + ]; private const PHONETIC_PRONUNCATION_MAPPING = [ '/Blessed /' => 'Blessed ', - '/Antiochia/' => 'Antiochia', + '/Antiochia/' => 'Antiochia', ]; private const ROMAN_NUMERAL_PATTERN_1_34 = '/^(I|II|III|IV|V|VI|VII|VIII|IX|X|XI|XII|XIII|XIV|XV|XVI|XVII|XVIII|XIX|XX|XXI|XXII|XXIII|XXIV|XXV|XXVI|XXVII|XXVIII|XXIX|XXX|XXXI|XXXII|XXXIII|XXXIV) /'; private const ROMAN_TO_ARABIC_MAPPING = [ @@ -566,6 +571,11 @@ private function prepareMainText(Festivity $festivity, int $idx): array } $mainText = preg_replace('/ +/', ' ', $mainText); + if (array_key_exists($this->baseLocale, LiturgyOfTheDay::MANUAL_FIXES)) { + foreach( LiturgyOfTheDay::MANUAL_FIXES[$this->baseLocale] as $pattern => $replacement ) { + $mainText = preg_replace($pattern, $replacement, $mainText); + } + } // Create the root element $speak = new \SimpleXMLElement(''); @@ -661,7 +671,7 @@ private function sendResponse() } elseif (count($this->LitCalFeed) > 1) { echo json_encode($this->LitCalFeed); } else { - die("Missing data from response: LitCalFeed seems to by empty or null? " . count($this->LitCalFeed)); + die("Missing data from response: LitCalFeed seems to be empty or null? " . count($this->LitCalFeed)); } }