diff options
| author | Łukasz Wilenski <wooc@gazeta.pl> | 2010-05-12 15:38:57 +0000 |
|---|---|---|
| committer | Łukasz Wilenski <wooc@gazeta.pl> | 2010-05-12 15:38:57 +0000 |
| commit | 1dc29368a477203270953fd023e74aaa324da7fc (patch) | |
| tree | 0a396f0b07a009b7ef64ed49c166ce8e24ef6c69 /includes | |
| parent | 4914ca4a0a7088607202722e65f78068ff49b4bc (diff) | |
| download | webtrees-1dc29368a477203270953fd023e74aaa324da7fc.tar.gz webtrees-1dc29368a477203270953fd023e74aaa324da7fc.tar.bz2 webtrees-1dc29368a477203270953fd023e74aaa324da7fc.zip | |
century localisation
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/classes/class_i18n.php | 22 | ||||
| -rw-r--r-- | includes/classes/class_stats.php | 102 |
2 files changed, 73 insertions, 51 deletions
diff --git a/includes/classes/class_i18n.php b/includes/classes/class_i18n.php index 910dd0451c..f37ea7c895 100644 --- a/includes/classes/class_i18n.php +++ b/includes/classes/class_i18n.php @@ -103,6 +103,9 @@ class i18n { $DATE_FORMAT=self::noop('%j %F %Y'); global $TIME_FORMAT; // I18N: This a the format string for the time-of-day. See http://php.net/date for codes $TIME_FORMAT=self::noop('%g:%i:%s%a'); + global $CENTURY_FORMAT; // I18N: This is the format of displaying the centuries. DECIMAL=21st century, ROMAN=XXI century + $CENTURY_FORMAT=self::noop('CENTURY_FORMAT=DECIMAL'); + list(, $CENTURY_FORMAT)=explode('=', $CENTURY_FORMAT); global $ALPHABET_upper; // Alphabetic sorting sequence (upper-case letters), used by webtrees to sort strings $ALPHABET_upper=self::noop('ALPHABET_upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ'); list(, $ALPHABET_upper)=explode('=', $ALPHABET_upper); @@ -304,6 +307,25 @@ class i18n { } // 5=>fifth, 9=>ninth, etc. Used for Nth cousins, etc. + static function century_name($century) { + switch ($century) { + case 21: return i18n::translate_c('CENTURY', '21st'); + case 20: return i18n::translate_c('CENTURY', '20th'); + case 19: return i18n::translate_c('CENTURY', '19th'); + case 18: return i18n::translate_c('CENTURY', '18th'); + case 17: return i18n::translate_c('CENTURY', '17th'); + case 16: return i18n::translate_c('CENTURY', '16th'); + case 15: return i18n::translate_c('CENTURY', '15th'); + case 14: return i18n::translate_c('CENTURY', '14th'); + case 13: return i18n::translate_c('CENTURY', '13th'); + case 12: return i18n::translate_c('CENTURY', '12th'); + case 11: return i18n::translate_c('CENTURY', '11th'); + case 10: return i18n::translate_c('CENTURY', '10th'); + default: return $century.'01-'.($century+1).'00'; + } + } + + // 5=>fifth, 9=>ninth, etc. Used for Nth cousins, etc. static function ordinal_word($n) { switch ($n) { case 1: return i18n::translate('first'); diff --git a/includes/classes/class_stats.php b/includes/classes/class_stats.php index a9238cf752..1edf643f20 100644 --- a/includes/classes/class_stats.php +++ b/includes/classes/class_stats.php @@ -1253,7 +1253,7 @@ class stats { } function statsBirth($simple=true, $sex=false, $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; + global $TBLPREFIX, $CENTURY_FORMAT, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; if ($simple) { $sql = "SELECT ROUND((d_year+49.1)/100) AS century, COUNT(*) AS total FROM {$TBLPREFIX}dates " @@ -1298,13 +1298,12 @@ class stats { // Beware divide by zero if ($tot==0) return ''; $centuries = ""; - $func="century_localisation_".WT_LOCALE; foreach ($rows as $values) { - if (function_exists($func)) { - $century = $func($values['century']); - } - else { - $century = $values['century']; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } $counts[] = round(100 * $values['total'] / $tot, 0); $centuries .= $century.' - '.$values['total'].'|'; @@ -1318,7 +1317,7 @@ class stats { } function statsDeath($simple=true, $sex=false, $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; + global $TBLPREFIX, $CENTURY_FORMAT, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; if ($simple) { $sql = "SELECT ROUND((d_year+49.1)/100) AS century, COUNT(*) AS total FROM {$TBLPREFIX}dates " @@ -1363,13 +1362,12 @@ class stats { // Beware divide by zero if ($tot==0) return ''; $centuries = ""; - $func="century_localisation_".WT_LOCALE; foreach ($rows as $values) { - if (function_exists($func)) { - $century = $func($values['century']); - } - else { - $century = $values['century']; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } $counts[] = round(100 * $values['total'] / $tot, 0); $centuries .= $century.' - '.$values['total'].'|'; @@ -1684,7 +1682,7 @@ class stats { } function statsAge($simple=true, $related='BIRT', $sex='BOTH', $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX; + global $TBLPREFIX, $CENTURY_FORMAT; if ($simple) { if (isset($params[0]) && $params[0] != '') {$size = strtolower($params[0]);}else{$size = '230x250';} @@ -1712,7 +1710,6 @@ class stats { .' death.d_julianday1>birth.d_julianday2' .' GROUP BY century, sex ORDER BY century, sex'); if (empty($rows)) return ''; - $func="century_localisation_".WT_LOCALE; $chxl = "0:|"; $countsm = ""; $countsf = ""; @@ -1722,8 +1719,11 @@ class stats { } foreach ($out as $century=>$values) { if ($sizes[0]<980) $sizes[0] += 50; - if (function_exists($func)) { - $century = $func($century, false); + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($century); + $century = $date->NumToRoman($century); + } else { + $century = i18n::century_name($century); } $chxl .= $century."|"; $average = 0; @@ -2317,7 +2317,7 @@ class stats { } function statsMarr($simple=true, $first=false, $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; + global $TBLPREFIX, $CENTURY_FORMAT, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; if ($simple) { $sql = "SELECT ROUND((d_year+49.1)/100) AS century, COUNT(*) AS total FROM {$TBLPREFIX}dates " @@ -2380,14 +2380,13 @@ class stats { // Beware divide by zero if ($tot==0) return ''; $centuries = ""; - $func="century_localisation_".WT_LOCALE; $counts=array(); foreach ($rows as $values) { - if (function_exists($func)) { - $century = $func($values['century']); - } - else { - $century = $values['century']; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } $counts[] = round(100 * $values['total'] / $tot, 0); $centuries .= $century.' - '.$values['total'].'|'; @@ -2400,7 +2399,7 @@ class stats { } function statsDiv($simple=true, $first=false, $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; + global $TBLPREFIX, $CENTURY_FORMAT, $WT_STATS_CHART_COLOR1, $WT_STATS_CHART_COLOR2, $WT_STATS_S_CHART_X, $WT_STATS_S_CHART_Y; if ($simple) { $sql = "SELECT ROUND((d_year+49.1)/100) AS century, COUNT(*) AS total FROM {$TBLPREFIX}dates " @@ -2463,14 +2462,13 @@ class stats { // Beware divide by zero if ($tot==0) return ''; $centuries = ""; - $func="century_localisation_".WT_LOCALE; $counts=array(); foreach ($rows as $values) { - if (function_exists($func)) { - $century = $func($values['century']); - } - else { - $century = $values['century']; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } $counts[] = round(100 * $values['total'] / $tot, 0); $centuries .= $century.' - '.$values['total'].'|'; @@ -2509,7 +2507,7 @@ class stats { function lastDivorcePlace() {return $this->_mortalityQuery('place', 'DESC', 'DIV');} function statsMarrAge($simple=true, $sex='M', $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX; + global $TBLPREFIX, $CENTURY_FORMAT; if ($simple) { if (isset($params[0]) && $params[0] != '') {$size = strtolower($params[0]);}else{$size = '200x250';} @@ -2545,7 +2543,6 @@ class stats { foreach ($rows as $values) { if ($max<$values['age']) $max = $values['age']; } - $func="century_localisation_".WT_LOCALE; $chxl = "0:|"; $chmm = ""; $chmf = ""; @@ -2558,8 +2555,11 @@ class stats { } foreach ($out as $century=>$values) { if ($sizes[0]<1000) $sizes[0] += 50; - if (function_exists($func)) { - $century = $func($century, false); + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($century); + $century = $date->NumToRoman($century); + } else { + $century = i18n::century_name($century); } $chxl .= $century."|"; $average = 0; @@ -2594,7 +2594,7 @@ class stats { $chmf = substr($chmf,0,-1); $chd = "t2:{$countsm}|{$countsf}|{$countsa}"; if ($max<=50) $chxl .= "1:||".i18n::translate('century')."|2:|0|10|20|30|40|50|3:||".i18n::translate('Age')."|"; - else $chxl .= "1:||".i18n::translate('century')."|2:|0|10|20|30|40|50|60|70|80|90|100|3:||".i18n::translate('Age')."|"; + else $chxl .= "1:||".i18n::translate('century')."|2:|0|10|20|30|40|50|60|70|80|90|100|3:||".i18n::translate('Age')."|"; if (count($rows)>4 || utf8_strlen(i18n::translate('Average age in century of marriage'))<30) { $chtt = i18n::translate('Average age in century of marriage'); } else { @@ -3001,7 +3001,7 @@ class stats { } function statsChildren($simple=true, $sex='BOTH', $year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX; + global $TBLPREFIX, $CENTURY_FORMAT; if ($simple) { if (isset($params[0]) && $params[0] != '') {$size = strtolower($params[0]);}else{$size = '220x200';} @@ -3028,16 +3028,16 @@ class stats { $chm = ""; $chxl = "0:|"; $i = 0; - $func="century_localisation_".WT_LOCALE; $counts=array(); foreach ($rows as $values) { if ($sizes[0]<980) $sizes[0] += 38; - if (function_exists($func)) { - $chxl .= $func($values['century'], false)."|"; - } - else { - $chxl .= $values['century']."|"; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } + $chxl .= $century."|"; if ($max<=5) $counts[] = round($values['num']*819.2-1, 1); else $counts[] = round($values['num']*409.6, 1); $chm .= 't'.$values['num'].',000000,0,'.$i.',11,1|'; @@ -3146,7 +3146,7 @@ class stats { } function chartNoChildrenFamilies($year1=-1, $year2=-1, $params=null) { - global $TBLPREFIX; + global $TBLPREFIX, $CENTURY_FORMAT; if (isset($params[0]) && $params[0] != '') {$size = strtolower($params[0]);}else{$size = '220x200';} $sizes = explode('x', $size); @@ -3183,15 +3183,15 @@ class stats { $chm = ""; $chxl = "0:|"; $i = 0; - $func="century_localisation_".WT_LOCALE; foreach ($rows as $values) { if ($sizes[0]<980) $sizes[0] += 38; - if (function_exists($func)) { - $chxl .= $func($values['century'], false)."|"; - } - else { - $chxl .= $values['century']."|"; + if ($CENTURY_FORMAT=='ROMAN') { + $date=new CalendarDate($values['century']); + $century = $date->NumToRoman($values['century']); + } else { + $century = i18n::century_name($values['century']); } + $chxl .= $century."|"; $counts[] = round(4095*$values['count']/($max+1)); $chm .= 't'.$values['count'].',000000,0,'.$i.',11,1|'; $i++; |
