diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..787f06e
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,21 @@
+# TODO
+
+## Localisation
+
+- [ ] It would be nice to centralize the translations to some well-chosen singular directory
+- [ ] Integrate it with some public translation project?
+
+## DevOps Functionality
+- [ ] I need to dockerize it
+- [ ] It should be easily buildable and publishable using some kind of CI/CD
+
+## Application Functionality
+
+- [ ] I should be able to connect one (or many) subjects to a user, so they can start generating as the one
+ - This is meant so that the user is being the "connected subject"
+- [ ] I need to be able to create the invoices as the connected subject to any subject in current database
+ - Automatically creating non-existing subjects might be nice to have
+- [ ] I should be able to keep the invoices even if the subject is deleted (or changed) with the data in the day of the
+ creation
+- [ ] Generating QR Payments is nice to have
+- [ ] It would be great to automatically check `ares` for data changes from time to time
diff --git a/accounts/forms.py b/accounts/forms.py
index 0e3f646..f88b119 100644
--- a/accounts/forms.py
+++ b/accounts/forms.py
@@ -1,5 +1,6 @@
from crispy_forms import helper, layout
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
+from django.utils.translation import gettext_lazy as _
from .models import User
@@ -13,7 +14,7 @@ class LoginForm(AuthenticationForm):
self.helper = helper.FormHelper()
self.helper.form_action = "accounts:login"
self.helper.form_method = "post"
- self.helper.add_input(layout.Submit('submit', 'Login'))
+ self.helper.add_input(layout.Submit('submit', _('Login')))
class RegisterForm(UserCreationForm):
@@ -26,4 +27,4 @@ class RegisterForm(UserCreationForm):
self.helper = helper.FormHelper()
self.helper.form_action = "accounts:register"
self.helper.form_method = "post"
- self.helper.add_input(layout.Submit('submit', 'Register'))
+ self.helper.add_input(layout.Submit('submit', _('Register')))
diff --git a/accounts/templates/account/login.html b/accounts/templates/account/login.html
index d5c791a..da1b13a 100644
--- a/accounts/templates/account/login.html
+++ b/accounts/templates/account/login.html
@@ -1,8 +1,9 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
{% load crispy_forms_tags %}
-{% block title %}Login{% endblock %}
+{% block title %}{% trans "Login" %}{% endblock %}
{% block content %}
{% crispy form form.helper %}
diff --git a/accounts/templates/account/me.html b/accounts/templates/account/me.html
index 37caf86..75218d1 100644
--- a/accounts/templates/account/me.html
+++ b/accounts/templates/account/me.html
@@ -1,14 +1,22 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
-{% block title %}About Me{% endblock %}
+{% block title %}{% trans "About Me" %}{% endblock %}
{% block content %}
-
About Me
+ {% trans "About Me" %}
-
+
- Username: {{ request.user.username }}
- Email: {{ request.user.email }}
+
+ {% blocktrans with username=request.user.username %}Username: {{ username }}{% endblocktrans %}
+
+
+ {% blocktrans with email=request.user.email %}Email: {{ email }}{% endblocktrans %}
+
{% endblock %}
diff --git a/accounts/templates/account/register.html b/accounts/templates/account/register.html
index 932cd08..91f1985 100644
--- a/accounts/templates/account/register.html
+++ b/accounts/templates/account/register.html
@@ -1,10 +1,10 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
{% load crispy_forms_tags %}
-{% block title %}Register{% endblock %}
+{% block title %}{% trans "Register" %}{% endblock %}
{% block content %}
- {# TODO: neukazovat všechny pičoviny hned najedou#}
{% crispy form form.helper %}
{% endblock %}
\ No newline at end of file
diff --git a/accounts/views.py b/accounts/views.py
index 5150483..a0c1d3e 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -55,4 +55,5 @@ def auth_register(req: HttpRequest) -> HttpResponse:
@login_required
def me(req: HttpRequest) -> HttpResponse:
+ print(req.user.username)
return render(req, "account/me.html")
diff --git a/facturio/settings.py b/facturio/settings.py
index b92181f..e141c67 100644
--- a/facturio/settings.py
+++ b/facturio/settings.py
@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/5.0/ref/settings/
"""
from pathlib import Path
+from django.utils.translation import gettext_lazy as _
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
@@ -44,6 +45,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
+ "django.middleware.locale.LocaleMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
@@ -102,7 +104,15 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/5.0/topics/i18n/
-LANGUAGE_CODE = "en-us"
+LANGUAGE_CODE = "cs"
+LANGUAGES = [
+ ("en", _("English")),
+ ("cs", _("Czech"))
+]
+
+LOCALE_PATHS = [
+ BASE_DIR / "locale"
+]
TIME_ZONE = "UTC"
diff --git a/facturio/urls.py b/facturio/urls.py
index a932a8d..6793c21 100644
--- a/facturio/urls.py
+++ b/facturio/urls.py
@@ -1,32 +1,18 @@
-"""
-URL configuration for facturio project.
-
-The `urlpatterns` list routes URLs to views. For more information please see:
- https://docs.djangoproject.com/en/5.0/topics/http/urls/
-Examples:
-Function views
- 1. Add an import: from my_app import views
- 2. Add a URL to urlpatterns: path('', views.home, name='home')
-Class-based views
- 1. Add an import: from other_app.views import Home
- 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
-Including another URLconf
- 1. Import the include() function: from django.urls import include, path
- 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
-"""
from django.contrib import admin
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.urls import path, include
+from django.conf.urls.i18n import i18n_patterns
def landing_page(req: HttpRequest) -> HttpResponse:
return render(req, "facturio/index.html")
-urlpatterns = [
+urlpatterns = i18n_patterns(
path("", landing_page, name="main-page"),
path("accounts/", include("accounts.urls")),
path("subjects/", include("subjects.urls")),
path("admin/", admin.site.urls),
-]
+ prefix_default_language=False
+)
diff --git a/locale/cs/LC_MESSAGES/django.po b/locale/cs/LC_MESSAGES/django.po
new file mode 100644
index 0000000..dae3bcb
--- /dev/null
+++ b/locale/cs/LC_MESSAGES/django.po
@@ -0,0 +1,142 @@
+# 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: 2024-01-29 20:46+0000\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=4; plural=(n == 1 && n % 1 == 0) ? 0 : (n >= 2 && n "
+"<= 4 && n % 1 == 0) ? 1: (n % 1 != 0 ) ? 2 : 3;\n"
+#: accounts/forms.py:17 accounts/templates/account/login.html:6
+#: templates/facturio/base.html:39
+msgid "Login"
+msgstr "Přihlásit se"
+
+#: accounts/forms.py:30 accounts/templates/account/register.html:6
+#: templates/facturio/base.html:42
+msgid "Register"
+msgstr "Registrovat se"
+
+#: accounts/models.py:9
+msgid "first name"
+msgstr "křestní jméno"
+
+#: accounts/models.py:10
+msgid "last name"
+msgstr "přijmení"
+
+#: accounts/models.py:11
+msgid "email address"
+msgstr "emailová adresa"
+
+#: accounts/templates/account/me.html:4 accounts/templates/account/me.html:7
+msgid "About Me"
+msgstr "O mně"
+
+#: accounts/templates/account/me.html:10
+#, python-format
+msgid "Welcome, %(firstname)s %(lastname)s!"
+msgstr "Vítej, %(firstname)s %(lastname)s!"
+
+#: accounts/templates/account/me.html:15
+#, python-format
+msgid "Username: %(username)s"
+msgstr "Uživatelské jméno: %(username)s"
+
+#: accounts/templates/account/me.html:18
+#, python-format
+msgid "Email: %(email)s"
+msgstr "Email: %(email)s"
+
+#: facturio/settings.py:109
+msgid "English"
+msgstr "Angličtina"
+
+#: facturio/settings.py:110
+msgid "Czech"
+msgstr "Čeština"
+
+#: subjects/forms.py:14
+msgid "Your provided CIN is not correct."
+msgstr "Vaše poskytnuté IČO není správné."
+
+#: subjects/forms.py:15
+msgid "Subject with provided CIN already exists."
+msgstr "Subjekt s poskytnutým IČO již existuje."
+
+#: subjects/forms.py:18 subjects/models.py:12
+#: subjects/templates/subjects/index.html:11
+msgid "CIN"
+msgstr "IČO"
+
+#: subjects/forms.py:20
+msgid "Enter the subject CIN, rest will be generated automatically"
+msgstr "Zadejte IČO subjektu, zbytek bude generován automaticky"
+
+#: subjects/forms.py:28
+msgid "Add"
+msgstr "Vytvořit"
+
+#: subjects/models.py:8
+msgid "Subject"
+msgstr "Subjekt"
+
+#: subjects/models.py:9 subjects/templates/subjects/index.html:4
+#: templates/facturio/base.html:19
+msgid "Subjects"
+msgstr "Subjekty"
+
+#: subjects/models.py:18 subjects/templates/subjects/index.html:12
+msgid "Name"
+msgstr "Jméno"
+
+#: subjects/models.py:23 subjects/templates/subjects/index.html:13
+msgid "VAT ID"
+msgstr "IČO"
+
+#: subjects/models.py:30 subjects/templates/subjects/index.html:14
+msgid "Street"
+msgstr "Ulice"
+
+#: subjects/models.py:35 subjects/templates/subjects/index.html:15
+msgid "Zip Code"
+msgstr "PSČ"
+
+#: subjects/models.py:40 subjects/templates/subjects/index.html:16
+msgid "City"
+msgstr "Město"
+
+#: subjects/models.py:45 subjects/templates/subjects/index.html:17
+msgid "City part"
+msgstr "Část města"
+
+#: subjects/templates/subjects/create.html:6
+msgid "Create Subjects"
+msgstr "Vytvořit Subjekty"
+
+#: subjects/templates/subjects/index.html:7
+msgid "Add new"
+msgstr "Přidat nový"
+
+#: templates/facturio/base.html:8 templates/facturio/index.html:4
+msgid "App"
+msgstr "Aplikace"
+
+#: templates/facturio/base.html:31
+msgid "Profile"
+msgstr "Profil"
+
+#: templates/facturio/base.html:34
+msgid "Logout"
+msgstr "Odhlásit se"
diff --git a/subjects/forms.py b/subjects/forms.py
index 516487a..324f497 100644
--- a/subjects/forms.py
+++ b/subjects/forms.py
@@ -25,7 +25,7 @@ class CreateSubjectForm(forms.Form):
self.helper = helper.FormHelper()
self.helper.form_action = "subjects:create"
self.helper.form_method = "post"
- self.helper.add_input(layout.Submit('submit', 'Add'))
+ self.helper.add_input(layout.Submit('submit', _('Add')))
def clean_cin(self):
cin = self.cleaned_data.get("cin")
diff --git a/subjects/models.py b/subjects/models.py
index 78ad294..e9ea42b 100644
--- a/subjects/models.py
+++ b/subjects/models.py
@@ -4,6 +4,10 @@ from django.utils.translation import gettext_lazy as _
class Subject(models.Model):
+ class Meta:
+ verbose_name = _("Subject")
+ verbose_name_plural = _("Subjects")
+
id = models.CharField(
_("CIN"),
max_length=8,
diff --git a/subjects/templates/subjects/create.html b/subjects/templates/subjects/create.html
index cd4f345..c2985bc 100644
--- a/subjects/templates/subjects/create.html
+++ b/subjects/templates/subjects/create.html
@@ -1,8 +1,9 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
{% load crispy_forms_tags %}
-{% block title %}Create Subjects{% endblock %}
+{% block title %}{% trans "Create Subjects" %}{% endblock %}
{% block content %}
{% crispy form form.helper %}
diff --git a/subjects/templates/subjects/index.html b/subjects/templates/subjects/index.html
index 62d8d90..eac8df0 100644
--- a/subjects/templates/subjects/index.html
+++ b/subjects/templates/subjects/index.html
@@ -1,19 +1,20 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
-{% block title %}Subjects{% endblock %}
+{% block title %}{% trans "Subjects" %}{% endblock %}
{% block content %}
- Add new
+ {% trans "Add new" %}
- CIN
- Name
- VAT ID
- Street
- Zip Code
- City
- City part
+ {% trans "CIN" %}
+ {% trans "Name" %}
+ {% trans "VAT ID" %}
+ {% trans "Street" %}
+ {% trans "Zip Code" %}
+ {% trans "City" %}
+ {% trans "City part" %}
diff --git a/templates/facturio/base.html b/templates/facturio/base.html
index 9296e0b..71039a1 100644
--- a/templates/facturio/base.html
+++ b/templates/facturio/base.html
@@ -1,9 +1,11 @@
+{% load i18n %}
- Facturio - {% block title %}App{% endblock %}
+ {# FIXME: this is not translating correctly!! #}
+ Facturio - {% block title %}{% trans "App" %}{% endblock %}
@@ -14,7 +16,7 @@
- Subjects
+ {% trans "Subjects" %}
{##}
{# Item 2 #}
@@ -26,17 +28,18 @@
diff --git a/templates/facturio/index.html b/templates/facturio/index.html
index 3ac6cc8..00f1f9d 100644
--- a/templates/facturio/index.html
+++ b/templates/facturio/index.html
@@ -1,2 +1,4 @@
{% extends "facturio/base.html" %}
+{% load i18n %}
+{% block title %}{% trans "App" %}{% endblock %}
\ No newline at end of file