Skip to content
This repository
Browse code

Move languages list from all pages, toggle if only two languages, or …

…link to full page instead
  • Loading branch information...
commit fea4508347dec02115d2947ac1d7d07e85fb9e62 1 parent 1f2356e
Chris Northwood cnorthwood authored
2  molly/apps/home/templates/home/index.html
@@ -103,7 +103,7 @@
103 103 <li class="round-bottom"><a href="{% url feedback:index %}?referer={% url home:index %}">Provide feedback</a></li>
104 104 </ul>
105 105
106   - {% include "language_selector.html" %}
  106 + {% include "i18n/language_selector.html" %}
107 107
108 108 {% block below-about %} {% endblock %}
109 109
11 molly/media/site/css/smart.css
@@ -849,7 +849,8 @@ small {
849 849 margin-right: 28px !important;
850 850 }
851 851
852   -.as-text-link
  852 +.as-text-link,
  853 +#bottom-links button
853 854 {
854 855 background: none !important;
855 856 border: 0 !important;
@@ -1039,4 +1040,12 @@ div#bottom-links div a {
1039 1040 -webkit-border-radius:0.4em;
1040 1041 -moz-border-radius:0.4em;
1041 1042 }
  1043 +
  1044 +#bottom-links button {
  1045 + font-size: 9pt;
  1046 + color: #00e !important;
  1047 + text-decoration: underline;
  1048 + font-weight: normal;
  1049 + font-family: "Liberation Sans",sans-serif;
  1050 +}
1042 1051 /* End Bottom Links */
23 molly/templates/base.html
@@ -174,7 +174,26 @@ <h1 class="{% if not breadcrumbs.2 %}{{ breadcrumbs.0 }}-header with-icon{% endi
174 174 {% endif %}
175 175
176 176 {% if "feature_vote"|app_is_loaded or "feature-suggestions"|app_is_loaded %}
177   - <div class="full-width"><a href="{% url feature_vote:index %}">{% trans "Suggest a feature" %}</a></div>
  177 + <div><a href="{% url feature_vote:index %}">{% trans "Suggest a feature" %}</a></div>
  178 + {% endif %}
  179 + {# If there's only two languages to switch between, show the switch here #}
  180 + {% if LANGUAGES|length < 3 %}
  181 + <div>
  182 + {% for language_code, language_name in LANGUAGES %}
  183 + {% if language_code != LANGUAGE_CODE %}
  184 + <form action="{% url set-language %}" method="post" class="has-ajax-handler">
  185 + {% csrf_token %}
  186 + <a><button type="submit" name="language" value="{{ language_code }}">
  187 + {{ language_name }}
  188 + </button></a>
  189 + </form>
  190 + {% endif %}
  191 + {% endfor %}
  192 + </div>
  193 + {% else %}
  194 + {# Otherwise take to another page to choose language #}
  195 + {# This is always in English as it's a lingua franca #}
  196 + <div><a href="{% url set-language %}">Change language</a></div>
178 197 {% endif %}
179 198 <div style="clear:both"> </div>
180 199 {# Give a simple list for feature phones #}
@@ -188,8 +207,6 @@ <h1 class="{% if not breadcrumbs.2 %}{{ breadcrumbs.0 }}-header with-icon{% endi
188 207 {% endblock bottom_links %}
189 208 </div>
190 209 {% endif %}
191   -
192   - {% include "language_selector.html" %}
193 210
194 211 </div>
195 212 {% endblock body %}
5 molly/templates/i18n/index.html
... ... @@ -0,0 +1,5 @@
  1 +{% extends "base.html" %}
  2 +
  3 +{% block content %}
  4 + {% include "i18n/language_selector.html" %}
  5 +{% endblock %}
5 molly/urls.py
@@ -3,6 +3,7 @@
3 3 from django.contrib import admin
4 4
5 5 from molly.conf import applications, all_apps
  6 +from molly.utils.i18n import SetLanguageView, javascript_catalog
6 7
7 8 # Admin
8 9 admin.autodiscover()
@@ -11,8 +12,8 @@
11 12 (r'^adm/', include(admin.site.urls)), # Admin site
12 13 (r'^comments/', include('django.contrib.comments.urls')), # Django comments
13 14 (r'', applications.home.urls), # Home default
14   - (r'set-language/$', 'django.views.i18n.set_language', {}, 'set-language'), # Change language view
15   - (r'^jsi18n/$', 'molly.utils.i18n.javascript_catalog',
  15 + (r'set-language/$', SetLanguageView, {}, 'set-language'), # Change language view
  16 + (r'^jsi18n/$', javascript_catalog,
16 17 {'packages': settings.INSTALLED_APPS}, 'js-i18n')) # JS i18n catalogues
17 18
18 19 # Dynamically add apps
16 molly/utils/i18n.py
@@ -2,6 +2,11 @@
2 2 from django.db.models import Model
3 3 from django.conf import settings
4 4 from django.core.exceptions import ObjectDoesNotExist
  5 +from django.views.i18n import set_language
  6 +from django.utils.translation import ugettext as _
  7 +from django.core.urlresolvers import reverse
  8 +
  9 +from molly.utils.views import BaseView
5 10
6 11 def name_in_language(obj, field):
7 12 try:
@@ -15,7 +20,16 @@ def name_in_language(obj, field):
15 20 else:
16 21 raise
17 22
18   -# TODO: When Molly moves to Django 1.3, this can be removed
  23 +class SetLanguageView(BaseView):
  24 +
  25 + def handle_GET(self, request, context):
  26 + return self.render(request, context, 'i18n/index')
  27 +
  28 + def handle_POST(self, request, context):
  29 + # Do Django's built in language setter
  30 + return set_language(request)
  31 +
  32 +# TODO: When Molly moves to Django 1.4, this can be removed
19 33
20 34 """
21 35 Below here contains backports from newer versions of Django, licensed under the

0 comments on commit fea4508

Please sign in to comment.
Something went wrong with that request. Please try again.