Extend the PickLanguage macro to let the user clear their overrides.
This commit is contained in:
parent
651d3b119d
commit
21223657a1
5 changed files with 41 additions and 9 deletions
Binary file not shown.
|
|
@ -26,6 +26,12 @@ our $HELP = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name => "delete_url",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => "delete_label",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
related => [
|
related => [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ package WebGUI::Macro::PickLanguage; # edit this line to match your own macro na
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use WebGUI::Asset::Template;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -47,17 +48,23 @@ sub process {
|
||||||
return "Could not instanciate template with id [$templateId]" unless $template;
|
return "Could not instanciate template with id [$templateId]" unless $template;
|
||||||
my $i18n = WebGUI::International->new($session);
|
my $i18n = WebGUI::International->new($session);
|
||||||
my $languages = $i18n->getLanguages();
|
my $languages = $i18n->getLanguages();
|
||||||
my $vars = {'lang_loop' => []};
|
my @lang_loop = ();
|
||||||
foreach my $language ( keys %$languages ) {
|
foreach my $language ( keys %$languages ) {
|
||||||
my $langVars = {};
|
push @lang_loop, {
|
||||||
$langVars->{ 'language_url' } = '?op=setLanguage;language=' . $language ;
|
language_url => '?op=setLanguage;language=' . $language,
|
||||||
$langVars->{ 'language_lang' } = $i18n->getLanguage($language , 'label');
|
language_lang => $i18n->getLanguage($language , 'label'),
|
||||||
$langVars->{ 'language_langAbbr' } = $i18n->getLanguage($language, 'languageAbbreviation');
|
language_langAbbr => $i18n->getLanguage($language, 'languageAbbreviation'),
|
||||||
$langVars->{ 'language_langAbbrLoc' } = $i18n->getLanguage($language, 'locale');
|
language_langAbbrLoc => $i18n->getLanguage($language, 'locale'),
|
||||||
$langVars->{ 'language_langEng' } = $language;
|
language_langEng => $language,
|
||||||
push(@{$vars->{lang_loop}}, $langVars);
|
};
|
||||||
}
|
}
|
||||||
return $template->process($vars);
|
my %vars = (
|
||||||
|
lang_loop => \@lang_loop,
|
||||||
|
delete_url => '?op=setLanguage;language=delete;',
|
||||||
|
delete_label => $i18n->get('delete',"Macro_PickLanguage"),
|
||||||
|
);
|
||||||
|
|
||||||
|
return $template->process(\%vars);
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,21 @@ our $I18N = { ##hashref of hashes
|
||||||
lastUpdated => 1131394072,
|
lastUpdated => 1131394072,
|
||||||
context => q|The url to change languages|
|
context => q|The url to change languages|
|
||||||
},
|
},
|
||||||
|
'delete_url' => {
|
||||||
|
message => q|The url that deletes the scratch language from the session.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|A template var to remove the scratch language|
|
||||||
|
},
|
||||||
|
'delete' => {
|
||||||
|
message => q|Go back to profile language.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|An internationalized label to go back to the profile language|
|
||||||
|
},
|
||||||
|
'delete_label' => {
|
||||||
|
message => q|A label for the link to go back to the profile language.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|Help for delete_label|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,8 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
'language_langEng' => 'English'
|
'language_langEng' => 'English'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
delete_url => '?op=setLanguage;language=delete;',
|
||||||
|
delete_label => 'Go back to profile language.',
|
||||||
},
|
},
|
||||||
'some template variables are created'
|
'some template variables are created'
|
||||||
);
|
);
|
||||||
|
|
@ -90,6 +92,8 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
'language_langEng' => 'English'
|
'language_langEng' => 'English'
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
delete_url => '?op=setLanguage;language=delete;',
|
||||||
|
delete_label => "Go back to profile language.",
|
||||||
},
|
},
|
||||||
'some template variables are created, when no templateId is passed on with the macro'
|
'some template variables are created, when no templateId is passed on with the macro'
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue