[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface lonnavmaps.pm /localize lonlocal.pm /localize/localize de.pm
www
lon-capa-cvs@mail.lon-capa.org
Sat, 04 Oct 2003 18:13:36 -0000
www Sat Oct 4 14:13:36 2003 EDT
Modified files:
/loncom/auth lonroles.pm
/loncom/interface lonnavmaps.pm
/loncom/localize lonlocal.pm
/loncom/localize/localize de.pm
Log:
Bug #2248: enable locale-dependent rendering of dates.
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.73 loncom/auth/lonroles.pm:1.74
--- loncom/auth/lonroles.pm:1.73 Sun Sep 21 17:40:06 2003
+++ loncom/auth/lonroles.pm Sat Oct 4 14:13:36 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.73 2003/09/21 21:40:06 www Exp $
+# $Id: lonroles.pm,v 1.74 2003/10/04 18:13:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -346,7 +346,7 @@
$tstatus='future';
if ($tstart<$now) { $tstatus='will'; }
}
- $tpstart=localtime($tstart);
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart);
}
if ($tend) {
if ($tend<$then) {
@@ -354,7 +354,7 @@
} elsif ($tend<$now) {
$tstatus='will_not';
}
- $tpend=localtime($tend);
+ $tpend=&Apache::lonlocal::locallocaltime($tend);
}
if ($ENV{'request.role'} eq $trolecode) {
$tstatus='selected';
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.236 loncom/interface/lonnavmaps.pm:1.237
--- loncom/interface/lonnavmaps.pm:1.236 Tue Sep 30 11:37:18 2003
+++ loncom/interface/lonnavmaps.pm Sat Oct 4 14:13:36 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Navigate Maps Handler
#
-# $Id: lonnavmaps.pm,v 1.236 2003/09/30 15:37:18 bowersj2 Exp $
+# $Id: lonnavmaps.pm,v 1.237 2003/10/04 18:13:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -432,7 +432,7 @@
return &mt('never');
}
unless (&Apache::lonlocal::current_language()=~/^en/) {
- return localtime($time);
+ return &Apache::lonlocal::locallocaltime($time);
}
my $now = time();
Index: loncom/localize/lonlocal.pm
diff -u loncom/localize/lonlocal.pm:1.17 loncom/localize/lonlocal.pm:1.18
--- loncom/localize/lonlocal.pm:1.17 Thu Oct 2 13:35:57 2003
+++ loncom/localize/lonlocal.pm Sat Oct 4 14:13:36 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Localization routines
#
-# $Id: lonlocal.pm,v 1.17 2003/10/02 17:35:57 bowersj2 Exp $
+# $Id: lonlocal.pm,v 1.18 2003/10/04 18:13:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -278,6 +278,44 @@
$r->content_languages([¤t_language()]);
}
### setlocale(LC_ALL,¤t_locale);
+}
+
+# ========================================================== Localize localtime
+
+sub locallocaltime {
+ my $thistime=shift;
+ if ((¤t_language=~/^en/) || (!$lh)) {
+ return ''.localtime($thistime);
+ } else {
+ my $format=$lh->maketext('date_locale');
+ if ($format eq 'date_locale') {
+ return ''.localtime($thistime);
+ }
+ my ($seconds,$minutes,$twentyfour,$day,$mon,$year,$wday,$yday,$isdst)=
+ localtime($thistime);
+ my $month=(split(/\,/,$lh->maketext('date_months')))[$mon];
+ my $weekday=(split(/\,/,$lh->maketext('date_days')))[$wday];
+ if ($seconds<10) {
+ $seconds='0'.$seconds;
+ }
+ if ($minutes<10) {
+ $minutes='0'.$minutes;
+ }
+ $year+=1900;
+ my $twelve=$twentyfour;
+ if ($twelve>12) {
+ $twelve-=12;
+ $twelve.=$lh->maketext('date_pm');
+ } else {
+ $twelve.=$lh->maketext('date_am');
+ }
+ foreach
+ ('seconds','minutes','twentyfour','twelve','day','year',
+ 'month','weekday') {
+ $format=~s/\$$_/eval('$'.$_)/gse;
+ }
+ return $format;
+ }
}
# ==================== Normalize string (reduce fragility in the lexicon files)
Index: loncom/localize/localize/de.pm
diff -u loncom/localize/localize/de.pm:1.37 loncom/localize/localize/de.pm:1.38
--- loncom/localize/localize/de.pm:1.37 Mon Sep 29 18:18:25 2003
+++ loncom/localize/localize/de.pm Sat Oct 4 14:13:36 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# German Localization Lexicon
#
-# $Id: de.pm,v 1.37 2003/09/29 22:18:25 www Exp $
+# $Id: de.pm,v 1.38 2003/10/04 18:13:36 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,7 +36,12 @@
'char_encoding'=> 'ISO-8859-1',
'language_code'=> 'de',
-'lang_locale' => 'german',
+'date_locale' =>
+ '$weekday, $day. $month $year, $twentyfour:$minutes:$seconds Uhr',
+'date_months' => 'Jan,Febr,März,April,Mai,Juni,Juli,Aug,Sept,Okt,Nov,Dez',
+'date_days' => 'So,Mo,Di,Mi,Do,Fr,Sa',
+'date_am' => 'vormittags',
+'date_pm' => 'nachmittags',
'Domain'
=> 'Domäne',