diff --git a/Dockerfile b/Dockerfile index 7eb7bbe..6d42235 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM alpine:3.8 +FROM alpine:3.10 MAINTAINER Claudio Maggioni (praticamentetilde) @@ -41,6 +41,7 @@ COPY . /home/app/code/ RUN chown -R app: /home/app RUN sh -c "cd /home/app/code && python3 ./manage.py collectstatic --no-input" +RUN sh -c "cd /home/app/code && python3 ./manage.py compilemessages" EXPOSE 8000 CMD ["/usr/sbin/uwsgi", "--ini", "/home/app/code/uwsgi.ini", "--plugin", "python3"] diff --git a/arrowcounter/settings.py b/arrowcounter/settings.py index c134c24..53ee282 100644 --- a/arrowcounter/settings.py +++ b/arrowcounter/settings.py @@ -29,7 +29,7 @@ ALLOWED_HOSTS = os.environ["ALLOWED_HOSTS"].split() AUTH_USER_MODEL = 'user.CounterUser' -LOGIN_URL = "auth/login/" +LOGIN_URL = "/accounts/login" LOGIN_REDIRECT_URL = "/" @@ -123,7 +123,13 @@ AUTH_PASSWORD_VALIDATORS = [ # Internationalization # https://docs.djangoproject.com/en/2.1/topics/i18n/ -LANGUAGE_CODE = 'it' +SITE_ROOT = os.path.dirname(os.path.realpath(__name__)) +LOCALE_PATHS = ( os.path.join(SITE_ROOT, 'locale'), ) + +LANGUAGES = ( + ('it', 'Italiano'), + ('en', 'English') +) TIME_ZONE = 'Europe/Rome' diff --git a/counter/models.py b/counter/models.py index 237d44f..cf55144 100644 --- a/counter/models.py +++ b/counter/models.py @@ -1,9 +1,10 @@ from django.db import models from django.conf import settings from django.contrib.auth.models import User +from django.utils.translation import gettext_lazy as _ class Target(models.Model): - target = models.PositiveIntegerField('Target to reach') + target = models.PositiveIntegerField(_('Target to reach')) user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE, @@ -15,8 +16,8 @@ class ArrowCount(models.Model): settings.AUTH_USER_MODEL, on_delete=models.CASCADE ) - date = models.DateField('Training date') - count = models.PositiveIntegerField('Arrow count for the day') + date = models.DateField(_('Training date')) + count = models.PositiveIntegerField(_('Arrow count for the day')) def __str__(self): return self.date.strftime("%x") + ": " + str(self.count) diff --git a/counter/templates/403.html b/counter/templates/403.html index edd620c..c57e36c 100644 --- a/counter/templates/403.html +++ b/counter/templates/403.html @@ -1,8 +1,15 @@ {% extends "base.html" %} -{% block title %}Not authorized{% endblock %} +{% load i18n %} + +{% block title %}{% trans "Not authorized" %}{% endblock %} {% block content %} -

Not authorized

-

You are not authorized to perform this action. Please return to the home.

+

{% trans "Not authorized" %}

+

+{% url "index" as link %} +{% blocktrans with link=link %} +You are not authorized to perform this action. Please return to the home. +{% endblocktrans %} +

{% endblock %} diff --git a/counter/templates/404.html b/counter/templates/404.html index 635af94..c469d38 100644 --- a/counter/templates/404.html +++ b/counter/templates/404.html @@ -1,8 +1,15 @@ {% extends "base.html" %} -{% block title %}Page not found{% endblock %} +{% load i18n %} + +{% block title %}{% trans "Page not found" %}{% endblock %} {% block content %} -

Page not found

-

This page has not been found. Please return to the home.

+

{% trans "Page not found" %}

+

+{% url "index" as link %} +{% blocktrans with link=link %} +This page has not been found. Please return to the home. +{% endblocktrans %} +

{% endblock %} diff --git a/counter/templates/500.html b/counter/templates/500.html index 78eca7d..c82e0c8 100644 --- a/counter/templates/500.html +++ b/counter/templates/500.html @@ -1,8 +1,14 @@ {% extends "base.html" %} -{% block title %}Internal server error{% endblock %} +{% load i18n %} + +{% block title %}{% trans "Internal server error" %}{% endblock %} {% block content %} -

Internal server error

-

The server failed to process the request. Please return to the home.

+

{% trans "Internal server error" %}

+{% url "index" as link %} +{% blocktrans with link=link %} +The server failed to process the request. Please return to the home. +{% endblocktrans %} +

{% endblock %} diff --git a/counter/templates/base.html b/counter/templates/base.html index 3401917..67fd3c1 100644 --- a/counter/templates/base.html +++ b/counter/templates/base.html @@ -1,60 +1,61 @@ +{# vim: set ts=2 sw=2 et tw=80: #} {% load static %} {% load i18n %} - + - - {% block title %}{% endblock %} | Arrow Counter - - - - - - {% block style %}{% endblock %} - + + {% block title %}{% endblock %} | {% trans "Arrow counter" %} + + + + + + {% block style %}{% endblock %} + - - - -
-
{% block content %}{% endblock %}
-
- - - + - - - - {% block scripts %}{% endblock %} - + {% endwith %} + }); + + + + + {% block scripts %}{% endblock %} + diff --git a/counter/templates/counter/edit.html b/counter/templates/counter/edit.html index c056240..1c1fe1f 100644 --- a/counter/templates/counter/edit.html +++ b/counter/templates/counter/edit.html @@ -1,17 +1,19 @@ +{# vim: set ts=2 sw=2 et tw=80: #} {% extends "base.html" %} {% load static %} +{% load i18n %} -{% block title %}Update count{% endblock %} +{% block title %}{% trans "Update count" %}{% endblock %} {% block scripts %} {% endblock %} {% block content %} -

Update count

+

{% trans "Update count" %}

+ data-update-ajax="{% url "count_edit_ajax" ac_id %}">
{% csrf_token %} @@ -19,7 +21,7 @@ {{ form.as_p }}
- @@ -32,7 +34,7 @@
- +
diff --git a/counter/templates/counter/list.html b/counter/templates/counter/list.html index 587552c..3debce8 100644 --- a/counter/templates/counter/list.html +++ b/counter/templates/counter/list.html @@ -1,21 +1,26 @@ +{# vim: set ts=2 sw=2 et tw=80: #} {% extends "base.html" %} -{% block title %}Counts{% endblock %} +{% load i18n %} + +{% block title %}{% trans "Counts" %}{% endblock %} {% block content %} -

Counts

+

{% trans "Counts" %}

- - Excel Data (CSV) file_download - + + {% trans "Excel Data (CSV)" %} + file_download +

{% include 'pagination.html' %} - - - + + + @@ -28,7 +33,8 @@ class="btn waves-effect waves-light"> edit - + {% csrf_token %} - + {% endfor %} diff --git a/counter/templates/counter/new.html b/counter/templates/counter/new.html index cd60c0a..9740d21 100644 --- a/counter/templates/counter/new.html +++ b/counter/templates/counter/new.html @@ -1,9 +1,12 @@ +{# vim: set ts=2 sw=2 et tw=80: #} {% extends "base.html" %} -{% block title %}New count{% endblock %} +{% load i18n %} + +{% block title %}{% trans "New count" %}{% endblock %} {% block content %} -

New count

+

{% trans "New count" %}

@@ -11,7 +14,7 @@ {{ form.as_p }}
- +
diff --git a/counter/templates/index.html b/counter/templates/index.html index f762460..1bc7906 100644 --- a/counter/templates/index.html +++ b/counter/templates/index.html @@ -1,34 +1,36 @@ -{% extends 'base.html' %} {# vim: set ts=2 sw=2 et tw=80: #} +{% extends 'base.html' %} -{% block title %}Home{% endblock %} +{% load i18n %} + +{% block title %}{% trans "Home" %}{% endblock %} {% block content %} -

Arrow counter

-
A simple online arrow counter
+

{% trans "Arrow counter" %}

+
{% trans "A simple online arrow counter" %}
{% if user.is_authenticated %}

- - Excel Data (CSV) file_download - + + {% trans "Excel Data (CSV)" %} file_download +

-
Arrows shot this year:
-

{{ yearArrows }}

+
{% trans "Arrows shot this year:" %}
+

{{ yearArrows }}

{% if diffTarget is not False %}
-
Difference with target:
-

{{ diffTarget }}

+
{% trans "Difference with target:" %}
+

{{ diffTarget }}

{% endif %}
-
Arrows shot this month:
-

{{ monthArrows }}

+
{% trans "Arrows shot this month:" %}
+

{{ monthArrows }}

-
Arrows shot this week:
-

{{ weekArrows }}

+
{% trans "Arrows shot this week:" %}
+

{{ weekArrows }}

{% endif %} {% endblock %} diff --git a/counter/templates/menu.html b/counter/templates/menu.html index 5e0ef8c..d2d9b33 100644 --- a/counter/templates/menu.html +++ b/counter/templates/menu.html @@ -1,3 +1,6 @@ +{# vim: set ft=htmldjango ts=2 sw=2 et tw=80: #} +{% load i18n %} + {% if mobile and user.is_authenticated %}
@@ -10,18 +13,18 @@
{% endif %} -
  • Home
  • +
  • {% trans "Home" %}
  • {% if user.is_authenticated %} -
  • Counts
  • -
  • Set yearly target
  • -
  • Weekly stats
  • +
  • {% trans "Counts" %}
  • +
  • {% trans "Set yearly target" %}
  • +
  • {% trans "Weekly stats" %}
  • {% if user.is_superuser %} -
  • Admin
  • +
  • {% trans "Admin" %}
  • {% endif %} -
  • Logout
  • +
  • {% trans "Logout" %}
  • {% else %} -
  • Login
  • -
  • Register
  • +
  • {% trans "Login" %}
  • +
  • {% trans "Register" %}
  • {% endif %} diff --git a/counter/templates/stats.html b/counter/templates/stats.html index e1d4218..93e2a26 100644 --- a/counter/templates/stats.html +++ b/counter/templates/stats.html @@ -1,7 +1,10 @@ +{# vim: set ts=2 sw=2 et tw=80: #} {% extends 'base.html' %} + +{% load i18n %} {% load static %} -{% block title %}Weekly stats{% endblock %} +{% block title %}{% trans "Weekly stats" %}{% endblock %} {% block scripts %}
    DateArrow countEdit{% trans "Date" %}{% trans "Arrow count" %}{% trans "Edit" %}
    No counts saved{% trans "No counts saved" %}