[extensions-web/feature/i18n] i18n: wrap base templates to gettext tags



commit e83e49b1bf14ffaae57d16eba7e11e4ee9a09274
Author: Yuri Konotopov <ykonotopov gnome org>
Date:   Mon Feb 6 20:45:36 2017 +0400

    i18n: wrap base templates to gettext tags

 .../templates/registration/login_popup_form.html   |    5 +-
 sweettooth/context_processors.py                   |   14 ++++--
 .../extensions/templates/extensions/list.html      |    3 +-
 sweettooth/settings.py                             |    1 +
 sweettooth/templates/404.html                      |    7 ++-
 sweettooth/templates/500.html                      |    7 ++-
 sweettooth/templates/base.html                     |   18 ++++---
 sweettooth/templates/footer_links.html             |   49 ++++++++++----------
 sweettooth/templates/usermenu.html                 |    7 ++-
 9 files changed, 64 insertions(+), 47 deletions(-)
---
diff --git a/sweettooth/auth/templates/registration/login_popup_form.html 
b/sweettooth/auth/templates/registration/login_popup_form.html
index 27d2860..2115020 100644
--- a/sweettooth/auth/templates/registration/login_popup_form.html
+++ b/sweettooth/auth/templates/registration/login_popup_form.html
@@ -1,7 +1,8 @@
+{% load i18n %}
 <form action="{% url 'auth-login' %}" method="POST" class="login_popup_form user_popup">
   {% csrf_token %}
   {{ login_popup_form.as_plain }}
   <input type="hidden" name="next" value="{{ request.path }}">
-  <input type="submit" value="Login">
-  <a href="{% url 'registration_register' %}">Register</a>
+  <input type="submit" value="{% trans "Log in" %}">
+  <a href="{% url 'registration_register' %}">{% trans "Register" %}</a>
 </form>
diff --git a/sweettooth/context_processors.py b/sweettooth/context_processors.py
index 34d94ff..47d7383 100644
--- a/sweettooth/context_processors.py
+++ b/sweettooth/context_processors.py
@@ -1,21 +1,27 @@
+from django.utils.translation import ugettext as _
+
 def navigation(request):
     return {
         'global_menu': [
             {
                 'id': 'extensions-index',
-                'name': 'Extensions'
+                # Translators: Main menu item
+                'name': _('Extensions')
             },
             {
                 'id': 'extensions-upload-file',
-                'name': 'Add yours'
+                # Translators: Main menu item
+                'name': _('Add yours')
             },
             {
                 'id': 'extensions-local',
-                'name': 'Installed extensions'
+                # Translators: Main menu item
+                'name': _('Installed extensions')
             },
             {
                 'id': 'extensions-about',
-                'name': 'About'
+                # Translators: Main menu item
+                'name': _('About')
             }
         ]
     }
diff --git a/sweettooth/extensions/templates/extensions/list.html 
b/sweettooth/extensions/templates/extensions/list.html
index 70fea13..4fd527b 100644
--- a/sweettooth/extensions/templates/extensions/list.html
+++ b/sweettooth/extensions/templates/extensions/list.html
@@ -1,4 +1,5 @@
 {% extends "base.html" %}
+{% load i18n %}
 {% block body %}
   <div id="extensions-list">
   </div>
@@ -6,7 +7,7 @@
 
 {% block search-bar %}
   <div class="right">
-    <input id="search_input" type="text" placeholder="Search..." />
+    <input id="search_input" type="text" placeholder="{% trans 'Search…' %}" />
   </div>
 {% endblock %}
 
