You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
5.7 KiB
189 lines
5.7 KiB
#!/usr/bin/perl
|
|
#
|
|
# $Id: languagelib.pl,v 1.6 2005/12/14 19:24:34 ddoughty Exp $
|
|
#
|
|
# Source File: languagelib.pl
|
|
|
|
%LANGUAGE_ID = ( 'enu' => 'English (U.S.)', 'ena' => 'English (Aus)',
|
|
'euv' => 'English (U.S.) VM',
|
|
'fr' => 'French', 'deu' => 'German',
|
|
'sp' => 'Spanish', 'arb' => 'Arabic',
|
|
'cyr' => 'Cyrillic', 'my' => 'Malay',
|
|
'kor' => 'Korean', 'afr' => 'Afrikaans',
|
|
'hin' => 'Hindi');
|
|
%LANGUAGE_FLAG = ( 'enu' => 'flagsussm.gif', 'sp' => 'flagsspsm.gif',
|
|
'fr' => 'flagsfrsm.gif', 'deu' => 'flagsdeusm.gif',
|
|
'my' => 'flagsmysm.gif');
|
|
|
|
#
|
|
# Load English as the default Language
|
|
#
|
|
$idEnglish = "enu";
|
|
&LoadLanguage($idEnglish);
|
|
$SYSTEM{'supportedlanguages'} = &GetSupportedLanguages('enu','Y','N','N');
|
|
|
|
#
|
|
# $lok = &LanguageIsSupported(_LANGUAGE_ID);
|
|
#
|
|
sub LanguageIsSupported {
|
|
if ($LANGUAGE_ID{$_[0]} eq '') {
|
|
return 0;
|
|
} else {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
#
|
|
# $options = &GetSupportedLanguages($defaultlanguage,$enabkeytrans, $setsystem, $multipleselect);
|
|
#
|
|
sub GetSupportedLanguages {
|
|
$deflang = ",$_[0],";
|
|
$onchangeevent = ($_[1] eq 'Y') ? " onChange=\"return langselect(this)\"" : "";
|
|
$sreturn="";
|
|
if ($_[3] eq 'Y') {
|
|
$sreturn = join('',$sreturn,"<OPTION value=\"none\">None\n");
|
|
}
|
|
for (keys %LANGUAGE_ID) {
|
|
unless (($_ eq 'arb') || ($_ eq 'cyr')) {
|
|
$checked = ($deflang =~ /,$_,/) ? " SELECTED" : "";
|
|
$sreturn = join('',$sreturn,"<OPTION VALUE=\"$_\"$checked> $LANGUAGE_ID{$_}\n");
|
|
}
|
|
}
|
|
$sreturn = join('',$sreturn,"<OPTION value=\"math\">Math/Scientific\n");
|
|
$sreturn = join('',$sreturn,"<OPTION value=\"misc\">Miscellaneous\n");
|
|
if ($_[3] eq 'Y') {
|
|
$sreturn = join('',"<SELECT NAME=\"languagedef\"$onchangeevent MULTIPLE SIZE=5>\n",$sreturn,"</SELECT>\n");
|
|
} else {
|
|
$sreturn = join('',"<SELECT NAME=\"languageext\"$onchangeevent>\n",$sreturn,"</SELECT>\n");
|
|
}
|
|
if ($_[2] eq 'Y') {
|
|
$SYSTEM{'supportedlanguages'} = $sreturn;
|
|
}
|
|
return $sreturn;
|
|
}
|
|
#
|
|
# &LoadLanguage($languageid)
|
|
#
|
|
sub LoadLanguage {
|
|
$llid = $_[0];
|
|
@sEnglish = &get_phrases('enu');
|
|
if ($llid ne 'enu') {
|
|
@sTranslation = &get_phrases($llid);
|
|
}
|
|
for (0 .. $#sEnglish) {
|
|
$sEnglish[$_] =~ s/\r//g;
|
|
$sEnglish[$_] =~ s/\n//g;
|
|
&SetLanguageElement("enu",$_,$sEnglish[$_]);
|
|
if ($llid ne 'enu') {
|
|
$sTranslation[$_] =~ s/\r//g;
|
|
$sTranslation[$_] =~ s/\n//g;
|
|
&SetLanguageElement($llid,$_,$sTranslation[$_]);
|
|
}
|
|
}
|
|
if ($llid eq 'enu') {
|
|
@sTranslation = @sEnglish;
|
|
}
|
|
$SYSTEM{'months'} = "<OPTION VALUE=\"01\">$sTranslation[526]
|
|
<OPTION VALUE=\"02\">$sTranslation[527]
|
|
<OPTION VALUE=\"03\">$sTranslation[528]
|
|
<OPTION VALUE=\"04\">$sTranslation[529]
|
|
<OPTION VALUE=\"05\">$sTranslation[530]
|
|
<OPTION VALUE=\"06\">$sTranslation[531]
|
|
<OPTION VALUE=\"07\">$sTranslation[532]
|
|
<OPTION VALUE=\"08\">$sTranslation[533]
|
|
<OPTION VALUE=\"09\">$sTranslation[534]
|
|
<OPTION VALUE=\"10\">$sTranslation[535]
|
|
<OPTION VALUE=\"11\">$sTranslation[536]
|
|
<OPTION VALUE=\"12\">$sTranslation[537]
|
|
";
|
|
return @sTranslation;
|
|
}
|
|
|
|
#
|
|
# &SetLanguageElement($languageid, $elementid, $elementtext);
|
|
#
|
|
sub SetLanguageElement {
|
|
my ($languageid, $elementid, $elementtext) = @_;
|
|
if ($languageid eq 'ena') {
|
|
$LANG_ENA[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'euv') {
|
|
$LANG_EUV[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'deu') {
|
|
$LANG_DEU[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'fr') {
|
|
$LANG_FR[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'sp') {
|
|
$LANG_SP[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'arb') {
|
|
$LANG_ARB[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'cyr') {
|
|
$LANG_CYR[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'my') {
|
|
$LANG_MY[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'kor') {
|
|
$LANG_KOR[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'afr') {
|
|
$LANG_AFR[$elementid] = $elementtext;
|
|
} elsif ($languageid eq 'hin') {
|
|
$LANG_HIN[$elementid] = $elementtext;
|
|
} else {
|
|
$LANG_ENU[$elementid] = $elementtext;
|
|
}
|
|
}
|
|
#
|
|
# $elementtext = &GetLanguageElement($languageid, $elementid);
|
|
#
|
|
sub GetLanguageElement {
|
|
my ($languageid, $elementid) = @_;
|
|
my $result;
|
|
if ( ! defined($languageid) ) {
|
|
&logger::logerr("GetLanguageElement() called with undefined languageid");
|
|
}
|
|
if ( ! defined($elementid) ) {
|
|
&logger::logerr("GetLanguageElement() called with undefined elementid");
|
|
}
|
|
if ( $languageid eq 'enu' || ! defined($languageid) ) {
|
|
$result = $LANG_ENU[$elementid];
|
|
} elsif ($languageid eq 'ena') {
|
|
$result = $LANG_ENA[$elementid];
|
|
} elsif ($languageid eq 'euv') {
|
|
$result = $LANG_EUV[$elementid];
|
|
} elsif ($languageid eq 'deu') {
|
|
$result = $LANG_DEU[$elementid];
|
|
} elsif ($languageid eq 'fr') {
|
|
$result = $LANG_FR[$elementid];
|
|
} elsif ($languageid eq 'sp') {
|
|
$result = $LANG_SP[$elementid];
|
|
} elsif ($languageid eq 'my') {
|
|
$result = $LANG_MY[$elementid];
|
|
} elsif ($languageid eq 'kor') {
|
|
$result = $LANG_KOR[$elementid];
|
|
} elsif ($languageid eq 'afr') {
|
|
$result = $LANG_AFR[$elementid];
|
|
} elsif ($languageid eq 'hin') {
|
|
$result = $LANG_HIN[$elementid];
|
|
} else {
|
|
&logger::logwarn("Unrecognized language ID '$languageid', defaulting to English");
|
|
$result = $LANG_ENU[$elementid];
|
|
}
|
|
|
|
if ( ! defined($result) ) {
|
|
# &logger::logwarn("Returning undefined result GetLanguageElement($languageid, $elementid)");
|
|
}
|
|
return $result;
|
|
}
|
|
#
|
|
# &LanguageSupportInit();
|
|
#
|
|
sub LanguageSupportInit {
|
|
&get_client_configuration();
|
|
$SESSION{'lang'} = ($SYSTEM{'DEFAULTLANG'} eq '') ? "enu" : $SYSTEM{'DEFAULTLANG'};
|
|
if (($SYSTEM{'languagesupport'} eq 'TRUE') && ($FORM{'lang'} ne $SESSION{'lang'}) && ($FORM{'lang'} ne '')) {
|
|
$SESSION{'lang'} = $FORM{'lang'};
|
|
}
|
|
unless ($FORM{'tid'} eq '') {&set_session($FORM{'tid'},'lang',$SESSION{'lang'});}
|
|
@xlatphrase = &LoadLanguage($SESSION{'lang'});
|
|
&GetSupportedLanguages($SESSION{'lang'},'Y','Y','N');
|
|
}
|
|
# End Library
|
|
1
|
|
|