Skip to content

Commit

Permalink
add translations wrapping to templates
Browse files Browse the repository at this point in the history
  • Loading branch information
“OMosimege” committed Jun 6, 2024
1 parent 45f815a commit b88f5d6
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 58 deletions.
7 changes: 4 additions & 3 deletions app/templates/400.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "base_error.html" %}
{% load i18n %}

{% block error_content %}

<div class="card-body">
<h5 class="card-title">Bad Request (400)</h5>
<p class="card-text">The server cannot process the request due to client error.</p>
<a href="{% url 'home' %}" class="btn btn-primary">Go to home</a>
<h5 class="card-title">{% trans "Bad Request (400)" %}</h5>
<p class="card-text">{% trans "The server cannot process the request due to client error." %}"</p>
<a href="{% url 'home' %}" class="btn btn-primary">{% trans "Go to home" %}</a>
</div>

{% endblock error_content %}
7 changes: 4 additions & 3 deletions app/templates/403.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "base_error.html" %}
{% load i18n %}

{% block error_content %}

<div class="card-body">
<h5 class="card-title">Forbidden (403)</h5>
<p class="card-text">You do not have permission to access on this server.</p>
<a href="{% url 'home' %}" class="btn btn-primary">Go to home</a>
<h5 class="card-title">{% trans "Forbidden (403)" %}</h5>
<p class="card-text">{% trans "You do not have permission to access on this server." %}</p>
<a href="{% url 'home' %}" class="btn btn-primary">{% trans "Go to home" %}</a>
</div>

{% endblock error_content %}
7 changes: 4 additions & 3 deletions app/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "base_error.html" %}
{% load i18n %}

{% block error_content %}

<div class="card-body">
<h5 class="card-title">Not Found (404)</h5>
<p class="card-text">The requested resource was not found on this server.</p>
<a href="{% url 'home' %}" class="btn btn-primary">Go to home</a>
<h5 class="card-title">{% trans "Not Found (404)" %}</h5>
<p class="card-text">{% trans "The requested resource was not found on this server." %}</p>
<a href="{% url 'home' %}" class="btn btn-primary">{% trans "Go to home" %}</a>
</div>

{% endblock error_content %}
7 changes: 4 additions & 3 deletions app/templates/500.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "base_error.html" %}
{% load i18n %}

{% block error_content %}

<div class="card-body">
<h5 class="card-title">Internal Server Error (500)</h5>
<p class="card-text">The server encountered an unexpected condition that prevented it from fulfilling the request.</p>
<a href="{% url 'home' %}" class="btn btn-primary">Go to home</a>
<h5 class="card-title">{% trans "Internal Server Error (500)" %}</h5>
<p class="card-text">{% trans "The server encountered an unexpected condition that prevented it from fulfilling the request." %}</p>
<a href="{% url 'home' %}" class="btn btn-primary">{% trans "Go to home" %}</a>
</div>

{% endblock error_content %}
35 changes: 18 additions & 17 deletions app/templates/app/home.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}

{% block content %}

<div class="body">
<div class="section mt-3 mb-3">
<div class="card content-card">
<div class="card-body">
<h5 class="card-title">Welcome</h5>
<h5 class="card-title">{% trans "Welcome" %}</h5>
<p class="card-text">
The South African Centre for Digital Language Resources (SADiLaR) is a national research
{% blocktrans %}The South African Centre for Digital Language Resources (SADiLaR) is a national research
infrastructure that aims to ensure a digital future for our official languages.
It supports researchers in the fields of digital humanities and social sciences and also assists
institutions in their language implementation plans.
<a href="https://sadilar.org">Read more about SADiLaR.</a>
institutions in their language implementation plans.{% endblocktrans %}
<a href="https://sadilar.org">{% blocktrans %}Read more about SADiLaR.{% endblocktrans %}</a>
</p>
<p class="card-text">
SADiLaR conducted an audit at South African public higher education institutions that highlighted
areas that require attention.
<a href="https://sadilar.org/usaf_report_2023">Read the report.</a>
{% blocktrans %}SADiLaR conducted an audit at South African public higher education institutions that highlighted
areas that require attention.{% endblocktrans %}
<a href="https://sadilar.org/usaf_report_2023">{% blocktrans %}Read the report.{% endblocktrans %}</a>
</p>
<p class="card-text">
This platform highlights previous and current work at institutions to encourage collaboration and
disseminate resources.
{% blocktrans %}This platform highlights previous and current work at institutions to encourage collaboration and
disseminate resources.{% endblocktrans %}
</p>
</div>
</div>
Expand All @@ -32,17 +33,17 @@ <h5 class="card-title">Welcome</h5>
<div class="card content-card">
<div class="card-body d-flex justify-content-between align-items-end">
<div class="card-items">
<h5 class="card-title">Search</h5>
<h5 class="card-title">{% trans "Search" %}</h5>
<p class="card-text">
This platforms hosts terminology and other useful language resources.
{% blocktrans %}This platforms hosts terminology and other useful language resources.{% endblocktrans %}
</p>
<p class="card-text">
Search for a term or topic you are interested in.
(Functionality coming soon.)
{% blocktrans %}Search for a term or topic you are interested in.
(Functionality coming soon.){% endblocktrans %}
</p>
{# TODO: create the search box right here so that no additional click is required. #}
<a href="{% url 'search' %}" class="btn btn-primary">
Search a term
{% trans "Search a term" %}
</a>
</div>
</div>
Expand All @@ -52,12 +53,12 @@ <h5 class="card-title">Search</h5>
<div class="section mt-3 mb-3">
<div class="card content-card">
<div class="card-body">
<h5 class="card-title">Institutions</h5>
<h5 class="card-title">{% trans "Institutions" %}</h5>
<p class="card-text">
Browse information by institution.
{% trans "Browse information by institution." %}
</p>
<a href="{% url 'institutions' %}" class="btn btn-primary">
View
{% trans "View" %}
</a>
</div>
</div>
Expand Down
17 changes: 11 additions & 6 deletions app/templates/app/institutions.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}

{% block content %}

Expand All @@ -14,15 +15,19 @@ <h5 class="card-title">{{ institution.name }}</h5>
{{ institution.abbreviation }}
</p>
<p class="card-text">
{% if institution.project_count == 0 %}
no applicable project
{% else %}
{{institution.project_count}} applicable projects
{% endif %}
{% if institution.project_count == 0 %}
{% blocktrans %}no applicable project{% endblocktrans %}
{% else %}
{% blocktrans count project_count=institution.project_count %}
{{ project_count }} applicable project
{% plural %}
{{ project_count }} applicable projects
{% endblocktrans %}
{% endif %}
</p>
</div>
<div class="col-sm-6 right-col">
<p class="card-text">Profile completion:</p>
<p class="card-text">{% trans "Profile completion:" %}</p>
<div class="profile-icons">
{% if institution.rating <= 20 %}
<i class="bi-star-fill"></i>
Expand Down
31 changes: 16 additions & 15 deletions app/templates/app/search.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,58 @@
{% extends "base.html" %}
{% load static %}
{% load i18n %}

{% block content %}