diff --git a/sweettooth/settings.py b/sweettooth/settings.py
index d16b422..73ef873 100644
--- a/sweettooth/settings.py
+++ b/sweettooth/settings.py
@@ -68,6 +68,7 @@ MIDDLEWARE_CLASSES = (
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    'django.middleware.locale.LocaleMiddleware',
     'django.middleware.security.SecurityMiddleware',
     'django.contrib.auth.middleware.AuthenticationMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
diff --git a/sweettooth/templates/404.html b/sweettooth/templates/404.html
index c1f5ab2..8f023ec 100644
--- a/sweettooth/templates/404.html
+++ b/sweettooth/templates/404.html
@@ -1,6 +1,7 @@
 {% extends "base.html" %}
-{% block title %}Uh oh... - {{ block.super }}{% endblock %}
+{% load i18n %}
+{% block title %}{% trans "Uh oh…" %} - {{ block.super }}{% endblock %}
 {% block body %}
-<h3>404 - Page not Found</h3>
-<p>We couldn't find the page you were looking for, <code>{{ request_path }}</code></p>
+<h3>404 - {% trans "Page not Found" %}</h3>
+<p>{% blocktrans %}We couldn't find the page you were looking for, <code>{{ request_path }}</code>" %}{% 
endblocktrans %}</p>
 {% endblock %}
diff --git a/sweettooth/templates/500.html b/sweettooth/templates/500.html
index 49f5d67..d44728a 100644
--- a/sweettooth/templates/500.html
+++ b/sweettooth/templates/500.html
@@ -1,6 +1,7 @@
 {% extends "base.html" %}
-{% block title %}Uh oh... - {{ block.super }}{% endblock %}
+{% load i18n %}
+{% block title %}{% trans "Uh oh…" %} - {{ block.super }}{% endblock %}
 {% block body %}
-<h3>500 - Internal Server Error</h3>
-<p>The server had an error when you wanted to access this page. Please <a 
href="https://bugzilla.gnome.org/enter_bug.cgi?product=website&component=extensions.gnome.org";>let us know 
what you did</a> so we can fix it!</p>
+<h3>500 - {% trans "Internal Server Error" %}</h3>
+<p>{% blocktrans with 
"https://bugzilla.gnome.org/enter_bug.cgi?product=website&component=extensions.gnome.org"; as bugzilla_url 
%}The server had an error when you wanted to access this page. Please <a href="{{ bugzilla_url }}">let us 
know what you did</a> so we can fix it!{% endblocktrans %}</p>
 {% endblock %}
diff --git a/sweettooth/templates/base.html b/sweettooth/templates/base.html
index 81346db..2758230 100644
--- a/sweettooth/templates/base.html
+++ b/sweettooth/templates/base.html
@@ -1,5 +1,9 @@
+{% spaceless %}
+    {% load i18n %}
+    {% trans "GNOME Shell Extensions" as t_title %}
 <!doctype html>
-<html>
+{% endspaceless %}
+<html lang="{{ LANGUAGE_CODE }}">
   <head>
     {% load static from staticfiles %}
     <meta charset="utf-8" />
@@ -7,7 +11,7 @@
     <link rel="shortcut icon" href="{% static 'images/favicon.png' %}" />
     <link rel="alternate" type="application/rss+xml"
           href="{% url 'extensions-rss-feed' %}" title="Latest extensions in GNOME Shell Extensions" />
-    <title>{% block title %}GNOME Shell Extensions{% endblock %}</title>
+    <title>{% block title %}{{t_title}}{% endblock %}</title>
     <script>
         {% load static_paths %}
         var require = {
@@ -41,7 +45,7 @@
           {% if request.user.is_authenticated %}
           <a class="user" href="#">{{ request.user.username }}</a>
           {% else %}
-          <a class="user" href="{% url 'auth-login' %}">Login</a>
+          <a class="user" href="{% url 'auth-login' %}">{% trans "Log in" %}</a>
           {% endif %}
 
           {% endspaceless %}
@@ -53,7 +57,7 @@
     <!-- header -->
     <div id="header" class="container_12">
         <div id="logo" class="grid_3">
-            <h1><a title="GNOME Shell Extensions" href="/"><img src="{% static 
'images/gnome-logo-extensions.png' %}" alt="GNOME Shell Extensions" /></a></h1>
+            <h1><a title="{{t_title}}" href="/"><img src="{% static 'images/gnome-logo-extensions.png' %}" 
alt="{{t_title}}" /></a></h1>
         </div>
         <div id="top_bar" class="grid_9">
             <div class="left">
@@ -125,15 +129,15 @@
                 </a>
                 <a href="//plus.google.com/108054458791366257368/posts">
                     <img 
