diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 84ead602e..73336b4dd 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -18,7 +18,7 @@ - fix: Using YUI to add the appropriate events when loading the Add/Edit Event page. Should fix the strange IE bugs. - RFE: Add wiki page variables to Wiki_Master.pm - + - fix: Not translated labels no displaing 7.3.0 diff --git a/lib/WebGUI/International.pm b/lib/WebGUI/International.pm index 6c7f792d9..7aceb358b 100644 --- a/lib/WebGUI/International.pm +++ b/lib/WebGUI/International.pm @@ -102,17 +102,14 @@ sub get { $namespace =~ s/$safeRe//g; my $cmd = "WebGUI::i18n::".$language."::".$namespace; - if (defined *{"$cmd\::I18N"}) { ##Symbol table lookup - our $table; - *table = *{"$cmd\::I18N"}; ##Create alias into symbol table - return $table->{$id}->{message}; ##return key + if (!defined *{"$cmd\::I18N"}) { ##Symbol table lookup + my $load = "use ".$cmd; + eval($load); + $self->session->errorHandler->warn($cmd." failed to compile because ".$@) if ($@); } - my $load = "use ".$cmd; - eval($load); - $self->session->errorHandler->warn($cmd." failed to compile because ".$@) if ($@); - $cmd = "\$".$cmd."::I18N->{'".$id."'}{message}"; - my $output = eval($cmd); - $self->session->errorHandler->warn("Couldn't get value from ".$cmd." because ".$@) if ($@); + our $table; + *table = *{"$cmd\::I18N"}; ##Create alias into symbol table + my $output = $table->{$id}->{message}; $output = $self->get($id,$namespace,"English") if ($output eq "" && $language ne "English"); return $output; } diff --git a/t/International.t b/t/International.t index 2ede04965..0a5d4183c 100644 --- a/t/International.t +++ b/t/International.t @@ -14,11 +14,13 @@ use lib "$FindBin::Bin/lib"; use WebGUI::Test; use WebGUI::Session; use Test::More; # increment this value for each test you create +use File::Copy qw(cp); my $session = WebGUI::Test->session; my $numTests = 1; ##For conditional load check -$numTests += 9; +my $langTests = 2; ##For language look-up tests +$numTests += 9 + $langTests; plan tests => $numTests; @@ -45,4 +47,39 @@ is($i18n->getNamespace(), 'Asset', 'getNamespace: set namespace to Asset'); is($i18n->get('topicName'), 'Assets', 'get: get English label for topicName in Asset: Assets'); is($i18n->get('topicName', 'WebGUI'), 'WebGUI', 'get: test manual namespace override'); +installPigLatin(); + +my $languages = $i18n->getLanguages(); + +my $gotPigLatin = exists $languages->{PigLatin}; + +SKIP: { + skip 'No PigLatin language pack for testing', $langTests unless $gotPigLatin; + is( + $i18n->get('account','WebGUI','English'), + $i18n->get('account','WebGUI','PigLatin'), + 'Language check: missing key returns English key' + ); + is( + $i18n->get('webgui','WebGUI','PigLatin'), + 'ebGUIWay', + 'Language check: existing key returns native language key' + ); + +} + +} + +sub installPigLatin { + my $wgLib = WebGUI::Test->lib; + mkdir join('/', $wgLib, 'WebGUI/i18n/PigLatin'); + cp 'supporting_collateral/WebGUI.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm'); + cp 'supporting_collateral/PigLatin.pm', join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm'); +} + +END: { + my $wgLib = WebGUI::Test->lib; + unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin/WebGUI.pm'); + unlink join('/', $wgLib, 'WebGUI/i18n/PigLatin.pm'); + rmdir join('/', $wgLib, 'WebGUI/i18n/PigLatin'); } diff --git a/t/supporting_collateral/PigLatin.pm b/t/supporting_collateral/PigLatin.pm new file mode 100644 index 000000000..d122e839b --- /dev/null +++ b/t/supporting_collateral/PigLatin.pm @@ -0,0 +1,27 @@ +package WebGUI::i18n::PigLatin; + +use strict; + + +our $LANGUAGE = { + label => 'PigLatin', + toolbar => 'bullet', + languageAbbreviation => 'PL', # used by plugins such as javascript helpers and third-party perl modules + locale => 'US' # same as above +}; + +sub makeUrlCompliant { + my $value = shift; + $value =~ s/\s+$//; #removes trailing whitespace + $value =~ s/^\s+//; #removes leading whitespace + $value =~ s/ /-/g; #replaces whitespace with hyphens + $value =~ s/\.$//; #removes trailing period + $value =~ s/[^A-Za-z0-9\-\.\_\/]//g; #removes all funky characters + $value =~ s/^\///; #removes a leading / + $value =~ s/\/$//; #removes a trailing / + $value =~ s/\/\//\//g; #removes double / + return $value; +} + + +1; diff --git a/t/supporting_collateral/WebGUI.pm b/t/supporting_collateral/WebGUI.pm new file mode 100644 index 000000000..a035cf3ad --- /dev/null +++ b/t/supporting_collateral/WebGUI.pm @@ -0,0 +1,11 @@ +package WebGUI::i18n::PigLatin::WebGUI; + +our $I18N = { + 'webgui' => { + message => q|ebGUIWay|, + lastUpdated => 1141963573, + context => q|Test key for International macro test. DO NOT TRANSLATE|, + }, +}; + +1;