Skip to content

Commit

Permalink
add debug msgs to LitCommon->i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRDOrazio committed Apr 17, 2024
1 parent 90e1f97 commit 419dc3a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions includes/enums/LitCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,19 @@ public static function AB( string|array $value ) : string {

private function i18n( string|array $value ) : string|array {
if( is_array( $value ) && self::areValid( $value ) ) {
LitCommon::debugWrite( "FUNCTION LitCommon->i18n: value for translation is an array, mapping all values to translation function" );
return array_map( [$this, 'i18n'], $value );
}
else if( self::isValid( $value ) ) {
if( $this->locale === LitLocale::LATIN ) {
LitCommon::debugWrite( "translating value $value to LATIN = " . self::LATIN[ $value ]);
return self::LATIN[ $value ];
} else{
LitCommon::debugWrite( "translating value $value to locale $this->locale : " . $this->GTXT[ $value ]);
return $this->GTXT[ $value ];
}
}
LitCommon::debugWrite( "final value from FUNCTION LitCommon->i18n is of type " . gettype( $value ) . " :: we should never get here?" );
return $value;
}

Expand All @@ -325,12 +329,12 @@ private function getPossessive( string|array $value ) : string|array {
* Returns a translated human readable string of the Common or the Proper
*/
public function C( string|array $common="" ) : string {
LitCommon::debugWrite( "Common param func LitCommon->C is of type " . gettype( $common ) );
LitCommon::debugWrite( "FUNCTION LitCommon->C: Common param is of type " . gettype( $common ) );
LitCommon::debugWrite( "Value of param is: " . json_encode( $common ) );
if ( ( is_string( $common ) && $common !== "" ) || is_array( $common ) ) {
if( (is_string( $common ) && $common === LitCommon::PROPRIO) || ( is_array( $common ) && in_array( LitCommon::PROPRIO, $common ) ) ) {
$common = $this->i18n( $common );
LitCommon::debugWrite( "Common is of liturgical type LitCommon:PROPRIO and now has type " . gettype( $common ) . " and value: " . json_encode( $common ) );
LitCommon::debugWrite( "Common is of liturgical type LitCommon:PROPRIO, and after translation has type " . gettype( $common ) . " and value: " . json_encode( $common ) );
} else {
LitCommon::debugWrite( "Common is not of liturgical type LitCommon::PROPRIO" );
if( is_string( $common ) ) {
Expand All @@ -341,6 +345,7 @@ public function C( string|array $common="" ) : string {
$commons = $common;
}
if( count( $commons ) > 0 ) {
LitCommon::debugWrite( "Common is an array with " . count( $commons ) . " elements" );
$commons = array_map(function ($txt) {
if( strpos($txt, ":") !== false ) {
[$commonGeneral, $commonSpecific] = explode(":", $txt);
Expand Down Expand Up @@ -368,14 +373,15 @@ public function C( string|array $common="" ) : string {
}, $commons);
/**translators: when there are multiple possible commons, this will be the glue "or from the common of..." */
$common = implode( "; " . _( "or" ) . " ", $commons );
LitCommon::debugWrite( "Common was not empty, now imploding translated value..." );
} else {
LitCommon::debugWrite( "Common was empty, setting final value to empty string" );
$common = "";
}
LitCommon::debugWrite( "Final common value is now of type string and has value: " . $common );
}
}
LitCommon::debugWrite( "common should now be of type string: " . is_string($common) ? "true" : "false" );
LitCommon::debugWrite( "common should now be of type string: " . (is_string($common) ? "true" : "false") );
return (is_string($common) ? $common : $common[0]);
}

Expand Down

0 comments on commit 419dc3a

Please sign in to comment.