Skip to content

Make templates translatable #6598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions warehouse/templates/403.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
-#}
{% extends "error-base-with-search.html" %}

{% block title %}Access Denied / Forbidden (403){% endblock %}
{% block title %}{% trans %}Access Denied / Forbidden (403){% endtrans %}{% endblock %}

{% block error_heading %}You don't have permission to view this page{% endblock %}
{% block error_heading %}{% trans %}You don't have permission to view this page{% endtrans %}{% endblock %}

{% block error_code %}403{% endblock %}
10 changes: 5 additions & 5 deletions warehouse/templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
-#}
{% extends "error-base-with-search.html" %}

{% block title %}Page Not Found (404){% endblock %}
{% block title %}{% trans %}Page Not Found (404){% endtrans %}{% endblock %}

{% block error_heading %}We looked everywhere but couldn't find this page{% endblock %}
{% block error_heading %}{% trans %}We looked everywhere but couldn't find this page{% endtrans %}{% endblock %}

{% block error_code %}404{% endblock %}

Expand All @@ -26,12 +26,12 @@
{% block easter_egg %}
<div class="viewport-section viewport-section--ee">
<div class="viewport-section__content">
<h2 class="viewport-section__heading">And now for something <br><span>completely different</span></h2>
<h2 class="viewport-section__heading">{% trans %}And now for something <br><span>completely different{% endtrans %}</span></h2>
<div class="viewport-section__video">
<div class="viewport-section__video-container">
<iframe title="Monty Python - The Cheese Shop Sketch" width="560" height="315" src="https://www.youtube-nocookie.com/embed/zB8pbUW5n1g?rel=0&enablejsapi=1&showinfo=0&iv_load_policy=3&origin={{ request.host_url }}" frameborder="0" allowfullscreen></iframe>
<iframe title="{% trans %}Monty Python - The Cheese Shop Sketch{% endtrans %}" width="560" height="315" src="https://www.youtube-nocookie.com/embed/zB8pbUW5n1g?rel=0&enablejsapi=1&showinfo=0&iv_load_policy=3&origin={{ request.host_url }}" frameborder="0" allowfullscreen></iframe>
</div>
<p><a href="http://www.montypython.net/scripts/cheese.php" title="External link" target="_blank" rel="noopener">View video transcript</a></p>
<p><a href="http://www.montypython.net/scripts/cheese.php" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}View video transcript{% endtrans %}</a></p>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions warehouse/templates/410.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
-#}
{% extends "error-base-with-search.html" %}

{% block title %}Page removed (410){% endblock %}
{% block title %}{% trans %}Page removed (410){% endtrans %}{% endblock %}

{% block error_heading %}The page you are looking for has been removed{% endblock %}
{% block error_heading %}{% trans %}The page you are looking for has been removed{% endtrans %}{% endblock %}

{% block error_code %}410{% endblock %}
26 changes: 19 additions & 7 deletions warehouse/templates/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,38 @@
-#}
{% extends "error-base.html" %}

{% block title %}Internal server error (500){% endblock %}
{% block title %}{% trans %}Internal server error (500){% endtrans %}{% endblock %}

{% block error_heading %}Something went wrong{% endblock %}
{% block error_heading %}{% trans %}Something went wrong{% endtrans %}{% endblock %}

{% block error_text %}
<div class="viewport-section__text no-top-margin no-top-padding">
{% trans trimmed %}
<p>We are experiencing technical issues that are affecting our ability to serve you this site.</p>
<p>We are aware of the problem and are working to resolve it as soon as possible.</p>
{% endtrans %}

<ul class="unstyled">
<li><a href="https://status.python.org/" title="External link" target="_blank" rel="noopener">Check our status page</a></li>
<li><a href="https://twitter.com/PythonStatus" title="External link" target="_blank" rel="noopener">View Python Status on Twitter</a></li>
<li><a href="https://status.python.org/" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}Check our status page{% endtrans %}</a></li>
<li><a href="https://twitter.com/PythonStatus" title="{% trans %}External link{% endtrans %}" target="_blank" rel="noopener">{% trans %}View Python Status on Twitter{% endtrans %}</a></li>
</ul>
<br>
<p class="no-bottom-padding"><strong>Error code 500</strong></p>
<p class="no-bottom-padding"><strong>{% trans %}Error code 500{% endtrans %}</strong></p>
<hr class="viewport-section__rule">
<p>
<strong>
Rely on PyPI to get your job done?<br>
Consider <a href="https://github.com/pypa/warehouse" target="_blank" rel="noopener">contributing</a> or <a href="https://psfmember.org/civicrm/contribute/transact?reset=1&id=13" target="_blank" rel="noopener">donating</a> to help us build a more stable and secure platform.
{% trans %}Rely on PyPI to get your job done?{% endtrans %}<br>
{% trans trimmed %}
Consider
<a href="https://github.com/pypa/warehouse" target="_blank" rel="noopener">
contributing
</a>
or
<a href="https://psfmember.org/civicrm/contribute/transact?reset=1&id=13" target="_blank" rel="noopener">
donating
</a>
to help us build a more stable and secure platform.
{% endtrans %}
</strong>
</p>
</div>
Expand Down
24 changes: 12 additions & 12 deletions warehouse/templates/accounts/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
{% extends "base.html" %}

{% block title %}
{% if form.errors %}Error processing form{% endif %}
Log in
{% if form.errors %}{% trans %}Error processing form{% endtrans %} -{% endif %}
{% trans %}Log in{% endtrans %}
{% endblock %}

{% block content %}
Expand All @@ -27,7 +27,7 @@

<div class="horizontal-section">
<div class="site-container">
<h1 class="page-title">Log in to {{ title }}</h1>
<h1 class="page-title">{% trans title=title %}Log in to {{ title }}{% endtrans %}</h1>

<form method="POST" action="{{ request.current_route_path() }}">
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
Expand All @@ -46,12 +46,12 @@ <h1 class="page-title">Log in to {{ title }}</h1>

<div class="form-group">
<label for="username" class="form-group__label">
Username
{% trans %}Username{% endtrans %}
{% if form.username.flags.required %}
<span class="form-group__required">(required)</span>
<span class="form-group__required">{% trans %}(required){% endtrans %}</span>
{% endif %}
</label>
{{ form.username(placeholder="Your username", autocapitalize="off", autocomplete="username", spellcheck="false", required="required", class_="form-group__input", **{"aria-describedby":"username-errors"}) }}
{{ form.username(placeholder=gettext("Your username"), autocapitalize="off", autocomplete="username", spellcheck="false", required="required", class_="form-group__input", **{"aria-describedby":"username-errors"}) }}
<div id="username-errors">
{% if form.username.errors %}
<ul class="form-errors" role="alert">
Expand All @@ -66,17 +66,17 @@ <h1 class="page-title">Log in to {{ title }}</h1>
<div data-controller="password" class="form-group">
<div class="split-layout">
<label for="password" class="form-group__label">
Password
{% trans %}Password{% endtrans %}
{% if form.password.flags.required %}
<span class="form-group__required">(required)</span>
<span class="form-group__required">{% trans %}(required){% endtrans %}</span>
{% endif %}
</label>
<label for="show-password">
<input data-action="change->password#togglePasswords" data-target="password.showPassword"
id="show-password" type="checkbox">&nbsp;Show password
id="show-password" type="checkbox">&nbsp;{% trans %}Show password{% endtrans %}
</label>
</div>
{{ form.password(placeholder="Your password", required="required", class_="form-group__input", autocomplete="current-password", spellcheck="false", data_target="password.password", **{"aria-describedby":"password-errors"}) }}
{{ form.password(placeholder=gettext("Your password"), required="required", class_="form-group__input", autocomplete="current-password", spellcheck="false", data_target="password.password", **{"aria-describedby":"password-errors"}) }}
<div id="password-errors">
{% if form.password.errors %}
<ul class="form-errors" role="alert">
Expand All @@ -91,10 +91,10 @@ <h1 class="page-title">Log in to {{ title }}</h1>
<div class="form-group">
<div class="split-layout split-layout--table">
<div>
<input type="submit" value="Log in" class="button button--primary">
<input type="submit" value="{% trans %}Log in{% endtrans %}" class="button button--primary">
</div>
<span>
<a href="{{request.route_url('accounts.request-password-reset')}}">Forgot password?</a>
<a href="{{request.route_url('accounts.request-password-reset')}}">{% trans %}Forgot password?{% endtrans %}</a>
</span>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions warehouse/templates/accounts/logout.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
-#}
{% extends "base.html" %}

{% block title %}Log out{% endblock %}
{% block title %}{% trans %}Log out{% endtrans %}{% endblock %}

{% block content %}
<h1>Log out of {{ request.user.username }}</h1>
<h1>{% trans account_name=request.user.username %}Log out of {{ account_name }}{% endtrans %}</h1>
<form method="POST" action="{{ request.current_route_path() }}">
<input name="csrf_token" type="hidden" value="{{ request.session.get_csrf_token() }}">
{% if redirect.data %}
<input name="{{ redirect.field }}" type="hidden" value="{{ redirect.data }}">
{% endif %}
<input type="submit" value="Log Out">
<input type="submit" value="{% trans %}Log Out{% endtrans %}">
</form>
{% endblock %}
16 changes: 8 additions & 8 deletions warehouse/templates/accounts/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
-#}
{% extends "base.html" %}

{% block title %}Profile of {{ user.username }}{% endblock %}
{% block title %}{% trans username=user.username %}Profile of {{ username }}{% endtrans %}{% endblock %}

{% block content %}
<div class="horizontal-section horizontal-section--medium">
<div class="left-layout">
<div class="left-layout__sidebar">
<div class="author-profile">
{% set alt = "Avatar for {} from gravatar.com".format(user.name|default(user.username, true)) %}
{% set alt = gettext("Avatar for {user} from gravatar.com").format(user=user.name|default(user.username, true)) %}
<img src="{{ gravatar(request, user.email, size=225) }}" alt="{{ alt }}" title="{{ alt }}">
<div class="author-profile__info">
{% if user.name %}
Expand All @@ -29,14 +29,14 @@ <h1 class="author-profile__name">{{ user.name }}</h1>
<div class="author-profile__meta">
<p>
<i class="fa fa-user-circle" aria-hidden="true"></i>
<span class="sr-only">Username</span>
<span class="sr-only">{% trans %}Username{% endtrans %}</span>
&nbsp;&nbsp;{{ user.username }}
</p>
{% if user.date_joined %}
<p>
<i class="fa fa-calendar-alt" aria-hidden="true"></i>
<span class="sr-only">Date joined</span>
&nbsp;&nbsp;Joined on {{ user.date_joined|format_date() }}
<span class="sr-only">{% trans %}Date joined{% endtrans %}</span>
&nbsp;&nbsp;{% trans start_date=user.date_joined|format_date() %}Joined on {{ start_date }}{% endtrans %}
</p>
{% endif %}
</div>
Expand All @@ -56,7 +56,7 @@ <h2>
{{ count }} projects
{% endtrans %}
{% else %}
No projects
{% trans %}No projects{% endtrans %}
{% endif %}
</h2>
<div class="package-list">
Expand All @@ -65,15 +65,15 @@ <h2>
<a class="package-snippet" href="{{ request.route_path('packaging.project', name=project.normalized_name) }}">
<h3 class="package-snippet__title">{{ project.name }}</h3>
<p class="package-snippet__meta">
Last released on {{ project.releases[0].created|format_date() }}
{% trans release_date=project.releases[0].created|format_date() %}Last released on {{ release_date }}{% endtrans %}
</p>
<p class="package-snippet__description">{{ project.releases[0].summary }}</p>
</a>
{% endfor %}
{% else %}
{% csi request.route_url("includes.current-user-profile-callout", username=user.username) %}
<div class="callout-block no-top-margin">
<p>{{ user.name|default(user.username, true) }} has not uploaded any projects to PyPI, yet</p>
<p>{% trans user=user.name|default(user.username, true) %}{{ user }} has not uploaded any projects to PyPI, yet{% endtrans %}</p>
</div>
{% endcsi %}
{% endif %}
Expand Down
Loading