[rt-devel] Language selection UI implemented.
Autrijus Tang
autrijus at autrijus.org
Thu Aug 7 04:47:30 EDT 2003
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 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://pallas.eruditorum.org/pipermail/rt-devel/attachments/20030807/61297649/attachment.pgp
More information about the Rt-devel
mailing list