src="https://www.gnome.org/wp-content/themes/gnome-grass/images/social_networks/gplus.png";
-                         alt="GNOME on Google+" rel="publisher">
+                         alt="{% trans "GNOME on Google+" %}" rel="publisher">
                 </a>
             </div>
            </div>
 
         <!-- footnotes -->
         <div id="footnotes" class="grid_9">
-          Copyright &copy; 2005&#8210;{% now "Y" %} <strong class="gnome_logo">The GNOME Project</strong><br>
-          <small>Free to share and remix: <a href="http://creativecommons.org/licenses/by/3.0/";>Creative 
Commons CC-BY</a>. Optimised for standards. Hosted by <a href="https://www.redhat.com/";>Red Hat</a>. Powered 
by <a href="//www.djangoproject.com">Django</a> and <a 
href="//git.gnome.org/browse/extensions-web">SweetTooth</a></small>
+          {% trans "Copyright &copy;" %} 2005&#8210;{% now "Y" %} <strong class="gnome_logo">{% trans "The 
GNOME Project" %}</strong><br>
+          <small>{% trans 'Free to share and remix: <a 
href="http://creativecommons.org/licenses/by/3.0/";>Creative Commons CC-BY</a>.' %} {% trans "Optimised for 
standards." %} {% trans 'Hosted by <a href="https://www.redhat.com/";>Red Hat</a>.' %} {% trans 'Powered by <a 
href="//www.djangoproject.com">Django</a> and <a 
href="//git.gnome.org/browse/extensions-web">SweetTooth</a>.' %}</small>
         </div>
 
         <div class="clear"></div>
diff --git a/sweettooth/templates/footer_links.html b/sweettooth/templates/footer_links.html
index bde48fc..368be1e 100644
--- a/sweettooth/templates/footer_links.html
+++ b/sweettooth/templates/footer_links.html
@@ -1,34 +1,35 @@
-<div class="menu-footer-container"><ul id="menu-footer" class="menu"><li id="menu-item-1048" 
class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-1048"><a 
href="//www.gnome.org">The GNOME Project</a>
+{% load i18n %}
+<div class="menu-footer-container"><ul class="menu"><li class="menu-item menu-item-type-custom 
menu-item-object-custom menu-item-has-children"><a href="//www.gnome.org">The GNOME Project</a>
 <ul class="sub-menu">
-       <li id="menu-item-1049" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1049"><a href="//www.gnome.org/about/">About Us</a></li>
-       <li id="menu-item-1050" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1050"><a href="//www.gnome.org/get-involved/">Get Involved</a></li>
-       <li id="menu-item-1051" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1051"><a href="//www.gnome.org/teams/">Teams</a></li>
-       <li id="menu-item-1053" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1053"><a href="//www.gnome.org/support-gnome/">Support GNOME</a></li>
-       <li id="menu-item-7251" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-7251"><a href="//www.gnome.org/merchandise/">Merchandise</a></li>
-       <li id="menu-item-1054" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1054"><a href="//www.gnome.org/contact/">Contact Us</a></li>
-       <li id="menu-item-2246" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-2246"><a href="//www.gnome.org/foundation/">The GNOME Foundation</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/about/">{% trans "About Us" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/get-involved/">{% trans "Get Involved" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/teams/">{% trans "Teams" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/support-gnome/">{% trans "Support GNOME" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/merchandise/">{% trans "Merchandise" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/contact/">{% trans "Contact Us" %}</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/foundation/">{% trans "The GNOME Foundation" %}</a></li>
 </ul>
 </li>
-<li id="menu-item-1047" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-has-children menu-item-1047"><a href="#" onclick="return false;">Resources</a>
+<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children"><a href="#" 
onclick="return false;">{% trans "Resources" %}</a>
 <ul class="sub-menu">
-       <li id="menu-item-1055" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1055"><a href="//developer.gnome.org">Developer Center</a></li>
-       <li id="menu-item-1056" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1056"><a href="//help.gnome.org">Documentation</a></li>
-       <li id="menu-item-1057" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1057"><a href="//wiki.gnome.org">Wiki</a></li>
-       <li id="menu-item-1058" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1058"><a href="//mail.gnome.org/mailman/listinfo">Mailing Lists</a></li>
-       <li id="menu-item-1059" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1059"><a href="//wiki.gnome.org/Community/GettingInTouch/IRC">IRC Channels</a></li>
-       <li id="menu-item-1060" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1060"><a href="//bugzilla.gnome.org/">Bug Tracker</a></li>
-       <li id="menu-item-1061" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1061"><a href="//git.gnome.org/browse/">Development Code</a></li>
-       <li id="menu-item-1062" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1062"><a href="//wiki.gnome.org/Jhbuild">Build Tool</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//developer.gnome.org">{% trans "Developer Center" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//help.gnome.org">{% 
trans "Documentation" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//wiki.gnome.org">{% 
trans "Wiki" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//mail.gnome.org/mailman/listinfo">{% trans "Mailing Lists" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//wiki.gnome.org/Community/GettingInTouch/IRC">{% trans "IRC Channels" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//bugzilla.gnome.org/">{% trans "Bug Tracker" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//git.gnome.org/browse/">{% trans "Development Code" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//wiki.gnome.org/Jhbuild">{% trans "Build Tool" %}</a></li>
 </ul>
 </li>
-<li id="menu-item-1046" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-has-children menu-item-1046"><a href="//www.gnome.org/news">News</a>
+<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children"><a 
href="//www.gnome.org/news">News</a>
 <ul class="sub-menu">
-       <li id="menu-item-1063" class="menu-item menu-item-type-post_type menu-item-object-page 
menu-item-1063"><a href="//www.gnome.org/press/">Press Releases</a></li>
-       <li id="menu-item-1064" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1064"><a href="//www.gnome.org/start/stable">Latest Release</a></li>
-       <li id="menu-item-1065" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1065"><a href="//planet.gnome.org">Planet GNOME</a></li>
-       <li id="menu-item-1067" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1067"><a href="//news.gnome.org">Development News</a></li>
-       <li id="menu-item-1068" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1068"><a href="//identi.ca/gnome">Identi.ca</a></li>
-       <li id="menu-item-1069" class="menu-item menu-item-type-custom menu-item-object-custom 
menu-item-1069"><a href="//twitter.com/gnome">Twitter</a></li>
+       <li class="menu-item menu-item-type-post_type menu-item-object-page"><a 
href="//www.gnome.org/press/">{% trans "Press Releases" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a 
href="//www.gnome.org/start/stable">{% trans "Latest Release" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//planet.gnome.org">{% 
trans "Planet GNOME" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//news.gnome.org">{% 
trans "Development News" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//identi.ca/gnome">{% 
trans "Identi.ca" %}</a></li>
+       <li class="menu-item menu-item-type-custom menu-item-object-custom"><a href="//twitter.com/gnome">{% 
trans "Twitter" %}</a></li>
 </ul>
 </li>
 </ul></div>
diff --git a/sweettooth/templates/usermenu.html b/sweettooth/templates/usermenu.html
index 5805db2..4add645 100644
--- a/sweettooth/templates/usermenu.html
+++ b/sweettooth/templates/usermenu.html
@@ -1,12 +1,13 @@
+{% load i18n %}
 {% if request.user.is_authenticated %}
 <div class="user_settings user_popup">
   {% load gravatar %}
-  <a class="avatar" href="{% url 'auth-profile' user=request.user.username %}" title="Profile">
+  <a class="avatar" href="{% url 'auth-profile' user=request.user.username %}" title="{% trans "Profile" %}">
     <img src="{% gravatar_url request request.user.email %}">
   </a>
   <ul>
-    <li><a class="text" href="{% url 'auth-settings' user=request.user.username %}">Website Settings</a></li>
-    <li><a class="text" href="{% url 'auth-logout' %}">Log Out</a></li>
+    <li><a class="text" href="{% url 'auth-settings' user=request.user.username %}">{% trans "Website 
Settings" %}</a></li>
+    <li><a class="text" href="{% url 'auth-logout' %}">{% trans "Log out" %}</a></li>
   </ul>
 </div>
 {% else %}


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