From e16f1096837d3c5c9b1887c3435ca56a81429388 Mon Sep 17 00:00:00 2001 From: "John R. D'Orazio" Date: Fri, 29 Nov 2024 16:58:21 +0100 Subject: [PATCH] determine dataPath for calendar i18n source checks --- src/Health.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/Health.php b/src/Health.php index 66274862..0a96984f 100644 --- a/src/Health.php +++ b/src/Health.php @@ -363,6 +363,32 @@ private function executeValidation(object $validation, ConnectionInterface $to) $pathForSchema = $validation->validate; if (property_exists($validation, 'sourceFolder')) { $dataPath = rtrim($validation->sourceFolder, '/'); + $matches = null; + if (preg_match("/^(wider-region|national-calendar|diocesan-calendar)-([A-Z][a-z]+)-i18n$/i", $validation->validate, $matches)) { + switch ($matches[1]) { + case 'wider-region': + $dataPath = strtr( + JsonData::WIDER_REGIONS_I18N_FOLDER, + ['{wider_region}' => $matches[2]] + ); + break; + case 'national-calendar': + $dataPath = strtr( + JsonData::NATIONAL_CALENDARS_I18N_FOLDER, + ['{nation}' => $matches[2]] + ); + break; + case 'diocesan-calendar': + $diocese = array_values(array_filter(self::$metadata->litcal_metadata->diocesan_calendars, fn ($el) => $el->calendar_id === $matches[2])); + $nation = $diocese[0]->nation; + $dataPath = strtr( + JsonData::DIOCESAN_CALENDARS_I18N_FOLDER, + ['{diocese}' => $matches[2]], + ['{nation}' => $nation] + ); + break; + } + } } else { if (property_exists($validation, 'sourceFile')) { $dataPath = $validation->sourceFile;