Improve splitting and translating of times BC

This commit is contained in:
2020-09-24 17:35:40 +02:00
committed by Stefan Rohde-Enslin
parent 785b1c5156
commit 9f39437c6e
2 changed files with 47 additions and 18 deletions

View File

@ -208,13 +208,13 @@ final class NodaTimeAutotranslater {
'fa' => 'قرن %s',
'fr' => '%sème siècle',
'hu' => '%s. század',
'id' => 'abad ke-%s',
'id' => 'Abad ke-%s',
'it' => '%sesimo secolo',
'ka' => 'მე -%s საუკუნე',
'ko' => '%s 세기',
'pl' => '%s wiek',
'pt' => 'século %s',
'ro' => 'secolul al %s-lea',
'pt' => 'Século %s',
'ro' => 'Secolul al %s-lea',
'ru' => '%s век',
'ta' => '%s ஆம் நூற்றாண்டு',
'tl' => 'Ika-%s na siglo',
@ -231,13 +231,13 @@ final class NodaTimeAutotranslater {
'fa' => 'قرن %s-%s',
'fr' => '%s-%sème siècle',
'hu' => '%s.-%s. század',
'id' => 'abad ke-%s-%s',
'id' => 'Abad ke-%s-%s',
'it' => '%s-%sesimo secolo',
'ka' => 'მე -%s-%s საუკუნე',
'ko' => '%s-%s 세기',
'pl' => '%s-%s wiek',
'pt' => 'século %s-%s',
'ro' => 'secolul al %s-%s-lea',
'pt' => 'Século %s-%s',
'ro' => 'Secolul al %s-%s-lea',
'ru' => '%s-%s век',
'ta' => '%s-%s ஆம் நூற்றாண்டு',
'tl' => 'Ika-%s hanggang ika-%s na siglo',
@ -332,7 +332,9 @@ final class NodaTimeAutotranslater {
return self::TRANSLATABLE_NOT;
}
if (intval($zeit_ende) % 100 === 0 and (intval($zeit_beginn) - 1) % 100 === 0) {
if (($zeit_ende > 0 && intval($zeit_ende) % 100 === 0 and (intval($zeit_beginn) - 1) % 100 === 0)
|| (intval($zeit_beginn) < 0 && intval($zeit_beginn) % 100 === 0 and (intval($zeit_ende) + 1) % 100 === 0)
) {
return self::TRANSLATABLE_CENTURY;
}
@ -481,10 +483,18 @@ final class NodaTimeAutotranslater {
*/
public static function translateYearsAsCentury(array $timeInfo):array {
// Beginn: 1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$start_cen = ((intval($timeInfo['zeit_beginn']) - 1) / 100) + 1;
// End: 1600. 16th century is the time.
$end_cen = (intval($timeInfo['zeit_ende']) / 100);
if (intval($timeInfo['zeit_beginn']) > 0) {
// Beginn: 1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$start_cen = ((intval($timeInfo['zeit_beginn']) - 1) / 100) + 1;
// End: 1600. 16th century is the time.
$end_cen = (intval($timeInfo['zeit_ende']) / 100);
}
else {
// End: -1600. 16th century is the time.
$start_cen = (intval($timeInfo['zeit_beginn']) / 100);
// End: -1500. (1501 - 1) / 100 + 1 = 16. 16th century is the time.
$end_cen = ((intval($timeInfo['zeit_ende']) + 1) / 100) - 1;
}
$suffixMode = self::getSuffixModeForYearsWSuffix((intval($timeInfo['zeit_beginn']) - 1), intval($timeInfo['zeit_ende']));
@ -492,13 +502,13 @@ final class NodaTimeAutotranslater {
if ($start_cen === $end_cen) {
foreach (self::LANGS_CENTURY_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)$start_cen);
$tLangValue = sprintf($format, (string)abs($start_cen));
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}
else {
foreach (self::LANGS_CENTURIES_FORMAT as $tLang => $format) {
$tLangValue = sprintf($format, (string)$start_cen, (string)$end_cen);
$tLangValue = sprintf($format, (string)abs($start_cen), (string)abs($end_cen));
$output[$tLang] = self::applyBcBceFormat($tLang, $tLangValue, $suffixMode);
}
}