Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
7fef9c56
Commit
7fef9c56
authored
Apr 28, 2017
by
cynddl
Browse files
Add support for client i18n (and fix language navigation)
parent
05a73122
Changes
4
Show whitespace changes
Inline
Side-by-side
project/settings/base.py
View file @
7fef9c56
...
...
@@ -21,6 +21,7 @@ ALLOWED_HOSTS = []
MIDDLEWARE
=
[
"django.middleware.security.SecurityMiddleware"
,
"django.contrib.sessions.middleware.SessionMiddleware"
,
"django.middleware.locale.LocaleMiddleware"
,
"django.middleware.common.CommonMiddleware"
,
"django.middleware.csrf.CsrfViewMiddleware"
,
"django.contrib.auth.middleware.AuthenticationMiddleware"
,
...
...
project/urls.py
View file @
7fef9c56
...
...
@@ -16,6 +16,8 @@ router.extend(rp_router)
urlpatterns
=
[
url
(
r
"^admin/"
,
admin
.
site
.
urls
),
url
(
r
'^i18n/'
,
include
(
'django.conf.urls.i18n'
)),
url
(
r
"^api/"
,
include
(
router
.
urls
,
namespace
=
"api"
)),
url
(
r
"^rp/"
,
include
(
"rp.urls"
,
namespace
=
"rp"
)),
url
(
r
'^accounts/'
,
include
(
'allauth.urls'
)),
...
...
static/src/components/navigation.css
View file @
7fef9c56
/* Navigation */
@custom-selector
:
--enter
:
hover
,
:
focus
;
@custom-selector
:
--link
a
,
.
btn-link
;
@custom-selector
:
--navbar-blue
.
navbar
.
dark-blue-bg
,
.
navbar
.
medium-blue-bg
;
.navbar-sm
{
font-size
:
13px
;
font-weight
:
600
;
}
.navbar
a
{
.navbar
:--link
{
color
:
var
(
--color-medium-blue
);
line-height
:
1.5rem
;
font-size
:
13px
;
font-weight
:
600
;
border
:
0
;
padding
:
0.5em
1em
;
&:--enter
{
color
:
var
(
--color-dark-blue
);
}
...
...
@@ -19,10 +28,12 @@
position
:
absolute
;
}
.navbar.dark-blue-bg
a
,
.navbar.medium-blue-bg
a
{
:--navbar-blue
:--link
{
color
:
var
(
--color-white
);
&:--enter
{
color
:
var
(
--color-medium-gray
);
text-decoration
:
none
;
cursor
:
pointer
;
}
}
...
...
@@ -53,7 +64,7 @@ ul.nav.nav-integrated li {
background-color
:
var
(
--color-white
);
}
&
a
{
&
:--link
{
padding
:
1rem
;
font-weight
:
bold
;
text-align
:
center
;
...
...
templates/base.html
View file @
7fef9c56
{% load static %}
{% load i18n %}
<!DOCTYPE html>
<!-- Header -->
<html>
...
...
@@ -26,15 +27,27 @@
<ul
class=
"navbar-nav ml-auto"
>
{% if user.is_authenticated %}
{% comment %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_profile' %}"
>
Mon profile
</a></li>
{% endcomment %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_logout' %}"
>
Déconnexion
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_logout' %}"
>
{% trans "Logout" %}
</a></li>
{% else %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_signup' %}"
>
Créer un compte
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_login' %}"
>
Se connecter
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_signup' %}"
>
{% trans "Register" %}
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"{% url 'account_login' %}"
>
{% trans "Login" %}
</a></li>
{% endif %}
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"https://soutien.laquadrature.net"
>
[FR]
</a></li>
<li
class=
"nav-item"
><a
class=
"nav-link"
href=
"https://support.laquadrature.net"
>
[EN]
</a></li>
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<li
class=
"nav-item"
>
<form
action=
"{% url 'set_language' %}"
method=
"post"
>
{% csrf_token %}
<input
name=
"next"
type=
"hidden"
value=
"{{ redirect_to }}"
/>
<input
name=
"language"
type=
"hidden"
value=
"{{ language.code }}"
/>
<button
class=
"btn btn-link"
type=
"submit"
>
[{{ language.code }}]
</button>
</form>
</li>
{% endfor %}
</ul>
</div>
</nav>
<nav
class=
"navbar navbar-toggleable-md"
>
...
...
Write
Preview
Supports
Markdown
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