Skip to content

Commit

Permalink
Merge pull request #259 from Liturgical-Calendar:JohnRDOrazio/issue251
Browse files Browse the repository at this point in the history
JohnRDOrazio/issue251
  • Loading branch information
JohnRDOrazio authored Nov 16, 2024
2 parents 5bd5214 + 3444b41 commit 9aebebf
Show file tree
Hide file tree
Showing 4 changed files with 178 additions and 94 deletions.
22 changes: 18 additions & 4 deletions schemas/LitCal.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@
"StsBasilGreg"
]
},
"litcal": {
"Advent1_vigil": {
"litcal": [
{
"event_idx": 1076,
"event_key": "Advent1_vigil",
"name": "Dominica Prima Adventus Missa in Vigilia",
"date": 1701475200,
"color": [
Expand All @@ -218,6 +219,7 @@
"type": "mobile",
"grade": 7,
"grade_lcl": "celebratio altioris ordinis quam sollemnitatis",
"grade_abbr": "S✝",
"grade_display": "",
"common": [],
"common_lcl": "",
Expand All @@ -235,8 +237,9 @@
"liturgical_season": "ADVENT",
"liturgical_season_lcl": "Tempus Adventus"
},
"Advent1": {
{
"event_idx": 583,
"event_key": "Advent1",
"name": "Dominica Prima Adventus",
"date": 1701561600,
"color": [
Expand All @@ -248,6 +251,7 @@
"type": "mobile",
"grade": 7,
"grade_lcl": "celebratio altioris ordinis quam sollemnitatis",
"grade_abbr": "S✝",
"grade_display": "",
"common": [],
"common_lcl": "",
Expand All @@ -267,7 +271,7 @@
"liturgical_season": "ADVENT",
"liturgical_season_lcl": "Tempus Adventus"
}
},
],
"messages": [
"The Solemnity 'Sancti Ioseph Sponsi Beatæ Mariæ Virginis' falls on Dominica IV in Quadragesima in the year 2023, the celebration has been transferred to the following Monday (20 Martius) as per the <a href=\"http://www.cultodivino.va/content/cultodivino/it/rivista-notitiae/indici-annate/1990/284-285.html\">Decree of the Congregation for Divine Worship</a>.",
"'Dominica XVIII «Per Annum»' is superseded by the FESTUM DOMINI 'In Transfiguratione Domini' in the year 2023."
Expand Down Expand Up @@ -334,6 +338,9 @@
"grade_lcl": {
"type": "string"
},
"grade_abbr": {
"type": "string"
},
"grade_display": {
"type": "string"
},
Expand Down Expand Up @@ -412,6 +419,8 @@
"color_lcl",
"type",
"grade",
"grade_lcl",
"grade_abbr",
"grade_display",
"common",
"common_lcl",
Expand Down Expand Up @@ -465,6 +474,9 @@
"grade_lcl": {
"type": "string"
},
"grade_abbr": {
"type": "string"
},
"grade_display": {
"type": "string"
},
Expand Down Expand Up @@ -546,6 +558,8 @@
"color_lcl",
"type",
"grade",
"grade_lcl",
"grade_abbr",
"grade_display",
"common",
"common_lcl",
Expand Down
9 changes: 9 additions & 0 deletions schemas/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4788,6 +4788,15 @@
"SOLEMNITY"
]
},
"GradeAbbr": {
"description": "The logical importance of the celebration, represented in abbreviated human readable form and localized according to the current requested locale",
"type": "string",
"examples": [
"w",
"F",
"S"
]
},
"DisplayGrade": {
"type": "string",
"description": "will often be empty, in which case the ***grade*** or ***gradeLcl*** properties can be used, for the purpose of displaying the rank of the current liturgical event. If non empty, will contain the localized rank of the liturgical event and should be used instead of the ***grade*** or ***gradeLcl*** properties for display purposes"
Expand Down
225 changes: 141 additions & 84 deletions src/Enum/LitGrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,139 +16,196 @@

class LitGrade
{
// I.
public const HIGHER_SOLEMNITY = 7;
// HIGHER RANKING SOLEMNITIES, THAT HAVE PRECEDENCE OVER ALL OTHERS:
// 1. EASTER TRIDUUM
// 2. CHRISTMAS, EPIPHANY, ASCENSION, PENTECOST
// SUNDAYS OF ADVENT, LENT AND EASTER
// ASH WEDNESDAY
// DAYS OF THE HOLY WEEK, FROM MONDAY TO THURSDAY
// DAYS OF THE OCTAVE OF EASTER

public const SOLEMNITY = 6;
// 3. SOLEMNITIES OF THE LORD, OF THE BLESSED VIRGIN MARY, OF THE SAINTS LISTED IN THE GENERAL CALENDAR
// COMMEMORATION OF THE FAITHFUL DEPARTED
// 4. PARTICULAR SOLEMNITIES:
// a) PATRON OF THE PLACE, OF THE COUNTRY OR OF THE CITY (CELEBRATION REQUIRED ALSO FOR RELIGIOUS COMMUNITIES);
// b) SOLEMNITY OF THE DEDICATION AND OF THE ANNIVERSARY OF THE DEDICATION OF A CHURCH
// c) SOLEMNITY OF THE TITLE OF A CHURCH
// d) SOLEMNITY OF THE TITLE OR OF THE FOUNDER OR OF THE MAIN PATRON OF AN ORDER OR OF A CONGREGATION

// II.
public const FEAST_LORD = 5;
// 5. FEASTS OF THE LORD LISTED IN THE GENERAL CALENDAR
// 6. SUNDAYS OF CHRISTMAS AND OF ORDINARY TIME

public const FEAST = 4;
// 7. FEASTS OF THE BLESSED VIRGIN MARY AND OF THE SAINTS IN THE GENERAL CALENDAR
// 8. PARTICULAR FEASTS:
// a) MAIN PATRON OF THE DIOCESE
// b) FEAST OF THE ANNIVERSARY OF THE DEDICATION OF THE CATHEDRAL
// c) FEAST OF THE MAIN PATRON OF THE REGION OR OF THE PROVINCE, OF THE NATION, OF A LARGER TERRITORY
// d) FEAST OF THE TITLE, OF THE FOUNDER, OF THE MAIN PATRON OF AN ORDER OR OF A CONGREGATION AND OF A RELIGIOUS PROVINCE
// e) OTHER PARTICULAR FEASTS OF SOME CHURCH
// f) OTHER FEASTS LISTED IN THE CALENDAR OF EACH DIOCESE, ORDER OR CONGREGATION
// 9. WEEKDAYS OF ADVENT FROM THE 17th TO THE 24th OF DECEMBER
// DAYS OF THE OCTAVE OF CHRISTMAS
// WEEKDAYS OF LENT

// III.
public const MEMORIAL = 3;
// 10. MEMORIALS OF THE GENERAL CALENDAR
// 11. PARTICULAR MEMORIALS:
// a) MEMORIALS OF THE SECONDARY PATRON OF A PLACE, OF A DIOCESE, OF A REGION OR A RELIGIOUS PROVINCE
// b) OTHER MEMORIALS LISTED IN THE CALENDAR OF EACH DIOCESE, ORDER OR CONGREGATION

public const MEMORIAL_OPT = 2;
// 12. OPTIONAL MEMORIALS, WHICH CAN HOWEVER BE OBSERVED IN DAYS INDICATED AT N. 9,
// ACCORDING TO THE NORMS DESCRIBED IN "PRINCIPLES AND NORMS" FOR THE LITURGY OF THE HOURS AND THE USE OF THE MISSAL

public const COMMEMORATION = 1;
// SIMILARLY MEMORIALS CAN BE OBSERVED AS OPTIONAL MEMORIALS THAT SHOULD FALL DURING THE WEEKDAYS OF LENT

public const WEEKDAY = 0;
// 13. WEEKDAYS OF ADVENT UNTIL DECEMBER 16th
// WEEKDAYS OF CHRISTMAS, FROM JANUARY 2nd UNTIL THE SATURDAY AFTER EPIPHANY
// WEEKDAYS OF THE EASTER SEASON, FROM THE MONDAY AFTER THE OCTAVE OF EASTER UNTIL THE SATURDAY BEFORE PENTECOST
// WEEKDAYS OF ORDINARY TIME
/**
* HIGHER SOLEMNITIES
*
* I. HIGHER RANKING SOLEMNITIES, THAT HAVE PRECEDENCE OVER ALL OTHERS:
* 1. EASTER TRIDUUM
* 2. CHRISTMAS, EPIPHANY, ASCENSION, PENTECOST
* SUNDAYS OF ADVENT, LENT AND EASTER
* ASH WEDNESDAY
* DAYS OF THE HOLY WEEK, FROM MONDAY TO THURSDAY
* DAYS OF THE OCTAVE OF EASTER
*/
public const int HIGHER_SOLEMNITY = 7;

/**
* SOLEMNITIES
*
* 3. SOLEMNITIES OF THE LORD, OF THE BLESSED VIRGIN MARY, OF THE SAINTS LISTED IN THE GENERAL CALENDAR
* COMMEMORATION OF THE FAITHFUL DEPARTED
* 4. PARTICULAR SOLEMNITIES:
* * PATRON OF THE PLACE, OF THE COUNTRY OR OF THE CITY (CELEBRATION REQUIRED ALSO FOR RELIGIOUS COMMUNITIES);
* * SOLEMNITY OF THE DEDICATION AND OF THE ANNIVERSARY OF THE DEDICATION OF A CHURCH
* * SOLEMNITY OF THE TITLE OF A CHURCH
* * SOLEMNITY OF THE TITLE OR OF THE FOUNDER OR OF THE MAIN PATRON OF AN ORDER OR OF A CONGREGATION
*/
public const int SOLEMNITY = 6;

/**
* FEASTS OF THE LORD
*
* II.
*
* 5. FEASTS OF THE LORD LISTED IN THE GENERAL CALENDAR
* 6. SUNDAYS OF CHRISTMAS AND OF ORDINARY TIME
*/
public const int FEAST_LORD = 5;

/**
* FEASTS
*
* 7. FEASTS OF THE BLESSED VIRGIN MARY AND OF THE SAINTS IN THE GENERAL CALENDAR
* 8. PARTICULAR FEASTS:
* * MAIN PATRON OF THE DIOCESE
* * FEAST OF THE ANNIVERSARY OF THE DEDICATION OF THE CATHEDRAL
* * FEAST OF THE MAIN PATRON OF THE REGION OR OF THE PROVINCE, OF THE NATION, OF A LARGER TERRITORY
* * FEAST OF THE TITLE, OF THE FOUNDER, OF THE MAIN PATRON OF AN ORDER OR OF A CONGREGATION AND OF A RELIGIOUS PROVINCE
* * OTHER PARTICULAR FEASTS OF SOME CHURCH
* * OTHER FEASTS LISTED IN THE CALENDAR OF EACH DIOCESE, ORDER OR CONGREGATION
* 9. WEEKDAYS OF ADVENT FROM THE 17th TO THE 24th OF DECEMBER
* DAYS OF THE OCTAVE OF CHRISTMAS
* WEEKDAYS OF LENT
*/
public const int FEAST = 4;

/**
* OBLIGATORY MEMORIALS
*
* III.
*
* 10. MEMORIALS OF THE GENERAL CALENDAR
* 11. PARTICULAR MEMORIALS:
* * MEMORIALS OF THE SECONDARY PATRON OF A PLACE, OF A DIOCESE, OF A REGION OR A RELIGIOUS PROVINCE
* * OTHER MEMORIALS LISTED IN THE CALENDAR OF EACH DIOCESE, ORDER OR CONGREGATION
*/
public const int MEMORIAL = 3;

/**
* OPTIONAL MEMORIALS
*
* 12. OPTIONAL MEMORIALS, WHICH CAN HOWEVER BE OBSERVED IN DAYS INDICATED AT N. 9,
* ACCORDING TO THE NORMS DESCRIBED IN "PRINCIPLES AND NORMS" FOR THE LITURGY OF THE HOURS AND THE USE OF THE MISSAL
*/
public const int MEMORIAL_OPT = 2;

/**
* COMMEMORATIONS
*
* SIMILARLY MEMORIALS THAT SHOULD FALL DURING THE WEEKDAYS OF LENT CAN BE OBSERVED AS OPTIONAL MEMORIALS
*/
public const int COMMEMORATION = 1;

/**
* WEEKDAYS
*
* 13.
*
* - WEEKDAYS OF ADVENT UNTIL DECEMBER 16th
* - WEEKDAYS OF CHRISTMAS, FROM JANUARY 2nd UNTIL THE SATURDAY AFTER EPIPHANY
* - WEEKDAYS OF THE EASTER SEASON, FROM THE MONDAY AFTER THE OCTAVE OF EASTER UNTIL THE SATURDAY BEFORE PENTECOST
* - WEEKDAYS OF ORDINARY TIME
*/
public const int WEEKDAY = 0;

public static array $values = [ 0, 1, 2, 3, 4, 5, 6, 7 ];
private string $locale;

/**
* Constructor for the LitGrade class.
*
* @param string $locale The locale to be used for localization.
*/
public function __construct(string $locale)
{
$this->locale = $locale;
}

/**
* Check if a given liturgical grade is valid.
*
* @param int $value the value to check
* @return bool true if the value is a valid liturgical grade, false otherwise
*/
public static function isValid(int $value)
{
return in_array($value, self::$values);
}

public function i18n(int $value, bool $html = true)
/**
* Translates a liturgical grade value into a localized string, optionally wrapped in HTML tags.
*
* @param int $value The liturgical grade value to be translated.
* @param bool $html Optional parameter to determine if the output should be wrapped in HTML tags.
* Defaults to true.
* @return string The localized string representing the liturgical grade, potentially wrapped in HTML.
*/
public function i18n(int $value, bool $html = true, bool $abbreviate = false): string
{
switch ($value) {
case self::WEEKDAY:
/**translators: liturgical rank. Keep lowercase */

$grade = $this->locale === LitLocale::LATIN ? 'feria' : _("weekday");
$grade = $this->locale === LitLocale::LATIN ? 'feria' : _("weekday");
/**translators: liturgical rank 'WEEKDAY' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'f' : _("w");
$tags = ['<I>','</I>'];

break;
case self::COMMEMORATION:
/**translators: liturgical rank. Keep Capitalized */

$grade = $this->locale === LitLocale::LATIN ? 'Commemoratio' : _("Commemoration");
/**translators: liturgical rank. Keep lowercase */
$grade = $this->locale === LitLocale::LATIN ? 'commemoratio' : _("commemoration");
/**translators: liturgical rank 'COMMEMORATION' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'm*' : _("m*");
$tags = ['<I>','</I>'];

break;
case self::MEMORIAL_OPT:
/**translators: liturgical rank. Keep Capitalized */

$grade = $this->locale === LitLocale::LATIN ? 'Memoria ad libitum' : _("Optional memorial");
/**translators: liturgical rank. Keep lowercsase */
$grade = $this->locale === LitLocale::LATIN ? 'memoria ad libitum' : _("optional memorial");
/**translators: liturgical rank 'OPTIONAL MEMORIAL' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'm' : _("m");
$tags = ['',''];

break;
case self::MEMORIAL:
/**translators: liturgical rank. Keep Capitalized */

$grade = $this->locale === LitLocale::LATIN ? 'Memoria obligatoria' : _("Memorial");
$grade = $this->locale === LitLocale::LATIN ? 'Memoria obligatoria' : _("Memorial");
/**translators: liturgical rank 'MEMORIAL' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'M' : _("M");
$tags = ['',''];

break;
case self::FEAST:
/**translators: liturgical rank. Keep UPPERCASE */

$grade = $this->locale === LitLocale::LATIN ? 'FESTUM' : _("FEAST");
$grade = $this->locale === LitLocale::LATIN ? 'FESTUM' : _("FEAST");
/**translators: liturgical rank 'FEAST' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'F' : _("F");
$tags = ['',''];

break;
case self::FEAST_LORD:
/**translators: liturgical rank. Keep UPPERCASE */

$grade = $this->locale === LitLocale::LATIN ? 'FESTUM DOMINI' : _("FEAST OF THE LORD");
$grade = $this->locale === LitLocale::LATIN ? 'FESTUM DOMINI' : _("FEAST OF THE LORD");
/**translators: liturgical rank 'FEAST OF THE LORD' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'F✝' : _("F✝");
$tags = ['<B>','</B>'];

break;
case self::SOLEMNITY:
/**translators: liturgical rank. Keep UPPERCASE */

$grade = $this->locale === LitLocale::LATIN ? 'SOLLEMNITAS' : _("SOLEMNITY");
$grade = $this->locale === LitLocale::LATIN ? 'SOLLEMNITAS' : _("SOLEMNITY");
/**translators: liturgical rank 'SOLEMNITY' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'S' : _("S");
$tags = ['<B>','</B>'];

break;
case self::HIGHER_SOLEMNITY:
/**translators: liturgical rank. Keep lowercase */

$grade = $this->locale === LitLocale::LATIN ? 'celebratio altioris ordinis quam sollemnitatis' : _("celebration with precedence over solemnities");
$grade = $this->locale === LitLocale::LATIN ? 'celebratio altioris ordinis quam sollemnitatis' : _("celebration with precedence over solemnities");
/**translators: liturgical rank 'HIGHER SOLEMNITY' in abbreviated form */
$gradeAbbr = $this->locale === LitLocale::LATIN ? 'S✝' : _("S✝");
$tags = ['<B><I>','</I></B>'];

break;
default:
$grade = $this->locale === LitLocale::LATIN ? 'feria' : _("weekday");
$grade = $this->locale === LitLocale::LATIN ? 'feria' : _("weekday");
$tags = ['',''];
}
if ($abbreviate) {
return $html ? $tags[0] . $gradeAbbr . $tags[1] : $gradeAbbr;
}
return $html ? $tags[0] . $grade . $tags[1] : $grade;
}
}
Loading

0 comments on commit 9aebebf

Please sign in to comment.