Update translatable strings

Stop using the `_()` function, and use `{% trans %}` tags instead.
This commit is contained in:
Gergely Polonkai 2018-07-16 10:42:25 +02:00
parent 496b638694
commit 808c6bbdde
4 changed files with 18 additions and 6 deletions

View File

@ -86,7 +86,11 @@ class CalendarSocialApp(Flask):
# Make sure we look up users both by their usernames and email addresses # Make sure we look up users both by their usernames and email addresses
self.config['SECURITY_USER_IDENTITY_ATTRIBUTES'] = ('username', 'email') self.config['SECURITY_USER_IDENTITY_ATTRIBUTES'] = ('username', 'email')
self.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html' self.config['SECURITY_LOGIN_USER_TEMPLATE'] = 'login.html'
self.jinja_env.policies['ext.i18n.trimmed'] = True # pylint: disable=no-member
db.init_app(self) db.init_app(self)
babel = Babel(app=self) babel = Babel(app=self)
babel.localeselector(get_locale) babel.localeselector(get_locale)

View File

@ -29,7 +29,9 @@
<a class="item" href="{{ url_for('security.login') }}">{% trans %}Login{% endtrans %}</a> <a class="item" href="{{ url_for('security.login') }}">{% trans %}Login{% endtrans %}</a>
{% else %} {% else %}
<div class="item"> <div class="item">
{{ _('Logged in as %(username)s', username=('<a href="' + url_for('display_profile', username=current_user.username) + '">' + current_user.username + '</a>') | safe) }} {% trans username=('<a href="' + url_for('display_profile', username=current_user.username) + '">' + current_user.username + '</a>') | safe -%}
Logged in as {{username}}
{%- endtrans %}
</div> </div>
<a class="item" href="{{ url_for('hello') }}">{% trans %}Calendar view{% endtrans %}</a> <a class="item" href="{{ url_for('hello') }}">{% trans %}Calendar view{% endtrans %}</a>
<a class="item" href="{{ url_for('notifications') }}">{% trans %}Notifications{% endtrans %}</a> <a class="item" href="{{ url_for('notifications') }}">{% trans %}Notifications{% endtrans %}</a>

View File

@ -1,17 +1,21 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% from '_macros.html' import field %} {% 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 %} {% block content %}
<h2 class="ui header"> <h2 class="ui header">
<div class="content"> <div class="content">
{{ event.title }}<br> {{ event.title }}<br>
<div class="sub header"> <div class="sub header">
{%- if current_user.timezone | string != event.time_zone -%} {%- if current_user.timezone | string != event.time_zone -%}
<span title="{{ _('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|datetimeformat(rebase=false), end_time=event.end_time_tz|datetimeformat(rebase=false)) }}"> <span title="{{ time_zone_warning() }}">
<i class="fa fa-exclamation-triangle timezone-warning"></i> <i class="fa fa-exclamation-triangle timezone-warning"></i>
<span class="sr-only"> <span class="sr-only">{{ time_zone_warning() }}</span>
{{ _('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) }}
</span>
</span> </span>
{% endif %} {% endif %}
{{ event.start_time_for_user(current_user) | datetimeformat(rebase=false) }} {{ event.start_time_for_user(current_user) | datetimeformat(rebase=false) }}

View File

@ -1,7 +1,9 @@
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %} {% 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' %} {% include 'month-view.html' %}