<div class="body">
<div class="section mt-3 mb-3">
<div class="card content-card">
<div class="card-body">
<h5 class="card-title">Search a term</h5>
<h5 class="card-title">{% trans "Search a term" %}</h5>
{% if feature_flag == "search_feature" %}
{# test section start#}
<form>
<div class="input-group mb-3">
<input type="search" class="form-control" name="q" placeholder="Search">
<div class="input-group-append">
<button class="btn btn-outline-secondary">Search</button>
<button class="btn btn-outline-secondary">{% trans "Search" %}</button>
</div>
</div>
</form>
<div class="mb-3">
<span class="mr-5"><b>Results:</b></span>
<span class="mr-5"><b>{% trans "Results:" %}</b></span>
<span>{{ documents|length }}</span>
</div>
<div>
{% for document in documents %}
<div>
<ul>
<li>
<span class="mr-5 text-primary"><b>Title:</b></span>
<span class="mr-5 text-primary"><b>{% trans "Title:" %}</b></span>
<span>{{ document.title }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>Institution:</b></span>
<span class="mr-5"><b>{% trans "Institution:" %}</b></span>
<span>{{ document.institution }}</span>
</li>
<li class="mb-2">
<span class="mr-5"><b>Headline:</b></span>
<span class="mr-5"><b>{% trans "Headline:" %}</b></span>
<span>{{ document.search_headline|safe }}</span>
</li>
<li>
<span class="mr-5"><b>File:</b></span>
<span class="mr-5"><b>{% trans "File:" %}</b></span>
<span>{{ document.uploaded_file }}</span>
</li>
<li>
<span class="mr-5"><b>License:</b></span>
<span class="mr-5"><b>{% trans "License:" %}</b></span>
<span>{{ document.license }}</span>
</li>
<li>
<span class="mr-5"><b>Mime Type:</b></span>
<span class="mr-5"><b>{% trans "Mime Type:" %}</b></span>
<span>{{ document.mime_type }}</span>
</li>
<li class="mt-2">
<span class="mr-5"><b>Rank:</b></span>
<span class="mr-5"><b>{% trans "Rank:" %}</b></span>
<span><i>{{ document.rank }}</i></span>
</li>
</ul>
Expand All @@ -61,23 +62,23 @@ <h5 class="card-title">Search a term</h5>
<div class="pagination">
<span class="step-links">
{% if documents.has_previous %}
<a href="?page=1">&laquo; first</a>
<a href="?page={{ documents.previous_page_number }}">previous</a>
<a href="?page=1">&laquo; {% trans "first" %}</a>
<a href="?page={{ documents.previous_page_number }}">{% trans "previous" }</a>
{% endif %}
<span class="current">
Page {{ documents.number }} of {{ documents.paginator.num_pages }}.
</span>
{% if documents.has_next %}
<a href="?page={{ documents.next_page_number }}">next</a>
<a href="?page={{ documents.paginator.num_pages }}">last &raquo;</a>
<a href="?page={{ documents.next_page_number }}">{% trans "next" %}</a>
<a href="?page={{ documents.paginator.num_pages }}">{% trans "last" %} &raquo;</a>
{% endif %}
</span>
<hr>
</div>
</div>
{# test section end#}
{% else %}
<p>Functionality of this page coming soon</p>
<p>{% trans "Functionality of this page coming soon" %}</p>
{% endif %}
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>SADiLaR</title>
<meta name="description" content="SADiLaR">
<meta name="keywords" content="South African Centre for Digital Language Resources"/>
<title>{% trans "SADiLaR" %}</title>
<meta name="description" content="{% trans 'SADiLaR' %}">
<meta name="keywords" content="{% trans 'South African Centre for Digital Language Resources' %}"/>
<meta charset="uft-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

Expand All @@ -30,23 +30,23 @@
<li class="nav-item">
<a
{% if current_page == 'home' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'home' %}">Home
class="nav-link" href="{% url 'home' %}">{% trans "Home" %}
</a>
</li>
<li class="nav-item">
<a
{% if current_page == 'search' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'search' %}">Search
class="nav-link" href="{% url 'search' %}">{% trans "Search" %}
</a>
</li>
<li class="nav-item">
<a
{% if current_page == 'institutions' %} class="nav-link active" aria-current="page" {% endif %}
class="nav-link" href="{% url 'institutions' %}">Institutions
class="nav-link" href="{% url 'institutions' %}">{% trans "Institutions" %}
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'admin:index' %}">Admin</a>
<a class="nav-link" href="{% url 'admin:index' %}">{% trans "Admin" %}</a>
</li>
</ul>
</div>
Expand Down
3 changes: 2 additions & 1 deletion app/templates/base_error.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "base.html" %}
{% load i18n %}

{% block content %}

<div class="section mt-3 mb-3">
<div class="card text-center error-card">
<div class="card-header">
Error
{% trans "Error" %}
</div>
<div id="error_content">
{% block error_content %}
Expand Down

0 comments on commit b88f5d6

Please sign in to comment.