diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2018-11-01 16:12:46 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2018-11-01 16:12:46 +0000 |
| commit | 5f58d1fd8b8c5f41b8c423f85b1b514eb2b3e5fb (patch) | |
| tree | 23fa43208e066cdd15f3c0e9d4ca131331d82a09 /app/I18N.php | |
| parent | 8ad7d27de8a94d7d436bf1dbae4aac396b33ed53 (diff) | |
| download | webtrees-5f58d1fd8b8c5f41b8c423f85b1b514eb2b3e5fb.tar.gz webtrees-5f58d1fd8b8c5f41b8c423f85b1b514eb2b3e5fb.tar.bz2 webtrees-5f58d1fd8b8c5f41b8c423f85b1b514eb2b3e5fb.zip | |
Age
Diffstat (limited to 'app/I18N.php')
| -rw-r--r-- | app/I18N.php | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/app/I18N.php b/app/I18N.php index 596bb76c0e..e17ca91f6a 100644 --- a/app/I18N.php +++ b/app/I18N.php @@ -362,84 +362,6 @@ class I18N } /** - * Convert a GEDCOM age string into translated_text - * - * NB: The import function will have normalised this, so we don't need to worry about badly formatted strings - * NOTE: this function is not yet complete - eventually it will replace FunctionsDate::get_age_at_event() - * - * @param string $string - * - * @return string - */ - public static function gedcomAge(string $string): string - { - switch ($string) { - case 'STILLBORN': - // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (stillborn) - return self::translate('(stillborn)'); - case 'INFANT': - // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (in infancy) - return self::translate('(in infancy)'); - case 'CHILD': - // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (in childhood) - return self::translate('(in childhood)'); - } - - $age = []; - - if (preg_match('/(\d+)y/', $string, $match)) { - $years = (int) $match[1]; - // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days - $age[] = self::plural('%s year', '%s years', $years, self::number($years)); - } else { - $years = -1; - } - - if (preg_match('/(\d+)m/', $string, $match)) { - $months = (int) $match[1]; - // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days - $age[] = self::plural('%s month', '%s months', $months, self::number($months)); - } - - if (preg_match('/(\d+)w/', $string, $match)) { - $weeks = (int) $match[1]; - // I18N: Part of an age string. e.g. 7 weeks and 3 days - $age[] = self::plural('%s week', '%s weeks', $weeks, self::number($weeks)); - } - - if (preg_match('/(\d+)d/', $string, $match)) { - $days = (int) $match[1]; - // I18N: Part of an age string. e.g. 5 years, 4 months and 3 days - $age[] = self::plural('%s day', '%s days', $days, self::number($days)); - } - - // If an age is just a number of years, only show the number - if (count($age) === 1 && $years >= 0) { - $age = [self::number($years)]; - } - - $age_string = implode(self::$list_separator, $age); - - // No valid d/m/y values? Show the original string. - if ($age_string === '') { - $age_string = $string; - } - - if (!substr_compare($string, '<', 0, 1)) { - // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged less than 21 years) - return self::translate('(aged less than %s)', $age_string); - } - - if (!substr_compare($string, '>', 0, 1)) { - // I18N: Description of an individual’s age at an event. For example, Died 14 Jan 1900 (aged more than 21 years) - return self::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 self::translate('(aged %s)', $age_string); - } - - /** * Generate i18n markup for the <html> tag, e.g. lang="ar" dir="rtl" * * @return string |
