Add a template variable for the current language, for better user feedback. Fixes bug #11573.

This commit is contained in:
Colin Kuskie 2010-05-25 14:14:58 -07:00
parent ab0204dfd9
commit c2e6978873
4 changed files with 20 additions and 7 deletions

View file

@ -45,17 +45,22 @@ sub process {
my $session = shift;
my $templateId = shift || "_aE16Rr1-bXBf8SIaLZjCg";
my $template = WebGUI::Asset::Template->new($session, $templateId);
return "Could not instanciate template with id [$templateId]" unless $template;
my $i18n = WebGUI::International->new($session);
return "Could not instanciate template with id [$templateId]" unless $template;
my $i18n = WebGUI::International->new($session);
my $languages = $i18n->getLanguages();
my $currentLanguage = $session->scratch->get('language')
? $session->scratch->get('language')
: $session->user->profileField('language');
my @lang_loop = ();
foreach my $language ( keys %$languages ) {
my $isCurrentLanguage = $currentLanguage eq $language ? 1 : 0;
push @lang_loop, {
language_url => '?op=setLanguage;language=' . $language,
language_lang => $i18n->getLanguage($language , 'label'),
language_langAbbr => $i18n->getLanguage($language, 'languageAbbreviation'),
language_langAbbrLoc => $i18n->getLanguage($language, 'locale'),
language_langEng => $language,
language_isCurrent => $isCurrentLanguage,
};
}
my %vars = (

View file

@ -34,7 +34,12 @@ our $I18N = { ##hashref of hashes
message => q|The English name of the language.|,
lastUpdated => 1131394072,
context => q|A label of the language to use in the template|
},
},
'language_isCurrent' => {
message => q|A boolean which is true if this language is the current language.|,
lastUpdated => 1131394072,
context => q|A label of the language to use in the template|
},
'language_url' => {
message => q|The url that sets the WebGUI language to the selected language.|,
lastUpdated => 1131394072,