changeset 20:8fa2fd2e928e

default: added i18n support
author Goffi <goffi@goffi.org>
date Sun, 21 May 2017 16:10:44 +0200
parents 422c54e0204a
children 24af9089aacd
files default/base/base.html default/blog/articles.html default/blog/item.html default/error/401.html default/error/404.html default/error/base.html default/event/attendance.html default/event/invitation.html default/input/comment.html default/input/field.html default/invitation/welcome.html
diffstat 11 files changed, 21 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/default/base/base.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/base/base.html	Sun May 21 16:10:44 2017 +0200
@@ -29,6 +29,6 @@
     {% block body %}
     {% endblock body %}
     </div>
-    <footer>{% block footer %}Powered by {{C.APP_NAME}}{% endblock %}</footer>
+    <footer>{% block footer %}{% trans app_name=C.APP_NAME %}Powered by {{app_name}}{% endtrans %}{% endblock %}</footer>
 </body>
 </html>
--- a/default/blog/articles.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/blog/articles.html	Sun May 21 16:10:44 2017 +0200
@@ -11,7 +11,7 @@
 
         {# we recursively display comments for all comments nodes (usually there's only one) #}
         {% for comments_items in item.comments_items_list %}
-            <button class="comments_btn" onclick="document.getElementById('{{comments_panel|next_gidx}}').classList.toggle('show')">show comments ({{comments_items|count}})</button>
+            <button class="comments_btn" onclick="document.getElementById('{{comments_panel|next_gidx}}').classList.toggle('show')">{% trans %}show comments{% endtrans %} ({{comments_items|count}})</button>
             <div id="{{comments_panel|cur_gidx}}" class="comments_panel">
                 {% if allow_commenting %}
                     <div class="comment_post">
--- a/default/blog/item.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/blog/item.html	Sun May 21 16:10:44 2017 +0200
@@ -1,5 +1,3 @@
-{% import 'script/css.js' as css %}
-
 {% block item %}
 <article id="{{ item.id }}" class="box" onclick="this.classList.toggle('clicked')">
     <header>
@@ -23,7 +21,7 @@
 
     <div class="expand_box">
         <p>
-            Click to to expand…
+            {% trans %}Click to to expand…{% endtrans %}
         </p>
     </div>
 </article>
--- a/default/error/401.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/error/401.html	Sun May 21 16:10:44 2017 +0200
@@ -1,6 +1,6 @@
 {% extends 'error/base.html' %}
 
 {% block body %}
-<h1>Unauthorized</h1>
-<p>Sorry, you are not allowed to access this page.</p>
+<h1>{% trans %}Unauthorized{% endtrans %}</h1>
+<p>{% trans %}Sorry, you are not allowed to access this page.{% endtrans %}</p>
 {% endblock body %}
--- a/default/error/404.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/error/404.html	Sun May 21 16:10:44 2017 +0200
@@ -1,6 +1,6 @@
 {% extends 'error/base.html' %}
 
 {% block body %}
-<h1>Not Found</h1>
-<p>Sorry, we can't find the resource you are trying to access.</p>
+<h1>{% trans %}Not Found{% endtrans %}</h1>
+<p>{% trans %}Sorry, we can't find the resource you are trying to access.{% endtrans %}</p>
 {% endblock body %}
--- a/default/error/base.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/error/base.html	Sun May 21 16:10:44 2017 +0200
@@ -1,7 +1,7 @@
 {% extends 'base/base.html' %}
 
-{% block title %}Error {{error_code}}{% endblock %}
+{% block title %}{% trans %}Error {{error_code}}{% endtrans %}{% endblock %}
 {% block body %}
-An error occured while trying to access the resource.
+{% trans %}An error occured while trying to access the resource.{% endtrans %}
 {% endblock body %}
 {% block footer %}{% endblock %}
--- a/default/event/attendance.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/event/attendance.html	Sun May 21 16:10:44 2017 +0200
@@ -2,16 +2,16 @@
 {% import 'input/field.html' as field with context %}
 
 <div class="attendance box">
-    <p class="poll_instructions">Please indicate if you plan to attend the event:</p>
+    <p class="poll_instructions">{% trans %}Please indicate if you plan to attend the event:{% endtrans %}</p>
     {% call form.form() %}
         {{ field.meta("type", "attendance") }}
         {{ field.meta("service", event.invitees_service) }}
         {{ field.meta("node", event.invitees_node) }}
         <div class="attending">
-            {{ field.choices("attend", ("yes", "no", "maybe"), checked=invitee.attend) }}
+            {{ field.choices("attend", (("yes", _("yes")), ("no", _("no")), ("maybe", _("maybe"))), checked=invitee.attend) }}
         </div>
         <div class="guests">
-            {{ field.int("guests", label="How many people will come (including you)?", init=invitee.get("guests", 1)) }}
+            {{ field.int("guests", label=_("How many people will come (including you)?"), init=invitee.get("guests", 1)) }}
         </div>
         <div class="submit">
             {{ field.submit() }}
--- a/default/event/invitation.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/event/invitation.html	Sun May 21 16:10:44 2017 +0200
@@ -2,8 +2,8 @@
 
 {% block body %}
 <div class='invitation_header box'>
-    <h1>Welcome {{name}}</h1>
-    <p class='instructions'>You have been invited to participate to an event</p>
+    <h1>{% trans %}Welcome {{name}}{% endtrans %}</h1>
+    <p class='instructions'>{% trans %}You have been invited to participate to an event{% endtrans %}</p>
     {% if event.image is defined %}
         <p><img id='event_picture' src="{{event.image}}"></p>
     {% endif %}
--- a/default/input/comment.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/input/comment.html	Sun May 21 16:10:44 2017 +0200
@@ -8,11 +8,11 @@
 {% endmacro %}
 
 {% macro body(rows=10, cols=50) %}
-    <textarea name="body" rows="{{rows}}" cols="{{cols}}" placeholder="Your comment"></textarea>
+    <textarea name="body" rows="{{rows}}" cols="{{cols}}" placeholder="{{_("Your comment")}}"></textarea>
 {% endmacro %}
 
 {% macro submit() %}
-    <input type="submit" value="Send">
+    <input type="submit" value="{{_("Send")}}">
 {% endmacro %}
 
 {% macro comment(service, node, action='') %}
--- a/default/input/field.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/input/field.html	Sun May 21 16:10:44 2017 +0200
@@ -1,7 +1,7 @@
 {% macro choices(name, choices_list, checked=none) %}
-    {% for choice in choices_list %}
+    {% for choice, label in choices_list %}
         <div class="form_input">
-            <input id="{{'field'|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{'field'|cur_gidx}}">{{choice}}</label>
+            <input id="{{'field'|next_gidx}}" type="radio" name="{{name}}" value="{{choice}}"{{" checked" if checked==choice}}><label for="{{'field'|cur_gidx}}">{{label}}</label>
         </div>
     {% endfor %}
 {% endmacro %}
@@ -17,5 +17,5 @@
 {% endmacro %}
 
 {% macro submit() %}
-    <input type="submit" value="Send">
+    <input type="submit" value="{{_("Send")}}">
 {% endmacro %}
--- a/default/invitation/welcome.html	Fri May 19 12:59:43 2017 +0200
+++ b/default/invitation/welcome.html	Sun May 21 16:10:44 2017 +0200
@@ -2,8 +2,8 @@
 
 {% block body %}
 <div class='invitation_header'>
-    <h1>Welcome {{name}}</h1>
-    <p class='instructions'>You have been invited to participate with the community, please choose an action below</p>
+    <h1>{% trans %}Welcome {{name}}{% endtrans %}</h1>
+    <p class='instructions'>{% trans %}You have been invited to participate with the community, please choose an action below{% endtrans %}</p>
 </div>
 
 {% if include_url is defined %}