app/Age.php
public function asText(): string
    {
        if ($this->keyword === self::KEYWORD_STILLBORN) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn)
            return I18N::translate('(stillborn)');
        }

        if ($this->keyword === self::KEYWORD_INFANT) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy)
            return I18N::translate('(in infancy)');
        }

        if ($this->keyword === self::KEYWORD_CHILD) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood)
            return I18N::translate('(in childhood)');
        }

        $age = [];

        // Show a zero age as "0 years", not "0 days"
        if ($this->years > 0 || $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s year', '%s years', $this->years, I18N::number($this->years));
        }

        if ($this->months > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s month', '%s months', $this->months, I18N::number($this->months));
        }

        if ($this->weeks > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s week', '%s weeks', $this->weeks, I18N::number($this->weeks));
        }

        if ($this->days > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s day', '%s days', $this->days, I18N::number($this->days));
        }

        // If an age is just a number of years, only show the number
        if ($this->years > 0 && $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
            $age = [I18N::number($this->years)];
        }

        $age_string = implode(I18N::$list_separator, $age);

        if ($this->qualifier === self::SYMBOL_LESS_THAN) {
            // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years)
            return I18N::translate('(aged less than %s)', $age_string);
        }

        if ($this->qualifier === self::SYMBOL_MORE_THAN) {
            // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years)
            return I18N::translate('(aged more than %s)', $age_string);
        }

        // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years)
        return I18N::translate('(aged %s)', $age_string);
    }
public function asText(): string
    {
        if ($this->keyword === self::KEYWORD_STILLBORN) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn)
            return I18N::translate('(stillborn)');
        }

        if ($this->keyword === self::KEYWORD_INFANT) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy)
            return I18N::translate('(in infancy)');
        }

        if ($this->keyword === self::KEYWORD_CHILD) {
            // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood)
            return I18N::translate('(in childhood)');
        }

        $age = [];

        // Show a zero age as "0 years", not "0 days"
        if ($this->years > 0 || $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s year', '%s years', $this->years, I18N::number($this->years));
        }

        if ($this->months > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s month', '%s months', $this->months, I18N::number($this->months));
        }

        if ($this->weeks > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s week', '%s weeks', $this->weeks, I18N::number($this->weeks));
        }

        if ($this->days > 0) {
            // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days
            $age[] = I18N::plural('%s day', '%s days', $this->days, I18N::number($this->days));
        }

        // If an age is just a number of years, only show the number
        if ($this->years > 0 && $this->months === 0 && $this->weeks === 0 && $this->days === 0) {
            $age = [I18N::number($this->years)];
        }

        $age_string = implode(I18N::$list_separator, $age);

        if ($this->qualifier === self::SYMBOL_LESS_THAN) {
            // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years)
            return I18N::translate('(aged less than %s)', $age_string);
        }

        if ($this->qualifier === self::SYMBOL_MORE_THAN) {
            // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years)
            return I18N::translate('(aged more than %s)', $age_string);
        }

        // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years)
        return I18N::translate('(aged %s)', $age_string);
    }
public function asText ( ) : string { if ( $ this -> keyword === self :: KEYWORD_STILLBORN ) { // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (stillborn) return I18N :: translate ( '(stillborn)' ) ; } if ( $ this -> keyword === self :: KEYWORD_INFANT ) { // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in infancy) return I18N :: translate ( '(in infancy)' ) ; } if ( $ this -> keyword === self :: KEYWORD_CHILD ) { // I18N: An individual’s age at an event. e.g. Died 14 Jan 1900 (in childhood) return I18N :: translate ( '(in childhood)' ) ; } $ age = [ ] ; // Show a zero age as "0 years", not "0 days" if ( $ this -> years > 0 || $ this -> months === 0 && $ this -> weeks === 0 && $ this -> days === 0 ) { // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days $ age [ ] = I18N :: plural ( '%s year' , '%s years' , $ this -> years , I18N :: number ( $ this -> years ) ) ; } if ( $ this -> months > 0 ) { // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days $ age [ ] = I18N :: plural ( '%s month' , '%s months' , $ this -> months , I18N :: number ( $ this -> months ) ) ; } if ( $ this -> weeks > 0 ) { // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days $ age [ ] = I18N :: plural ( '%s week' , '%s weeks' , $ this -> weeks , I18N :: number ( $ this -> weeks ) ) ; } if ( $ this -> days > 0 ) { // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days $ age [ ] = I18N :: plural ( '%s day' , '%s days' , $ this -> days , I18N :: number ( $ this -> days ) ) ; } // If an age is just a number of years, only show the number if ( $ this -> years > 0 && $ this -> months === 0 && $ this -> weeks === 0 && $ this -> days === 0 ) { $ age = [ I18N :: number ( $ this -> years ) ] ; } $ age_string = implode ( I18N :: $ list_separator , $ age ) ; if ( $ this -> qualifier === self :: SYMBOL_LESS_THAN ) { // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years) return I18N :: translate ( '(aged less than %s)' , $ age_string ) ; } if ( $ this -> qualifier === self :: SYMBOL_MORE_THAN ) { // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years) return I18N :: translate ( '(aged more than %s)' , $ age_string ) ; } // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged 43 years) return I18N :: translate ( '(aged %s)' , $ age_string ) ; }
Convert an age to localised text.
Convert an age to localised text .