some small i18n cleanups
This commit is contained in:
parent
95ea885cdc
commit
b4e4590697
2 changed files with 30 additions and 26 deletions
|
|
@ -107,7 +107,7 @@ sub get {
|
||||||
eval { WebGUI::Pluggable::load($cmd); };
|
eval { WebGUI::Pluggable::load($cmd); };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
if ($language eq 'English') {
|
if ($language eq 'English') {
|
||||||
$session->log->error('Unable to load $cmd');
|
$session->log->error("Unable to load $cmd");
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -115,10 +115,13 @@ sub get {
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
our $table;
|
my $table = do {
|
||||||
*table = *{"$cmd\::I18N"}; ##Create alias into symbol table
|
no strict 'refs';
|
||||||
my $output = $table->{$id}->{message};
|
${"$cmd\::I18N"};
|
||||||
$output = $self->get($id,$namespace,"English") if ($output eq "" && $language ne "English");
|
};
|
||||||
|
my $output = $table->{$id}->{message};
|
||||||
|
$output = $self->get($id, $namespace, "English")
|
||||||
|
if ($output eq "" && $language ne "English");
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,16 +145,18 @@ If this is specified, only the value of the property will be returned, instead o
|
||||||
sub getLanguage {
|
sub getLanguage {
|
||||||
my ($self, $language, $property) = @_;
|
my ($self, $language, $property) = @_;
|
||||||
$language = $language || $self->{_language} || "English";
|
$language = $language || $self->{_language} || "English";
|
||||||
my $cmd = "WebGUI::i18n::".$language;
|
my $pack = "WebGUI::i18n::" . $language;
|
||||||
WebGUI::Pluggable::load($cmd);
|
WebGUI::Pluggable::load($pack);
|
||||||
$cmd = '$'.$cmd.'::LANGUAGE';
|
my $langInfo = do {
|
||||||
my $hashRef = eval($cmd);
|
no strict 'refs';
|
||||||
|
${"$pack\::LANGUAGE"};
|
||||||
|
};
|
||||||
$self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@);
|
$self->session->errorHandler->warn("Failed to retrieve language properties because ".$@) if ($@);
|
||||||
if ($property) {
|
if ($property) {
|
||||||
return $hashRef->{$property};
|
return $langInfo->{$property};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return $hashRef;
|
return $langInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,18 +184,17 @@ Returns a hash reference to the languages installed on this WebGUI system.
|
||||||
|
|
||||||
sub getLanguages {
|
sub getLanguages {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my ($hashRef);
|
my $hashRef;
|
||||||
my $dir = $self->session->config->getWebguiRoot."/lib/WebGUI/i18n";
|
my $dir = $self->session->config->getWebguiRoot."/lib/WebGUI/i18n";
|
||||||
opendir (DIR,$dir) or $self->session->errorHandler->fatal("Can't open I18N directory! ".$dir);
|
opendir my $dh, $dir or $self->session->errorHandler->fatal("Can't open I18N directory! ".$dir);
|
||||||
my @files = readdir(DIR);
|
while (my $file = readdir($dh)) {
|
||||||
closedir(DIR);
|
next
|
||||||
foreach my $file (@files) {
|
unless $file =~ s/\.pm$//;
|
||||||
if ($file =~ /(.*?)\.pm$/) {
|
my $language = $file;
|
||||||
my $language = $1;
|
$hashRef->{$language} = $self->getLanguage($language, "label");
|
||||||
$hashRef->{$language} = $self->getLanguage($language,"label");
|
}
|
||||||
}
|
closedir $dh;
|
||||||
}
|
return $hashRef;
|
||||||
return $hashRef;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@ use strict;
|
||||||
|
|
||||||
|
|
||||||
our $LANGUAGE = {
|
our $LANGUAGE = {
|
||||||
label => 'English',
|
label => 'English',
|
||||||
toolbar => 'bullet',
|
toolbar => 'bullet',
|
||||||
languageAbbreviation => 'en', # used by plugins such as javascript helpers and third-party perl modules
|
languageAbbreviation => 'en', # used by plugins such as javascript helpers and third-party perl modules
|
||||||
locale => 'US' # same as above
|
locale => 'US', # same as above
|
||||||
};
|
};
|
||||||
|
|
||||||
sub makeUrlCompliant {
|
sub makeUrlCompliant {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue