[LON-CAPA-cvs] cvs: loncom(version_2_9_X) /interface loncommon.pm
raeburn
raeburn@source.lon-capa.org
Tue, 19 May 2009 00:16:12 -0000
raeburn Tue May 19 00:16:12 2009 EDT
Modified files: (Branch: version_2_9_X)
/loncom/interface loncommon.pm
Log:
- Backport 1.695.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.692 loncom/interface/loncommon.pm:1.692.4.1
--- loncom/interface/loncommon.pm:1.692 Tue Nov 4 21:06:41 2008
+++ loncom/interface/loncommon.pm Tue May 19 00:16:11 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.692 2008/11/04 21:06:41 www Exp $
+# $Id: loncommon.pm,v 1.692.4.1 2009/05/19 00:16:11 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -677,7 +677,7 @@
if ($id ne '') {
my $en_terr = $locale->{'en_territory'};
my $native_terr = $locale->{'native_territory'};
- my @languages = &preferred_languages();
+ my @languages = &Apache::lonlocal::preferred_languages();
if (grep(/^en$/,@languages) || !@languages) {
if ($en_terr ne '') {
$locale_names{$id} = '('.$en_terr.')';
@@ -2998,7 +2998,7 @@
sub display_languages {
my %languages=();
- foreach my $lang (&preferred_languages()) {
+ foreach my $lang (&Apache::lonlocal::preferred_languages()) {
$languages{$lang}=1;
}
&get_unprocessed_cgi($ENV{'QUERY_STRING'},['displaylanguage']);
@@ -3010,59 +3010,9 @@
return %languages;
}
-sub preferred_languages {
- my @languages=();
- if (($env{'request.role.adv'}) && ($env{'form.languages'})) {
- @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,$env{'form.languages'}));
- }
- if ($env{'course.'.$env{'request.course.id'}.'.languages'}) {
- @languages=(@languages,split(/\s*(\,|\;|\:)\s*/,
- $env{'course.'.$env{'request.course.id'}.'.languages'}));
- }
-
- if ($env{'environment.languages'}) {
- @languages=(@languages,
- split(/\s*(\,|\;|\:)\s*/,$env{'environment.languages'}));
- }
- my $browser=$ENV{'HTTP_ACCEPT_LANGUAGE'};
- if ($browser) {
- my @browser =
- map { (split(/\s*;\s*/,$_))[0] } (split(/\s*,\s*/,$browser));
- push(@languages,@browser);
- }
-
- foreach my $domtype ($env{'user.domain'},$env{'request.role.domain'},
- $Apache::lonnet::perlvar{'lonDefDomain'}) {
- if ($domtype ne '') {
- my %domdefs = &Apache::lonnet::get_domain_defaults($domtype);
- if ($domdefs{'lang_def'} ne '') {
- push(@languages,$domdefs{'lang_def'});
- }
- }
- }
- return &get_genlanguages(@languages);
-}
-
-sub get_genlanguages {
- my (@languages) = @_;
-# turn "en-ca" into "en-ca,en"
- my @genlanguages;
- foreach my $lang (@languages) {
- unless ($lang=~/\w/) { next; }
- push(@genlanguages,$lang);
- if ($lang=~/(\-|\_)/) {
- push(@genlanguages,(split(/(\-|\_)/,$lang))[0]);
- }
- }
- #uniqueify the languages list
- my %count;
- @genlanguages = map { $count{$_}++ == 0 ? $_ : () } @genlanguages;
- return @genlanguages;
-}
-
sub languages {
my ($possible_langs) = @_;
- my @preferred_langs = &preferred_languages();
+ my @preferred_langs = &Apache::lonlocal::preferred_languages();
if (!ref($possible_langs)) {
if( wantarray ) {
return @preferred_langs;