Updated language engine to support multiple character sets, and added the Chinese translation.
This commit is contained in:
parent
a22aeaf155
commit
564392cced
8 changed files with 695 additions and 29 deletions
|
|
@ -19,11 +19,12 @@ sub fatalError {
|
|||
if (exists $session{cgi}) {
|
||||
$cgi = $session{cgi};
|
||||
$friendly = 1 if ($session{setting}{onCriticalError} eq "friendly");
|
||||
print WebGUI::Session::header();
|
||||
} else {
|
||||
use CGI;
|
||||
$cgi = CGI->new;
|
||||
print $cgi->header;
|
||||
}
|
||||
print $cgi->header;
|
||||
if (exists $session{config}{logfile}) {
|
||||
$logfile = $session{config}{logfile};
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ sub get {
|
|||
} elsif ($session{user}{language} ne "") {
|
||||
$language = $session{user}{language};
|
||||
} else {
|
||||
$language = "English";
|
||||
$language = 1;
|
||||
}
|
||||
if ($_[1] ne "") {
|
||||
$namespace = $_[1];
|
||||
|
|
@ -34,9 +34,9 @@ sub get {
|
|||
if (defined $international{$language}{$_[0]}) { # a little caching never hurts =)
|
||||
$output = $international{$language}{$_[0]};
|
||||
} else {
|
||||
($output) = WebGUI::SQL->quickArray("select message from international where internationalId=$_[0] and namespace='$namespace' and language='$language'");
|
||||
if ($output eq "" && $language ne "English") {
|
||||
$output = get($_[0],$namespace,"English");
|
||||
($output) = WebGUI::SQL->quickArray("select message from international where internationalId=$_[0] and namespace='$namespace' and languageId='$language'");
|
||||
if ($output eq "" && $language ne 1) {
|
||||
$output = get($_[0],$namespace,1);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
|
|
@ -44,14 +44,9 @@ sub get {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub getLanguages {
|
||||
my ($sth, %hash, @data);
|
||||
tie %hash, "Tie::IxHash";
|
||||
$sth = WebGUI::SQL->read("select distinct(language) from international");
|
||||
while (@data = $sth->array) {
|
||||
$hash{$data[0]} = $data[0];
|
||||
}
|
||||
$sth->finish;
|
||||
return \%hash;
|
||||
my ($hashRef);
|
||||
$hashRef = WebGUI::SQL->buildHashRef("select languageId,language from language");
|
||||
return $hashRef;
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -79,8 +79,8 @@ sub addInternationalizedEntry {
|
|||
$internationalId = $_[3];
|
||||
$namespace = $_[4] || "WebGUI";
|
||||
$status = $_[5] || 'notice';
|
||||
%message = WebGUI::SQL->buildHash("select language,message from international where internationalId=$internationalId and namespace='$namespace'");
|
||||
%subject = WebGUI::SQL->buildHash("select language,message from international where internationalId=523 and namespace='WebGUI'");
|
||||
%message = WebGUI::SQL->buildHash("select languageId,message from international where internationalId=$internationalId and namespace='$namespace'");
|
||||
%subject = WebGUI::SQL->buildHash("select languageId,message from international where internationalId=523 and namespace='WebGUI'");
|
||||
if ($groupId ne "") {
|
||||
@users = WebGUI::SQL->quickArray("select userId from groupings where groupId=$groupId");
|
||||
}
|
||||
|
|
@ -88,9 +88,9 @@ sub addInternationalizedEntry {
|
|||
foreach $user (@users) {
|
||||
$u = WebGUI::User->new($user);
|
||||
if ($u->userId ne "") {
|
||||
$subject{$u->profileField("language")} = $subject{'English'} if ($subject{$u->profileField("language")} eq "");
|
||||
$subject{$u->profileField("language")} = $subject{1} if ($subject{$u->profileField("language")} eq "");
|
||||
$subject = $subject{$u->profileField("language")};
|
||||
$message{$u->profileField("language")} = $message{'English'} if ($message{$u->profileField("language")} eq "");
|
||||
$message{$u->profileField("language")} = $message{1} if ($message{$u->profileField("language")} eq "");
|
||||
$message = WebGUI::Macro::process($message{$u->profileField("language")});
|
||||
WebGUI::SQL->write("insert into messageLog values ($messageLogId,".$u->userId.",
|
||||
".quote($message).",".quote($url).",".time().",".quote($message).",".quote($status).")");
|
||||
|
|
|
|||
|
|
@ -27,19 +27,19 @@ sub www_viewHelp {
|
|||
$namespace = $session{form}{namespace} || "WebGUI";
|
||||
tie %help, 'Tie::CPHash';
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and
|
||||
language='$session{user}{language}'");
|
||||
languageId='$session{user}{language}'");
|
||||
if ($help{action} eq "") {
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and language='English'");
|
||||
%help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace' and languageId=1");
|
||||
}
|
||||
$output = '<h1>'.WebGUI::International::get(93).': '.$help{action}.' '.$help{object}.'</h1>';
|
||||
$output .= $help{body};
|
||||
$output .= '<p><b>'.WebGUI::International::get(94).':';
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where object='$help{object}'
|
||||
and action<>'$help{action}' and language='$session{user}{language}' order by action");
|
||||
and action<>'$help{action}' and languageId='$session{user}{language}' order by action");
|
||||
unless ($sth->rows) {
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where object='$help{object}'
|
||||
and action<>'$help{action}' and language='English' order by action");
|
||||
and action<>'$help{action}' and languageId=1 order by action");
|
||||
}
|
||||
while (@data = $sth->array) {
|
||||
$output .= ' <a href="'.WebGUI::URL::page('op=viewHelp&hid='.$data[0].'&namespace='.$data[3])
|
||||
|
|
@ -49,10 +49,10 @@ sub www_viewHelp {
|
|||
$sth = WebGUI::SQL->read("select helpId, namespace from helpSeeAlso where seeAlsoId in ($help{seeAlso})");
|
||||
while (@data = $sth->array) {
|
||||
%seeAlso = WebGUI::SQL->quickHash("select helpId,namespace,action,object from help where helpId='$data[0]'
|
||||
and namespace='$data[1]' and language='$session{user}{language}'");
|
||||
and namespace='$data[1]' and languageId='$session{user}{language}'");
|
||||
if ($seeAlso{helpId} eq "") {
|
||||
%seeAlso = WebGUI::SQL->quickHash("select helpId,namespace,action,object from help where helpId='$data[0]'
|
||||
and namespace='$data[1]' and language='English'");
|
||||
and namespace='$data[1]' and languageId=1");
|
||||
}
|
||||
$output .= ' <a href="'.
|
||||
WebGUI::URL::page('op=viewHelp&hid='.$seeAlso{helpId}.'&namespace='.$seeAlso{namespace})
|
||||
|
|
@ -68,10 +68,10 @@ sub www_viewHelpIndex {
|
|||
my ($sth, @data, $output, $previous);
|
||||
$output = '<h1>'.WebGUI::International::get(95).'</h1>';
|
||||
$output .= '<table width="100%"><tr><td valign="top"><b>'.WebGUI::International::get(96).'</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where language='$session{user}{language}' order by action,object");
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId='$session{user}{language}' order by action,object");
|
||||
unless ($sth->rows) {
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where language='English' order by action,object");
|
||||
$sth = WebGUI::SQL->read("select helpId, action, object, namespace from help where languageId=1 order by action,object");
|
||||
}
|
||||
while (@data = $sth->array) {
|
||||
if ($data[1] ne $previous) {
|
||||
|
|
@ -83,10 +83,10 @@ sub www_viewHelpIndex {
|
|||
}
|
||||
$sth->finish;
|
||||
$output .= '</td><td valign="top"><b>'.WebGUI::International::get(97).'</b><p>';
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where language='$session{user}{language}' order by object,action");
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId='$session{user}{language}' order by object,action");
|
||||
unless ($sth->rows) {
|
||||
$sth->finish;
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where language='English' order by object,action");
|
||||
$sth = WebGUI::SQL->read("select helpId, object, action, namespace from help where languageId=1 order by object,action");
|
||||
}
|
||||
while (@data = $sth->array) {
|
||||
if ($data[1] ne $previous) {
|
||||
|
|
|
|||
|
|
@ -160,7 +160,11 @@ sub end {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub httpHeader {
|
||||
my ($charset);
|
||||
($charset) = WebGUI::SQL->quickArray("select characterSet from language where languageId=".$session{user}{language});
|
||||
$charset = "ISO-8859-1" if ($charset eq "");
|
||||
return $session{cgi}->header(
|
||||
-type => 'text/html; charset='.$charset,
|
||||
-cookie => $session{header}{cookie},
|
||||
-status => $session{header}{status}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ use WebGUI::URL;
|
|||
$karma = $u->karma;
|
||||
$lastUpdated = $u->lastUpdated;
|
||||
$ldapURL = $u->ldapURL("ldap://ldap.mycompany.com:389/o=MyCompany");
|
||||
$languagePreference = $u->profileField("language","English");
|
||||
$languagePreference = $u->profileField("language",1);
|
||||
$username = $u->username("jonboy");
|
||||
|
||||
$u->addToGroups(\@arr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue