maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maposmatic-dev] [PATCH] Support on-the-fly change of the locale setting


From: David Decotigny
Subject: [Maposmatic-dev] [PATCH] Support on-the-fly change of the locale settings.
Date: Sun, 6 Sep 2009 17:15:46 +0200

Add a new Language menu on the left to allow the selection of any of
the supported languages. The list of supported languages is in the
settings.py file and is related to the .po files available in locales/.
---
 www/locale/fr/LC_MESSAGES/django.po |    6 +++++-
 www/media/style.css                 |   24 +++++++++++++++++++++---
 www/settings.py                     |    2 ++
 www/templates/maposmatic/base.html  |   20 ++++++++++++++++++++
 www/templates/maposmatic/index.html |    6 ++++--
 www/urls.py                         |    2 +-
 6 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/www/locale/fr/LC_MESSAGES/django.po 
b/www/locale/fr/LC_MESSAGES/django.po
index 7291f9f..f5c5a08 100644
--- a/www/locale/fr/LC_MESSAGES/django.po
+++ b/www/locale/fr/LC_MESSAGES/django.po
@@ -364,7 +364,11 @@ msgstr "Vos cartes de villes libres !"
 msgid "Jobs"
 msgstr "Rendus"
 
-#: templates/maposmatic/base.html:61
+#: templates/maposmatic/base.html:64
+msgid "Language:"
+msgstr "Langue :"
+
+#: templates/maposmatic/base.html:81
 msgid "Random map"
 msgstr "Carte au hasard"
 
diff --git a/www/media/style.css b/www/media/style.css
index 0d7a7e4..4d58de5 100644
--- a/www/media/style.css
+++ b/www/media/style.css
@@ -156,22 +156,40 @@ form ul {
     list-style-type: none;
 }
 
-input {
+.submitmap input {
     background: #FFF6BF;
     border: 3px solid #CCC;
     width: 300px;
     padding: 3px;
 }
 
-input:hover {
+.submitmap input:hover {
     border: 3px solid #AAA;
 }
 
-input[type="submit"]
+.submitmap input[type="submit"]
 {
     width: 300px;
 }
 
+.langsel {
+    text-align: right;
+}
+
+.langsel input {
+    background: #FFF6BF;
+    border: 3px solid #CCC;
+    padding: 3px;
+}
+
+.langsel input:hover {
+    border: 3px solid #AAA;
+}
+
+.langsel input[type="submit"]
+{
+}
+
 table.list
 {
   margin: 1em;
diff --git a/www/settings.py b/www/settings.py
index 10012d7..d9b45ca 100644
--- a/www/settings.py
+++ b/www/settings.py
@@ -104,6 +104,8 @@ INSTALLED_APPS = (
 
 formatter = logging.Formatter("%(name)s - %(asctime)s - %(levelname)s - 
%(message)s")
 
+LANGUAGES = (("fr", u"Français"),
+             ("en", u"English"))
 
 LOG = logging.getLogger(os.environ.get("MAPOSMATIC_LOG_TARGET",
                                        "maposmatic"))
diff --git a/www/templates/maposmatic/base.html 
b/www/templates/maposmatic/base.html
index 7b7dd79..afdab13 100644
--- a/www/templates/maposmatic/base.html
+++ b/www/templates/maposmatic/base.html
@@ -42,6 +42,7 @@
 <div id="header">
 <h1>MapOSMatic</h1>
 <h2>{% trans "Your free city maps!" %}</h2>
+
  <div id="menu">
   <ul id="nav">
    <li {% block menu-home %}{% endblock %}><a href="/">{% trans "Home" 
%}</a></li>
@@ -57,6 +58,25 @@
 </div>
 
 <div id="left">
+
+  <div class="box">
+    <form name="langsel" action="/i18n/setlang/" method="post" class="langsel">
+      <label for="language">{%trans "Language:" %}</label>
+      <select name="language" onChange="document.langsel.submit();">
+       {% for lang in LANGUAGES %}
+       <option
+          {% ifequal lang.0 LANGUAGE_CODE %}
+          selected
+          {% endifequal %}
+          value="{{ lang.0 }}">
+         {{ lang.1 }}
+       </option>
+       {% endfor %}
+      </select>
+      <input type="submit" value="Go" />
+    </form>
+  </div>
+
 <div class="box">
   <h2>{% trans "Random map" %}</h2>
   {% if randommap %}
diff --git a/www/templates/maposmatic/index.html 
b/www/templates/maposmatic/index.html
index 2faabe1..2e5d119 100644
--- a/www/templates/maposmatic/index.html
+++ b/www/templates/maposmatic/index.html
@@ -141,7 +141,7 @@ rendering is completed (that might take some time depending 
on the queue
 length), this page will contain links to the generated
 map.{%endblocktrans%}</p>
 
-<form method="post" action="">
+<form method="post" action="" class="submitmap">
 
 <table style="margin: auto; border: 1px solid #CCC; padding: 10px;">
   <tr>
@@ -171,7 +171,9 @@ map.{%endblocktrans%}</p>
   </tr>
   <tr>
     <td></td>
-    <td><input type="submit" value="{% trans 'Generate' %}"/></td>
+    <td>
+      <input type="submit" value="{% trans 'Generate' %}"/>
+    </td>
   </tr>
 </table>
 
diff --git a/www/urls.py b/www/urls.py
index 41c5d07..54976f4 100644
--- a/www/urls.py
+++ b/www/urls.py
@@ -40,7 +40,7 @@ urlpatterns = patterns('',
     (r'^jobs/$', maposmatic.views.all_jobs),
     (r'^maps/$', maposmatic.views.all_maps),
     (r'^about/$', maposmatic.views.about),
-
+    (r'^i18n/', include('django.conf.urls.i18n')),
 
     (r'^results/(?P<path>.*)$',
      'django.views.static.serve',
-- 
1.6.0.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]