app/Functions/FunctionsDate.php
public static function getAgeAtEvent(string $age_string): string
    {
        switch (strtoupper($age_string)) {
            case 'CHILD':
                return I18N::translate('Child');
            case 'INFANT':
                return I18N::translate('Infant');
            case 'STILLBORN':
                return I18N::translate('Stillborn');
            default:
                return preg_replace_callback(
                    [
                        '/(\d+)([ymwd])/',
                    ],
                    static function (array $match): string {
                        $num = (int) $match[1];

                        switch ($match[2]) {
                            case 'y':
                                return I18N::plural('%s year', '%s years', $num, I18N::number($num));
                            case 'm':
                                return I18N::plural('%s month', '%s months', $num, I18N::number($num));
                            case 'w':
                                return I18N::plural('%s week', '%s weeks', $num, I18N::number($num));
                            case 'd':
                                return I18N::plural('%s day', '%s days', $num, I18N::number($num));
                            default:
                                throw new LogicException('Should never get here');
                        }
                    },
                    $age_string
                );
        }
    }
public static function getAgeAtEvent(string $age_string): string
    {
        switch (strtoupper($age_string)) {
            case 'CHILD':
                return I18N::translate('Child');
            case 'INFANT':
                return I18N::translate('Infant');
            case 'STILLBORN':
                return I18N::translate('Stillborn');
            default:
                return preg_replace_callback(
                    [
                        '/(\d+)([ymwd])/',
                    ],
                    static function (array $match): string {
                        $num = (int) $match[1];

                        switch ($match[2]) {
                            case 'y':
                                return I18N::plural('%s year', '%s years', $num, I18N::number($num));
                            case 'm':
                                return I18N::plural('%s month', '%s months', $num, I18N::number($num));
                            case 'w':
                                return I18N::plural('%s week', '%s weeks', $num, I18N::number($num));
                            case 'd':
                                return I18N::plural('%s day', '%s days', $num, I18N::number($num));
                            default:
                                throw new LogicException('Should never get here');
                        }
                    },
                    $age_string
                );
        }
    }
public static function getAgeAtEvent ( string $ age_string ) : string { switch ( strtoupper ( $ age_string ) ) { case 'CHILD' : return I18N :: translate ( 'Child' ) ; case 'INFANT' : return I18N :: translate ( 'Infant' ) ; case 'STILLBORN' : return I18N :: translate ( 'Stillborn' ) ; default : return preg_replace_callback ( [ '/(\d+)([ymwd])/' , ] , static function ( array $ match ) : string { $ num = ( int ) $ match [ 1 ] ; switch ( $ match [ 2 ] ) { case 'y' : return I18N :: plural ( '%s year' , '%s years' , $ num , I18N :: number ( $ num ) ) ; case 'm' : return I18N :: plural ( '%s month' , '%s months' , $ num , I18N :: number ( $ num ) ) ; case 'w' : return I18N :: plural ( '%s week' , '%s weeks' , $ num , I18N :: number ( $ num ) ) ; case 'd' : return I18N :: plural ( '%s day' , '%s days' , $ num , I18N :: number ( $ num ) ) ; default : throw new LogicException ( 'Should never get here' ) ; } } , $ age_string ) ; } }
Convert a GEDCOM age string to localized text.

@param string $age_string

@return string
Convert a GEDCOM age string to localized text .