[rt-users] RT 3.0.4: Selection of language in Web-interface

Autrijus Tang autrijus at autrijus.org
Thu Aug 7 07:19:59 EDT 2003


On Thu, Aug 07, 2003 at 10:58:19AM +0200, Bernhard Schmalhofer wrote:
> we are using RT here for customer support and customer projects, where 
> the customer can access the web interface.

I have just done that and sent to rt-devel.  Patches pasted below.

/Autrijus/

--- //depot/RT/rt/lib/RT/CurrentUser.pm#23
+++ //depot/RT/rt/lib/RT/CurrentUser.pm#24
@@ -329,6 +329,7 @@
     if  ((!defined $self->{'LangHandle'}) || 
          (!UNIVERSAL::can($self->{'LangHandle'}, 'maketext')) || 
          (@_))  {
+	if (my $lang = $self->UserObj->Lang) { unshift @_, $lang }
         $self->{'LangHandle'} = RT::I18N->get_handle(@_);
     }
     # Fall back to english.
--- //depot/RT/rt/html/Elements/SelectLang#0
+++ //depot/RT/rt/html/Elements/SelectLang#2
@@ -0,0 +1,55 @@
+%# BEGIN LICENSE BLOCK
+%# 
+%# Copyright (c) 1996-2003 Jesse Vincent <jesse at bestpractical.com>
+%# 
+%# (Except where explictly superceded by other copyright notices)
+%# 
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%# 
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+%# General Public License for more details.
+%# 
+%# Unless otherwise specified, all modifications, corrections or
+%# extensions to this work which alter its source code become the
+%# property of Best Practical Solutions, LLC when submitted for
+%# inclusion in the work.
+%# 
+%# 
+%# END LICENSE BLOCK
+<SELECT NAME ="<%$Name%>">
+% if ($ShowNullOption) {
+<OPTION VALUE="">-</OPTION>
+% }
+% foreach my $lang (@lang) {
+<OPTION VALUE="<%$lang%>" <%($Default && ($lang eq $Default)) && 'SELECTED'%>><% $lang_to_desc{$lang} %>
+%   if (($Verbose) and (my $description = I18N::LangTags::List::native_name($lang)) ){
+(<%$description%>)
+%  }
+</OPTION>
+% }
+</SELECT>
+<%ARGS>
+$ShowNullOption => 1
+$ShowAllQueues => 1
+$Name => undef
+$Verbose => undef
+$Default => 0
+$Lite => 0
+</%ARGS>
+
+<%ONCE>
+use I18N::LangTags::List;
+my (@lang, %lang_to_desc);
+foreach my $lang (map { s/:://; s/_/-/g; $_ } grep { /^\w+::$/ } keys %RT::I18N::) {
+    next if $lang =~ /i-default/;
+    my $desc = I18N::LangTags::List::name($lang);
+    $desc =~ s/(.*) (.*)/$2 ($1)/;
+    $lang_to_desc{$lang} = $desc;
+}
+ at lang = sort { $lang_to_desc{$a} cmp $lang_to_desc{$b} } keys %lang_to_desc;
+</%ONCE>
--- //depot/RT/rt/html/User/Prefs.html#14
+++ //depot/RT/rt/html/User/Prefs.html#15
@@ -43,6 +43,8 @@
 <&|/l&>Real Name</&>: <input name="RealName" value="<%$UserObj->RealName%>"> 
 <BR>
 <&|/l&>Nickname</&>: <input name="NickName" value="<%$UserObj->NickName%>">
+<BR>
+<&|/l&>Language</&>: <& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
 <& /Elements/TitleBoxEnd &>
 <br>
 <& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
@@ -147,12 +149,13 @@
 		    Organization RealName NickName Lang EmailEncoding WebEncoding 
 		    ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
 		    AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
-		Address2 City State Zip Country 
+		Address2 City State Zip Country Lang
 		   );
     
     my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
 					    Object => $UserObj,
 					    ARGSRef => \%ARGS );
+    $session{'CurrentUser'}->LanguageHandle($Lang);
     push (@results, at fieldresults);
 
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20030807/2b65f155/attachment.sig>


More information about the rt-users mailing list