I have implemented per-user language selection in the Preference page.
Diffs follow; it’s just submitted into my tree. Testing and suggestions
welcome.
Thanks,
/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@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
+
+% if ($ShowNullOption) {
+-
+% }
+% 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%>)
+% }
+
+% }
+
+<%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;
+}
+@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</&>:
<&|/l&>Nickname</&>:
+
+<&|/l&>Language</&>: <& /Elements/SelectLang, Name => ‘Lang’, Default => $UserObj->Lang &>
<& /Elements/TitleBoxEnd &>
<& /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,@fieldresults);