Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
3606f75d
Commit
3606f75d
authored
Nov 18, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 421265: Let the user easily override the language used to display HTML pages
Patch by Jacques Supcik <jacques@supcik.org> r=mkanat, a=mkanat
parent
a44e1524
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
6 deletions
+94
-6
Util.pm
Bugzilla/Install/Util.pm
+32
-3
Template.pm
Bugzilla/Template.pm
+8
-0
global.js
js/global.js
+9
-0
global.css
skins/standard/global.css
+12
-0
create.html.tmpl
template/en/default/bug/create/create.html.tmpl
+1
-1
header.html.tmpl
template/en/default/global/header.html.tmpl
+32
-2
No files found.
Bugzilla/Install/Util.pm
View file @
3606f75d
...
...
@@ -127,15 +127,28 @@ sub install_string {
}
sub
include_languages
{
# If we are in CGI mode (not in checksetup.pl) and if the function has
# been called without any parameter, then we cache the result of this
# function in Bugzilla->request_cache. This is done to improve the
# performance of the template processing.
my
$to_be_cached
=
0
;
if
(
exists
$ENV
{
'SERVER_SOFTWARE'
}
and
not
@_
)
{
my
$cache
=
Bugzilla
->
request_cache
;
if
(
exists
$cache
->
{
include_languages
})
{
return
@
{
$cache
->
{
include_languages
}}
}
$to_be_cached
=
1
;
}
my
(
$params
)
=
@_
;
$params
||=
{};
# Basically, the way this works is that we have a list of languages
# that we *want*, and a list of languages that Bugzilla actually
# supports. The caller tells us what languages they want, by setting
# $ENV{HTTP_ACCEPT_LANGUAGE} or $params->{only_language}. The languages
# we support are those specified in $params->{use_languages}. Otherwise
# we support every language installed in the template/ directory.
# $ENV{HTTP_ACCEPT_LANGUAGE}, using the "LANG" cookie or setting
# $params->{only_language}. The languages we support are those
# specified in $params->{use_languages}. Otherwise we support every
# language installed in the template/ directory.
my
@wanted
;
if
(
$params
->
{
only_language
})
{
...
...
@@ -143,6 +156,15 @@ sub include_languages {
}
else
{
@wanted
=
_sort_accept_language
(
$ENV
{
'HTTP_ACCEPT_LANGUAGE'
}
||
''
);
# Don't use the cookie if we are in "checksetup.pl". The test
# with $ENV{'SERVER_SOFTWARE'} is the same as in
# Bugzilla:Util::i_am_cgi.
if
(
exists
$ENV
{
'SERVER_SOFTWARE'
})
{
my
$cgi
=
Bugzilla
->
cgi
;
if
(
defined
(
my
$lang
=
$cgi
->
cookie
(
'LANG'
)))
{
unshift
@wanted
,
$lang
;
}
}
}
my
@supported
;
...
...
@@ -175,6 +197,13 @@ sub include_languages {
push
(
@usedlanguages
,
'en'
);
}
# Cache the result if we are in CGI mode and called without parameter
# (see the comment at the top of this function).
if
(
$to_be_cached
)
{
my
$cache
=
Bugzilla
->
request_cache
;
$cache
->
{
include_languages
}
=
\
@usedlanguages
;
}
return
@usedlanguages
;
}
...
...
Bugzilla/Template.pm
View file @
3606f75d
...
...
@@ -729,6 +729,14 @@ sub create {
# Currently logged in user, if any
# If an sudo session is in progress, this is the user we're faking
'user'
=>
sub
{
return
Bugzilla
->
user
;
},
# Currenly active language
# XXX Eventually this should probably be replaced with something
# like Bugzilla->language.
'current_language'
=>
sub
{
my
(
$language
)
=
include_languages
();
return
$language
;
},
# If an sudo session is in progress, this is the user who
# started the session.
...
...
js/global.js
View file @
3606f75d
...
...
@@ -110,3 +110,12 @@ function check_mini_login_fields( suffix ) {
window
.
alert
(
mini_login_constants
.
warning
);
return
false
;
}
function
set_language
(
value
)
{
YAHOO
.
util
.
Cookie
.
set
(
'LANG'
,
value
,
{
expires
:
new
Date
(
'January 1, 2038'
),
path
:
BUGZILLA
.
param
.
cookie_path
});
window
.
location
.
reload
()
}
skins/standard/global.css
View file @
3606f75d
...
...
@@ -61,6 +61,18 @@
padding
:
0.5em
;
}
#lang_links_container
{
float
:
right
;
}
#lang_links_container
.links
{
border
:
none
;
padding
:
.5em
;
}
.lang_current
{
font-weight
:
bold
;
}
#message
{
border
:
1px
solid
red
;
margin
:
0.3em
0em
;
...
...
template/en/default/bug/create/create.html.tmpl
View file @
3606f75d
...
...
@@ -33,7 +33,7 @@
style_urls = [ 'skins/standard/create_attachment.css',
'skins/standard/yui/calendar.css' ]
javascript_urls = [ "js/attachment.js", "js/util.js", "js/yui/calendar.js",
"js/field.js", "js/
yui/cookie.js", "js/
TUI.js" ]
"js/field.js", "js/TUI.js" ]
onload = 'set_assign_to();'
%]
...
...
template/en/default/global/header.html.tmpl
View file @
3606f75d
...
...
@@ -191,6 +191,7 @@
<![endif]-->
<script
src=
"js/yui/yahoo-dom-event.js"
type=
"text/javascript"
></script>
<script
src=
"js/yui/cookie.js"
type=
"text/javascript"
></script>
<script
src=
"js/global.js"
type=
"text/javascript"
></script>
<script
type=
"text/javascript"
>
<!--
...
...
@@ -199,6 +200,18 @@
YAHOO
.
util
.
Event
.
_simpleRemove
(
window
,
"unload"
,
YAHOO
.
util
.
Event
.
_unload
);
}
[
%
#
The
language
selector
needs
javascript
to
set
its
cookie
,
#
so
it
is
hidden
in
HTML
/
CSS
by
the
"bz_default_hidden"
class
.
#
If
the
browser
can
run
javascript
,
it
will
then
"unhide"
#
the
language
selector
using
the
following
code
.
#
%
]
function
unhide_language_selector
()
{
YAHOO
.
util
.
Dom
.
removeClass
(
'lang_links_container'
,
'bz_default_hidden'
);
}
YAHOO
.
util
.
Event
.
onDOMReady
(
unhide_language_selector
);
[
%
#
Make
some
Bugzilla
information
available
to
all
scripts
.
#
We
don
't import every parameter and constant because we
# don'
t
want
to
add
a
lot
of
uncached
JS
to
every
page
.
...
...
@@ -278,9 +291,26 @@
</tr>
</table>
[% PROCESS "global/common-links.html.tmpl" qs_suffix = "_top" %]
<table
id=
"lang_links_container"
cellpadding=
"0"
cellspacing=
"0"
class=
"bz_default_hidden"
><tr><td>
[% IF Bugzilla.languages.size > 1 %]
<ul
class=
"links"
>
[% FOREACH lang = Bugzilla.languages.sort %]
<li>
[% IF NOT loop.first %]
<span
class=
"separator"
>
|
</span>
[% END %]
[% IF lang == current_language %]
<span
class=
"lang_current"
>
[% lang FILTER html FILTER upper %]
</span>
[% ELSE %]
<a
href=
"#"
onclick=
"set_language('[% lang FILTER none %]');"
>
[%- lang FILTER html FILTER upper %]
</a>
[% END %]
</li>
[% END %]
</ul>
[% END %]
</td></tr></table>
</div>
[% PROCESS "global/common-links.html.tmpl" qs_suffix = "_top" %]
</div>
[%# header %]
<div
id=
"bugzilla-body"
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment