Skip to content

Commit

Permalink
localization: wrap more text strings in templates
Browse files Browse the repository at this point in the history
docs: fix typos in docs, mention html lang setting
  • Loading branch information
ikreymer committed Jun 7, 2021
1 parent 1f29b53 commit 4337afe
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 39 deletions.
6 changes: 4 additions & 2 deletions docs/manual/localization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pywb supports configuring different language locales and loading different langu

pywb can extract all text from templates and generate CSV files for translation and convert them back into a binary format used for localization/internationalization.

(pywb uses the `Babel library <http://babel.pocoo.org/en/latest/>`_ which extends the `standard Python i18n system <https://docs.python.org/3/library/gettext.html>`_
(pywb uses the `Babel library <http://babel.pocoo.org/en/latest/>`_ which extends the `standard Python i18n system <https://docs.python.org/3/library/gettext.html>`_)

Locales to use are configured in the ``config.yaml``.

Expand Down Expand Up @@ -83,7 +83,9 @@ pywb can be configured with a default, single-language locale, by setting the ``
- es


With this configuration, pywb will automatically use the ``es`` locale for all text strings.
With this configuration, pywb will automatically use the ``es`` locale for all text strings in pywb pages.

pywb will also set the ``<html lang="es">`` so that the browser will recognize the correct locale.


Mutli-language Translations
Expand Down
12 changes: 6 additions & 6 deletions pywb/templates/error.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}
{% block title %}Pywb Error{% endblock %}
{% block title %}{{ _('Pywb Error') }}{% endblock %}
{% block body %}
<div class="container text-danger">
<div class="row justify-content-center">
Expand All @@ -8,22 +8,22 @@ <h2 class="display-2">Pywb Error</h2>
<div class="row">
<div class="col-12 text-center">
{% if err_status == 451 %}
<p class="lead">Access Blocked to {{ err_msg }}</p>
<p class="lead">{% trans %}Access Blocked to {{ err_msg }}{% endtrans %}</p>

{% elif err_status == 404 and err_details == 'coll_not_found' %}
<p>Collection not found: <b>{{ err_msg }}</b></p>
<p>{% trans %}Collection not found: <b>{{ err_msg }}{% endtrans %}</b></p>

<p><a href="/">See list of valid collections</a></p>
<p><a href="/">{{ _('See list of valid collections') }}</a></p>

{% elif err_status == 404 and err_details == 'static_file_not_found' %}
<p>Static file not found: <b>{{ err_msg }}</b></p>
<p>{% trans %}Static file not found: <b>{{ err_msg }}{% endtrans %}</b></p>

{% else %}

<p class="lead">{{ err_msg }}</p>

{% if err_details %}
<p class="lead">Error Details:</p>
<p class="lead">{% trans %}Error Details:{% endtrans %}</p>
<pre>{{ err_details }}</pre>
{% endif %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion pywb/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="container">
<div class="row">
<h2 class="display-2">{{ _('Pywb Wayback Machine') }}</h2>
<p class="lead">This archive contains the following collections:</p>
<p class="lead">{{ _('This archive contains the following collections:') }}</p>
</div>
<div class="row">
<ul>
Expand Down
4 changes: 2 additions & 2 deletions pywb/templates/not_found.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "base.html" %}

{% block title %}URL Not Found{% endblock %}
{% block title %}{{ _('URL Not Found') }}{% endblock %}

{% block body %}
<div class="container">
Expand All @@ -13,7 +13,7 @@ <h4>{% trans %}URL Not Found{% endtrans %}</h4>
{% if wbrequest and wbrequest.env.pywb_proxy_magic and url %}
<p>
<a href="//select.{{ wbrequest and wbrequest.env.pywb_proxy_magic }}/{{ url }}">
Try Different Collection
{{ _('Try Different Collection') }}
</a>
</p>
{% endif %}
Expand Down
56 changes: 28 additions & 28 deletions pywb/templates/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h4 class="display-4">
name="search" placeholder="Enter a URL to search for"
title="{{ _('Enter a URL to search for') }}" type="search" required/>
<div class="invalid-feedback">
{{ _('Please enter a URL') }}
{% trans %}'Please enter a URL{% endtrans %}
</div>
</div>
</div>
Expand All @@ -54,94 +54,94 @@ <h4 class="display-4">
<div class="collapse mt-3" id="advancedOptions">
<div class="form-group form-row">
<label for="match-type-select" class="col-sm-2 col-form-label" aria-label="Match Type">
Match Type:
{{ _('Match Type:') }}
</label>
<select id="match-type-select" class="form-control form-control col-sm-6">
<option value=""></option>
<option value="prefix">Prefix</option>
<option value="host">Host</option>
<option value="domain">Domain</option>
<option value="prefix">{% trans %}Prefix{% endtrans %}</option>
<option value="host">{% trans %}Host{% endtrans %}</option>
<option value="domain">{% trans %}Domain{% endtrans %}</option>
</select>
</div>
<p style="cursor: help;">
<span data-toggle="tooltip" data-placement="right"
title="Restricts the results to the given date/time range (inclusive)">
Date/Time Range
{{ _('Date/Time Range') }}
</span>
</p>
<div class="form-row">
<div class="col-6">
<label class="sr-only" for="dt-from" aria-label="Date/Time Range From">From:</label>
<label class="sr-only" for="dt-from" aria-label="Date/Time Range From">{% trans %}From:{% endtrans %}</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">From:</div>
<div class="input-group-text">{% trans %}From:{% endtrans %}</div>
</div>
<input id="dt-from" type="number" name="date-range-from" class="form-control"
pattern="^\d{4,14}$">
<div class="invalid-feedback" id="dt-from-bad">
Please enter a valid <b>From</b> timestamp. Timestamps may be 4 <= ts <=14 digits
{% trans %}Please enter a valid <b>From</b> timestamp. Timestamps may be 4 <= ts <=14 digits{% endtrans %}
</div>
</div>
</div>
<div class="col-6">
<label class="sr-only" for="dt-to" aria-label="Date/Time Range To">To:</label>
<label class="sr-only" for="dt-to" aria-label="Date/Time Range To">{% trans %}To:{% endtrans %}</label>
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text">To:</div>
<div class="input-group-text">{% trans %}To:{% endtrans %}</div>
</div>
<input id="dt-to" type="number" name="date-range-to" class="form-control" pattern="^\d{4,14}$">
<div class="invalid-feedback" id="dt-to-bad">
Please enter a valid <b>To</b> timestamp. Timestamps may be 4 <= ts <=14 digits
{% trans %}Please enter a valid <b>To</b> timestamp. Timestamps may be 4 <= ts <=14 digits{% endtrans %}
</div>
</div>
</div>
</div>
<div class="form-group mt-3">
<div class="form-row">
<div class="col-6">
<p>Filtering</p>
<p>{% trans %}Filtering{% endtrans %}</p>
</div>
<div class="col-6">
<button id="clear-filters" class="btn btn-outline-warning float-right" type="button">
Clear Filters
{% trans %}Clear Filters{% endtrans %}
</button>
<button id="add-filter" class="btn btn-outline-secondary float-right mr-2" type="button">
Add Filter
{% trans %}Add Filter{% endtrans %}
</button>
</div>
</div>
<div class="form-row">
<div class="col-6">
<div class="row pb-1">
<label for="filter-by" class="col-form-label col-3">By:</label>
<label for="filter-by" class="col-form-label col-3">By:{% endtrans %}</label>
<select id="filter-by" class="form-control col-7">
<option value="" selected></option>
<option value="mime">Mime Type</option>
<option value="status">Status</option>
<option value="url">URL</option>
<option value="mime">{% trans %}Mime Type{% endtrans %}</option>
<option value="status">{% trans %}Status{% endtrans %}</option>
<option value="url">{% trans %}URL{% endtrans %}</option>
</select>
</div>
<div class="row pb-1">
<label for="filter-modifier" class="col-form-label col-3">How:</label>
<label for="filter-modifier" class="col-form-label col-3">{% trans %}How:{% endtrans %}</label>
<select id="filter-modifier" class="form-control col-7">
<option value="=">Contains</option>
<option value="==">Matches Exactly</option>
<option value="=~">Matches Regex</option>
<option value="=!">Does Not Contains</option>
<option value="=!=">Is Not</option>
<option value="=!~">Does Not Begins With</option>
<option value="=">{% trans %}Contains{% endtrans %}</option>
<option value="==">{% trans %}Matches Exactly{% endtrans %}</option>
<option value="=~">{% trans %}Matches Regex{% endtrans %}</option>
<option value="=!">{% trans %}Does Not Contain{% endtrans %}</option>
<option value="=!=">{% trans %}Is Not{% endtrans %}</option>
<option value="=!~">{% trans %}Does Not Begins With{% endtrans %}</option>
</select>
</div>
<div class="row">
<label for="filter-expression" class="col-form-label col-3">Expr:</label>
<label for="filter-expression" class="col-form-label col-3">{% trans %}Expr:{% endtrans %}</label>
<input type="text" id="filter-expression" class="form-control col-7"
placeholder="Enter an expression to filter by"
>
</div>
</div>
<div class="col-6">
<ul id="filter-list" class="filter-list">
<li id="filtering-nothing">No Filter</li>
<li id="filtering-nothing">{% trans %}No Filter{% endtrans %}</li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 4337afe

Please sign in to comment.