diff --git a/README.md b/README.md index 8c40d8a..02ecff2 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,18 @@ During debugging, we additionally use the [Django Debug Toolbar](https://django- And then uncomment the lines referring to the toolbar in `timealign/settings.py`. +## Localization +To add site localizations use the following command: + + # Go to the timealign folder + cd timealign + # To add a .po file that collects all the different message variables in templates + django-admin makemessages -l -i + # or add them all directly + django-admin makemessages --all + # To compile the translated texts + django-admin compilemessages + ## Documentation You can find ERD diagrams of the applications in [`doc/models`](doc/models/README.md). diff --git a/core/static/core/images/MDS-crop.png b/core/static/core/images/MDS-crop.png new file mode 100644 index 0000000..d2a99ca Binary files /dev/null and b/core/static/core/images/MDS-crop.png differ diff --git a/core/static/core/images/MDS.png b/core/static/core/images/MDS.png new file mode 100644 index 0000000..8ec47ad Binary files /dev/null and b/core/static/core/images/MDS.png differ diff --git a/core/static/core/landing-nav.css b/core/static/core/landing-nav.css new file mode 100644 index 0000000..9991cfd --- /dev/null +++ b/core/static/core/landing-nav.css @@ -0,0 +1,106 @@ +/* https://work.smarchal.com/twbscolor/3.3.7/css/000000000000ffffffffcd000 */ + +.navbar { + border: 0; +} + +.navbar-inverse { + background-color: var(--color-main); + text-transform: uppercase; + font-size: 1.2rem; + font-weight: 700; + letter-spacing: .1rem; +} + +.navbar-inverse .navbar-brand { + color: var(--color-text-dark); +} + +.navbar-inverse .navbar-text { + color: var(--color-text-dark); +} + +.navbar-inverse .navbar-nav > li > a { + color: var(--color-text-dark); + padding-left: 2rem; + padding-right: 2rem; +} + +.navbar-inverse .navbar-nav > li > a.active { + color: var(--color-primary); +} + +.navbar-inverse .navbar-nav > li > a.active:hover, +.navbar-inverse .navbar-nav > li > a.active:focus { + background-color: transparent; + cursor: auto; +} + +.navbar-inverse .navbar-nav > li > a:hover, +.navbar-inverse .navbar-nav > li > a:focus { + background-color: var(--color-primary); +} + +.navbar-inverse .navbar-nav > li > a:active { + background-color: var(--color-accent); +} + +.navbar-inverse .navbar-nav > .active > a:hover, +.navbar-inverse .navbar-nav > .active > a:focus { + background-color: #080808; +} + +.navbar-inverse .navbar-nav > .open > a:hover, +.navbar-inverse .navbar-nav > .open > a:focus { + background-color: var(--color-primary); +} + +.navbar-inverse .navbar-toggle { + background-color: var(--color-primary); +} + +.navbar-inverse .navbar-toggle:hover, +.navbar-inverse .navbar-toggle:focus { + background-color: var(--color-primary); +} + +.navbar-inverse .navbar-toggle .icon-bar { + color: var(--color-text-light); +} + +.navbar-inverse .navbar-link { + color: var(--color-text-dark); +} + +.navbar-inverse .navbar-link:hover { + color: var(--color-text-light); +} + +@media (max-width: 767px) { + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { + color: var(--color-text-dark); + } + + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { + background-color: var(--color-primary); + } +} + +.navbar .dropdown-menu { + background-color: var(--color-main); +} + +.navbar .dropdown-menu .dropdown-item { + display: block; + color: var(--color-text-dark); + text-decoration: none; + padding: 1rem; + line-height: 1; +} + +.navbar .dropdown-menu .dropdown-item:hover, +.navbar .dropdown-menu .dropdown-item:focus { + background-color: var(--color-primary); + color: var(--color-text-light); +} \ No newline at end of file diff --git a/core/static/core/landing-style.css b/core/static/core/landing-style.css new file mode 100644 index 0000000..7fea457 --- /dev/null +++ b/core/static/core/landing-style.css @@ -0,0 +1,130 @@ +:root { + --color-main: #ffcd00; + --color-primary: #24a793; + --color-accent: #ffe6ab; + --color-text-dark: #000000; + --color-text-light: #ffffff; +} + +body { + background-color: var(--color-text-light); + font-size: 1.8rem; + line-height: 1.8; + font-family: Open Sans,sans-serif; +} + +footer { + border-top: 2px solid var(--color-main); + margin-top: 20px; + padding-top: 20px; +} + +footer img { + margin: auto; + display: block; +} + +footer p { + text-align: center; +} + +hr { + border-top: 2px solid var(--color-text-light); +} + +header.masthead { + padding-top: 5rem; + padding-bottom: 5rem; + background-color: var(--color-main); +} + +header.masthead .masthead-heading { + font-size: 6rem; +} + +header.masthead .masthead-subheading { + font-size: 2rem; +} + +@media (min-width: 767px) { + header.masthead { + padding-top: calc(10rem + 55px); + padding-bottom: 10rem; + } +} + +a.main { + background-color: var(--color-primary); + color: var(--color-text-light); +} + +a.main:hover, +a.main:focus { + background-color: var(--color-accent); + color: var(--color-text-dark); + border: 1px solid var(--color-text-light); +} + +section { + padding: 4rem 0 6rem; +} + +section.secondary-section { + background-color: var(--color-accent); +} + +.mt-2 { + margin-top: 2rem; +} + +.mt-4 { + margin-top: 4rem; +} + +.mb-2 { + margin-bottom: 2rem; +} + +.mb-4 { + margin-bottom: 4rem; +} + +.m-2 { + margin: 2rem; +} + +.m-4 { + margin: 4rem; +} + +hr.primary { + border-color: var(--color-main); +} + +div.card { + background-color: var(--color-main); + padding: 0.5rem 1rem 3rem; + border-radius: 4px; + border: 2px solid #eeeeee; +} + +div.news { + margin: 0.5rem 1rem 3rem; + border-radius: 4px; + border: 2px solid var(--color-main); +} + +div.news-heading { + background-color: var(--color-main); + padding: 1rem; + min-height: 55px; +} + +div.news-body { + padding: 1rem; + background-color: transparent; +} + +div.news-body a { + font-weight: bold; +} diff --git a/core/templates/landing/_menu.html b/core/templates/landing/_menu.html new file mode 100644 index 0000000..e69de29 diff --git a/core/templates/landing/base.html b/core/templates/landing/base.html new file mode 100644 index 0000000..095ef19 --- /dev/null +++ b/core/templates/landing/base.html @@ -0,0 +1,130 @@ + + +{% load static %} +{% load i18n %} + + + + + + + + + + Translation Mining + + {# Load the tag library #} + {% load bootstrap3 %} + + {# Load CSS and JavaScript #} + {% bootstrap_css %} + {% bootstrap_javascript jquery=1 %} + + {# Load the SmartMenus library #} + + + + + {# Load the qTip library #} + + + + {# Load the Select2 library #} + + + + {# Custom CSS #} + + + + {# Allow for extra scripts and stylesheets #} + {% block head %}{% endblock %} + + + + + + +
{% bootstrap_messages %}
+ +{% block content %}{% endblock %} + +
+
+
+
+ Logo Utrecht University +
+
+

+ © 2021 UiL OTS, Utrecht + University. +
+ Research funded by NWO under grant 360-80-070. +
+ Powered by the Digital Humanities Lab, Utrecht University. +

+
+
+ Logo NWO +
+
+
+
+ + diff --git a/core/templates/landing/home.html b/core/templates/landing/home.html new file mode 100644 index 0000000..8bb4274 --- /dev/null +++ b/core/templates/landing/home.html @@ -0,0 +1,124 @@ +{% extends "landing/base.html" %} +{% load bootstrap3 %} +{% load static %} +{% load i18n %} +{% block head %} +{% endblock %} + +{% block menulist %} +{% endblock %} + +{% block content %} + +
+
+
+

Parallel Corpora and Linguistic Analysis

+
+

Parallel Corpora and Linguistic Analysis is an innovative methodology for investigating variation + across + languages.

+
+
+
+ +
+
+
+
+

Why Parallel Corpora and Linguistic Analysis?

+
+

+ Parallel Corpora are corpora that contain the same texts in different languages. The best-known example is Europarl + [Koehn + 2005] that compiles the multilingual minutes of the European Parliament. Parallel corpora are central to translation studies, + contrastive linguistics, and statistical machine translation. Typology and comparative linguistics have followed suit in + recent years and there is an ever-growing number of smaller and bigger parallel corpus compilation initiatives. +

+

+ However, from the perspective of linguistic analysis, the question remains how to best exploit the potential of parallel + corpora in a methodologically sound way. What we need for this is a joint effort to extend methodological insights from other + branches of corpus linguistics to parallel corpus linguistics, to explore new avenues of analysis that do justice to the + parallel nature of the data, and – above all – to probe the limits of parallel corpus data by investing in their analysis and + in the replication of findings. +

+

+ The Parallel Corpora and Linguistic Analysis initiative (PCLA) is an informal network of linguists working on parallel corpora + who share the above aims and exchange knowledge, resources, and ideas on a regular basis. This webpage keeps track of their + activities and of parallel corpus research more generally. +

+
+
+
+
+ +
+
+
+
+

Who is it for?

+
+
+
+
+
+
+
+

+ Researchers +

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rutrum.

+ Read more +
+
+
+
+
+
+

+ Teachers +

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rutrum.

+ Read more +
+
+
+
+
+
+

+ Students +

+
+

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent rutrum.

+ Read more +
+
+
+
+
+
+ +
+
+
+
+

Contact Us

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor + in + reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, + sunt + in culpa qui officia deserunt mollit anim id est laborum. +

+ Contact +
+
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/core/templates/landing/researcher.html b/core/templates/landing/researcher.html new file mode 100644 index 0000000..49a502f --- /dev/null +++ b/core/templates/landing/researcher.html @@ -0,0 +1,59 @@ +{% extends "base/base.html" %} + +{% load bootstrap3 %} + +{% block content %} + + + + + + + + + + + + {% for scenario in scenarios %} + + + + + + + {% endfor %} + +
CorpusScenarioLanguagesActions
+ {{ scenario.corpus.title }} + + {{ scenario.title }} + {% if scenario.is_test %}Test{% endif %} + + {{ scenario.from_languages }} {{ scenario.to_languages }} + + + MDS + + + Upset + + + Sankey + + + + + + + + {% if user.is_authenticated %} + + + + + + + {% endif %} +
+ +{% endblock %} diff --git a/core/templates/landing/student.html b/core/templates/landing/student.html new file mode 100644 index 0000000..fb1672b --- /dev/null +++ b/core/templates/landing/student.html @@ -0,0 +1,91 @@ +{% extends "landing/base.html" %} +{% load bootstrap3 %} +{% load static %} +{% block head %} +{% endblock %} + +{% block menulist %} + +{% endblock %} + +{% block content %} + +
+
+
+

Translation Mining for students

+
+

+ Translation Mining is an innovative methodology for investigating variation across languages. +

+
+
+
+ +
+
+
+
+

Details

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor + in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+
+
+
+
+ +
+
+
+
+

Methodology Examples

+
+
+
+
+ {# TODO: Need to collect scenarios automatically for students #} +
+ Scenario 1 abstract +
+
+ Scenario 2 abstract +
+
+ Scenario 3 abstract +
+
+
+
+ +
+
+
+
+

Latest student research

+
+
+
+
+
+ Thesis 1 abstract +
+
+ Thesis 2 abstract +
+
+ Thesis 3 abstract +
+
+
+ +
+{% endblock %} \ No newline at end of file diff --git a/core/templates/landing/teacher.html b/core/templates/landing/teacher.html new file mode 100644 index 0000000..b0694a4 --- /dev/null +++ b/core/templates/landing/teacher.html @@ -0,0 +1,68 @@ +{% extends "landing/base.html" %} +{% load bootstrap3 %} +{% load static %} +{% block head %} +{% endblock %} + +{% block menulist %} + +{% endblock %} + +{% block content %} + +
+
+
+

Translation Mining for teachers

+
+

+ Translation Mining is an innovative methodology for investigating variation across languages. +

+
+
+
+ +
+
+
+
+

Details

+
+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor + in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non + proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

+
+
+
+
+ +
+
+
+
+

Methodology Examples

+
+
+
+
+ {# TODO: Need to collect scenarios automatically for teachers #} +
+ Scenario 1 abstract +
+
+ Scenario 2 abstract +
+
+ Scenario 3 abstract +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/core/urls.py b/core/urls.py new file mode 100644 index 0000000..e38c72f --- /dev/null +++ b/core/urls.py @@ -0,0 +1,12 @@ +from django.urls import path +from django.views.generic import TemplateView + +from core.views import ActivateLanguageView + +urlpatterns = [ + path('', TemplateView.as_view(template_name='landing/home.html'), name='home'), + path('researcher', TemplateView.as_view(template_name='landing/researcher.html'), name='researcher'), + path('teacher', TemplateView.as_view(template_name='landing/teacher.html'), name='teacher'), + path('student', TemplateView.as_view(template_name='landing/student.html'), name='student'), + path('language/activate//', ActivateLanguageView.as_view(), name='activate_language') +] diff --git a/core/views.py b/core/views.py new file mode 100644 index 0000000..d9ef6ef --- /dev/null +++ b/core/views.py @@ -0,0 +1,46 @@ +from django.db.models import Prefetch +from django.shortcuts import redirect +from django.utils import translation +from django.views import generic +from django.views.generic.base import View + +from annotations.utils import get_available_corpora +from core.mixins import LimitedPublicAccessMixin +from stats.models import Scenario, ScenarioLanguage + + +class ActivateLanguageView(View): + language_code = '' + redirect_to = '' + + def get(self, request, *args, **kwargs): + self.redirect_to = request.META.get('HTTP_REFERER') + self.language_code = kwargs.get('language_code') + translation.activate(self.language_code) + request.session[translation.LANGUAGE_SESSION_KEY] = self.language_code + return redirect(self.redirect_to) + + +class PublicScenarioList(LimitedPublicAccessMixin, generic.TemplateView): + """Shows a list of Scenarios for different target groups""" + model = Scenario + template_name = 'stats/public_scenario_list.html' + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + + scenario_list_kwargs = {'corpus__in': get_available_corpora(self.request.user), 'is_public': True} + # TODO Bram: Is it necessary to add extra filter for teachers vs students? + languages_from = ScenarioLanguage.objects.filter(as_from=True).select_related('language') + languages_to = ScenarioLanguage.objects.filter(as_to=True).select_related('language') + scenarios = Scenario.objects \ + .filter(**scenario_list_kwargs) \ + .exclude(last_run__isnull=True) \ + .select_related('corpus') \ + .prefetch_related(Prefetch('scenariolanguage_set', queryset=languages_from, to_attr='languages_from'), + Prefetch('scenariolanguage_set', queryset=languages_to, to_attr='languages_to')) \ + .order_by('corpus__title') \ + .defer('mds_model', 'mds_matrix', 'mds_fragments', 'mds_labels') # Don't fetch the PickledObjectFields + + context['scenarios'] = scenarios + return context diff --git a/timealign/locale/en/LC_MESSAGES/django.mo b/timealign/locale/en/LC_MESSAGES/django.mo new file mode 100644 index 0000000..392530d Binary files /dev/null and b/timealign/locale/en/LC_MESSAGES/django.mo differ diff --git a/timealign/locale/en/LC_MESSAGES/django.po b/timealign/locale/en/LC_MESSAGES/django.po new file mode 100644 index 0000000..d7aaee1 --- /dev/null +++ b/timealign/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,43 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-11-09 14:18+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: core/templates/landing/_menu.html:17 core/templates/landing/home.html:25 +msgid "menu.researcher" +msgstr "Researchers" + +#: core/templates/landing/_menu.html:18 core/templates/landing/home.html:26 +msgid "menu.teacher" +msgstr "For teachers" + +#: core/templates/landing/_menu.html:19 core/templates/landing/home.html:27 +msgid "menu.student" +msgstr "For students" + +#: core/templates/landing/home.html:24 +msgid "menuP" +msgstr "PPen" + +#: timealign/settings.py:119 +msgid "Dutch" +msgstr "Dutch" + +#: timealign/settings.py:120 +msgid "English" +msgstr "English" diff --git a/timealign/locale/nl/LC_MESSAGES/django.mo b/timealign/locale/nl/LC_MESSAGES/django.mo new file mode 100644 index 0000000..d127ab4 Binary files /dev/null and b/timealign/locale/nl/LC_MESSAGES/django.mo differ diff --git a/timealign/locale/nl/LC_MESSAGES/django.po b/timealign/locale/nl/LC_MESSAGES/django.po new file mode 100644 index 0000000..fd11c95 --- /dev/null +++ b/timealign/locale/nl/LC_MESSAGES/django.po @@ -0,0 +1,43 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-11-09 14:02+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: core/templates/landing/_menu.html:17 core/templates/landing/home.html:25 +msgid "menu.researcher" +msgstr "Voor onderzoekers" + +#: core/templates/landing/_menu.html:18 core/templates/landing/home.html:26 +msgid "menu.teacher" +msgstr "Voor leraren" + +#: core/templates/landing/_menu.html:19 core/templates/landing/home.html:27 +msgid "menu.student" +msgstr "Voor studenten" + +#: core/templates/landing/home.html:24 +msgid "menuP" +msgstr "PPnl" + +#: timealign/settings.py:119 +msgid "Dutch" +msgstr "Nederlands" + +#: timealign/settings.py:120 +msgid "English" +msgstr "Engels" diff --git a/timealign/settings.py b/timealign/settings.py index 6d57816..f9d3e20 100644 --- a/timealign/settings.py +++ b/timealign/settings.py @@ -10,6 +10,10 @@ https://docs.djangoproject.com/en/1.11/ref/settings/ """ import os +from pathlib import Path + +from django.utils.translation import gettext_lazy as _ + from .settings_secret import * # Build paths inside the project like this: os.path.join(BASE_DIR, ...) @@ -132,12 +136,22 @@ # Internationalization # https://docs.djangoproject.com/en/1.11/topics/i18n/ -LANGUAGE_CODE = 'en-us' TIME_ZONE = 'Europe/Amsterdam' USE_I18N = True USE_L10N = True USE_TZ = True +LANGUAGE_CODE = 'en' + +LOCALE_PATHS = [ + os.path.join(Path(__file__).resolve().parent, "locale"), +] + +LANGUAGES = [ + ('nl', _('Dutch')), + ('en', _('English')), +] + # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.11/howto/static-files/ diff --git a/timealign/urls.py b/timealign/urls.py index 1b1a244..94666a8 100644 --- a/timealign/urls.py +++ b/timealign/urls.py @@ -21,6 +21,7 @@ from django.urls import include, path, re_path urlpatterns = [ + path('i18n/', include('django.conf.urls.i18n')), path('accounts/login/', LoginView.as_view(), name='login'), path('accounts/logout/', LogoutView.as_view(), name='logout'), path('accounts/password/change/', PasswordChangeView.as_view(), name='password_change'), @@ -28,6 +29,7 @@ path('captcha/', include('captcha.urls')), + re_path(r'^landing/', include(('core.urls', 'core'), namespace='core')), re_path(r'^timealign/', include(('annotations.urls', 'annotations'), namespace='annotations')), re_path(r'^preselect/', include(('selections.urls', 'selections'), namespace='selections')), re_path(r'^stats/', include(('stats.urls', 'stats'), namespace='stats')),