[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sat Apr 9 14:43:33 EDT 2016
raeburn Sat Apr 9 18:43:33 2016 EDT
Modified files:
/loncom/interface loncommon.pm
Log:
- Support for DateTime::Locale rev. 1.00 (Ubuntu 16 LTS) whilst supporting
older versions used by other distros.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1240 loncom/interface/loncommon.pm:1.1241
--- loncom/interface/loncommon.pm:1.1240 Tue Apr 5 02:02:27 2016
+++ loncom/interface/loncommon.pm Sat Apr 9 18:43:32 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1240 2016/04/05 02:02:27 raeburn Exp $
+# $Id: loncommon.pm,v 1.1241 2016/04/09 18:43:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -72,7 +72,7 @@
use Apache::courseclassifier();
use LONCAPA qw(:DEFAULT :match);
use DateTime::TimeZone;
-use DateTime::Locale::Catalog;
+use DateTime::Locale;
use Encode();
use Text::Aspell;
use Authen::Captcha;
@@ -974,15 +974,16 @@
}
$output .= '> </option>';
}
+ my @languages = &Apache::lonlocal::preferred_languages();
my (@possibles,%locale_names);
- my @locales = DateTime::Locale::Catalog::Locales;
- foreach my $locale (@locales) {
- if (ref($locale) eq 'HASH') {
- my $id = $locale->{'id'};
- if ($id ne '') {
- my $en_terr = $locale->{'en_territory'};
- my $native_terr = $locale->{'native_territory'};
- my @languages = &Apache::lonlocal::preferred_languages();
+ my @locales = DateTime::Locale->ids();
+ foreach my $id (@locales) {
+ if ($id ne '') {
+ my ($en_terr,$native_terr);
+ my $loc = DateTime::Locale->load($id);
+ if (ref($loc)) {
+ $en_terr = $loc->name();
+ $native_terr = $loc->native_name();
if (grep(/^en$/, at languages) || !@languages) {
if ($en_terr ne '') {
$locale_names{$id} = '('.$en_terr.')';
@@ -997,8 +998,8 @@
}
}
$locale_names{$id} = Encode::encode('UTF-8',$locale_names{$id});
- push (@possibles,$id);
- }
+ push(@possibles,$id);
+ }
}
}
foreach my $item (sort(@possibles)) {
More information about the LON-CAPA-cvs
mailing list