From 808c6bbdde201e28408a73d2768a706c6ffbb0ad Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Mon, 16 Jul 2018 10:42:25 +0200 Subject: [PATCH] Update translatable strings Stop using the `_()` function, and use `{% trans %}` tags instead. --- calsocial/__init__.py | 4 ++++ calsocial/templates/base.html | 4 +++- calsocial/templates/event-details.html | 12 ++++++++---- calsocial/templates/index.html | 4 +++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/calsocial/__init__.py b/calsocial/__init__.py index 452e40d..00779f9 100644 --- a/calsocial/__init__.py +++ b/calsocial/__init__.py @@ -86,7 +86,11 @@ class CalendarSocialApp(Flask): # Make sure we look up users both by their usernames and email addresses self.config['SECURITY_USER_IDENTITY_ATTRIBUTES'] = ('username', 'email') self.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html' + + self.jinja_env.policies['ext.i18n.trimmed'] = True # pylint: disable=no-member + db.init_app(self) + babel = Babel(app=self) babel.localeselector(get_locale) diff --git a/calsocial/templates/base.html b/calsocial/templates/base.html index cb75be9..f363a54 100644 --- a/calsocial/templates/base.html +++ b/calsocial/templates/base.html @@ -29,7 +29,9 @@ {% trans %}Login{% endtrans %} {% else %}
- {{ _('Logged in as %(username)s', username=('' + current_user.username + '') | safe) }} + {% trans username=('' + current_user.username + '') | safe -%} + Logged in as {{username}} + {%- endtrans %}
{% trans %}Calendar view{% endtrans %} {% trans %}Notifications{% endtrans %} diff --git a/calsocial/templates/event-details.html b/calsocial/templates/event-details.html index 8af533d..6017549 100644 --- a/calsocial/templates/event-details.html +++ b/calsocial/templates/event-details.html @@ -1,17 +1,21 @@ {% extends 'base.html' %} {% from '_macros.html' import field %} +{% macro time_zone_warning() %} + {% trans timezone=event.time_zone, start_time=event.start_time_tz | datetimeformat(rebase=false), end_time=event.end_time_tz | datetimeformat(rebase=false) -%} +This event is organised in the {{timezone}} time zone, in which it happens between {{start_time}} and {{end_time}} + {%- endtrans %} +{% endmacro %} + {% block content %}

{{ event.title }}
{%- if current_user.timezone | string != event.time_zone -%} - + - - {{ _('This event is organised in the %(timezone)s time zone, in which it happens between %(start_time)s and %(end_time)s', timezone=event.time_zone, start_time=event.start_time_tz, end_time=event.end_time_tz) }} - + {{ time_zone_warning() }} {% endif %} {{ event.start_time_for_user(current_user) | datetimeformat(rebase=false) }} diff --git a/calsocial/templates/index.html b/calsocial/templates/index.html index 2e86f2b..276fc1c 100644 --- a/calsocial/templates/index.html +++ b/calsocial/templates/index.html @@ -1,7 +1,9 @@ {% extends 'base.html' %} {% block content %} -{{ _('Welcome to Calendar.social, %(username)s!', username=current_user.username) }} +{% trans username=current_user.username -%} +Welcome to Calendar.social, {{username}}! +{%- endtrans %} {% include 'month-view.html' %}