Skip to content

Commit

Permalink
Adding internationalization
Browse files Browse the repository at this point in the history
  • Loading branch information
AndersSeverinsen committed Jun 27, 2024
1 parent 0a59946 commit 46a4a73
Show file tree
Hide file tree
Showing 12 changed files with 545 additions and 50 deletions.
21 changes: 11 additions & 10 deletions bartenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from django.urls import reverse
from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _

from fredagscafeen.email import send_template_email

Expand Down Expand Up @@ -47,28 +48,28 @@ class BartenderCommon(models.Model):
class Meta:
abstract = True

name = models.CharField(max_length=140, verbose_name="Fulde navn")
username = models.CharField(max_length=140, unique=True, verbose_name="Brugernavn")
name = models.CharField(max_length=140, verbose_name=_("Fulde navn"))
username = models.CharField(max_length=140, unique=True, verbose_name=_("Brugernavn"))
email = models.CharField(max_length=255, unique=True, blank=True)
studentNumber = models.IntegerField(
blank=True, null=True, verbose_name="Studienummer"
blank=True, null=True, verbose_name=_("Studienummer")
)
phoneNumber = models.IntegerField(
blank=True, null=True, verbose_name="Telefonnummer"
blank=True, null=True, verbose_name=_("Telefonnummer")
)
tshirt_size = models.CharField(
choices=TSHIRT_SIZE_CHOICES,
max_length=10,
blank=True,
null=True,
verbose_name="T-shirt størrelse",
verbose_name=_("T-shirt størrelse"),
)


class Bartender(BartenderCommon):
isActiveBartender = models.BooleanField(default=True)
prefer_only_early_shifts = models.BooleanField(
default=False, verbose_name="Jeg foretrækker ikke at have nogle sene barvagter"
default=False, verbose_name=_("Jeg foretrækker ikke at have nogle sene barvagter")
)

@property
Expand Down Expand Up @@ -224,14 +225,14 @@ def get_current_period(cls):

def __str__(self):
start_year = self.start_date.year
return f"{start_year} / {start_year + 1} ({self.start_date} til {self.end_date_display})"
return f"{start_year} / {start_year + 1} ({self.start_date} {_("til")} {self.end_date_display})"


class BartenderApplication(BartenderCommon):
study = models.CharField(max_length=50, verbose_name="Studie")
study_year = models.IntegerField(verbose_name="Årgang")
study = models.CharField(max_length=50, verbose_name=_("Studie"))
study_year = models.IntegerField(verbose_name=_("Årgang"))
info = models.TextField(
blank=True, help_text="Eventuelle ekstra info til bestyrelsen skrives her"
blank=True, help_text=_("Eventuelle ekstra info til bestyrelsen skrives her")
)

created = models.DateTimeField(auto_now_add=True)
Expand Down
18 changes: 9 additions & 9 deletions bartenders/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{% extends 'base.html' %}

{% load i18n %}
{% load static %}
{% load bootstrap3 %}

{% block content %}

Velkommen til Fredagscaféens webside, her kan du finde information om åbningstider, sortiment, udlejning af fadølsanlæg og grill mm.
{% translate "Velkommen til Fredagscaféens webside, her kan du finde information om åbningstider, sortiment, udlejning af fadølsanlæg og grill mm." %}

<div class="row">
<div class="col-md-8">
<h2>Bartendertilmelding</h2>
<p>Er du interesseret i at være med i et fedt fællesskab hvor vi hygger bag baren og serverer nogle kolde drikkevarer?</p>
<p>Du vil som bartender få ca. 2 vagter pr. semester, hvor du er med til at sikre at alle får slukket tørsten.<p>
<p>Udover dette inviteres du til vores årlige arrangementer for bartendere, såsom Sommerfesten og Julefrokosten. Derudover vil der løbende være fede begivenheder, såsom ølsmagning og lign. Alt sammen gratis for bartendere.</p>
<p>Det er en god idé at læse <a href="{{ barshift_guide_url }}" alt="guide">barvagt-guiden</a> før du tilmelder dig, så du
ved hvad en typisk vagt i Fredagscaféen indebærer.</p>
<h2>{% translate "Bartendertilmelding" %}</h2>
<p>{% translate "Er du interesseret i at være med i et fedt fællesskab hvor vi hygger bag baren og serverer nogle kolde drikkevarer?" %}</p>
<p>{% translate "Du vil som bartender få ca. 2 vagter pr. semester, hvor du er med til at sikre at alle får slukket tørsten." %}<p>
<p>{% translate "Udover dette inviteres du til vores årlige arrangementer for bartendere, såsom Sommerfesten og Julefrokosten. Derudover vil der løbende være fede begivenheder, såsom ølsmagning og lign. Alt sammen gratis for bartendere." %}</p>
<p>{% translate "Det er en god idé at læse" %} <a href="{{ barshift_guide_url }}" alt="guide">{% translate "barvagt-guiden" %}</a>
{% translate "før du tilmelder dig, så du ved hvad en typisk vagt i Fredagscaféen indebærer." %}</p>
{% if config.REGISTRATION_OPEN %}
<form method="post" action="/">
{% csrf_token %}
Expand All @@ -24,7 +24,7 @@ <h2>Bartendertilmelding</h2>
{% endbuttons %}
</form>
{% else %}
<b>Bartendertilmeldingen er lukket.</b>
<b>{% translate "Bartendertilmeldingen er lukket." %}</b>
{% endif %}
</div>
</div>
Expand Down
23 changes: 23 additions & 0 deletions fredagscafeen/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,14 @@
"guides",
"events",
"printer",
"rosetta",
)

MIDDLEWARE = (
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
'django.middleware.locale.LocaleMiddleware', # Used for internationalization. Has to be after sessions but before common
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
Expand Down Expand Up @@ -254,6 +256,27 @@

USE_TZ = True

from django.utils.translation import gettext_lazy as _

LANGUAGES = (
('da', _('Danish')),
('en', _('English')),
)

PARLER_LANGUAGES = {
None : (
{'code': 'da',},
{'code': 'en',},
),
'default': {
'fallbacks': ['da'],
'hide_untranslated': False,
}
}

LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale/'),
)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
Expand Down
6 changes: 4 additions & 2 deletions fredagscafeen/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from django.conf.urls.i18n import i18n_patterns

urlpatterns = [
urlpatterns = i18n_patterns (
path("favicon.ico", RedirectView.as_view(url="/static/favicon.ico")),
path("admin/", admin.site.urls),
path("api/", include("api.urls")),
path("", include("web.urls")),
]
path("rosetta/", include("rosetta.urls")),
)

if settings.DEBUG:
# Handle user-uploaded content during development
Expand Down
Binary file added locale/da/LC_MESSAGES/django.mo
Binary file not shown.
203 changes: 203 additions & 0 deletions locale/da/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# 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 <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-06-27 13:48+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"

#: bartenders/migrations/0001_initial.py:29
#: bartenders/migrations/0001_initial.py:92
msgid "Fulde navn"
msgstr ""

#: bartenders/migrations/0001_initial.py:33
#: bartenders/migrations/0001_initial.py:96
msgid "Brugernavn"
msgstr ""

#: bartenders/migrations/0001_initial.py:40
#: bartenders/migrations/0001_initial.py:103
msgid "Studienummer"
msgstr ""

#: bartenders/migrations/0001_initial.py:46
#: bartenders/migrations/0001_initial.py:109
msgid "Telefonnummer"
msgstr ""

#: bartenders/migrations/0001_initial.py:64
#: bartenders/migrations/0001_initial.py:127
msgid "T-shirt størrelse"
msgstr ""

#: bartenders/migrations/0001_initial.py:72
msgid "Jeg foretrækker ikke at have nogle sene barvagter"
msgstr ""

#: bartenders/migrations/0001_initial.py:130
msgid "Studie"
msgstr ""

#: bartenders/migrations/0001_initial.py:131
msgid "Årgang"
msgstr ""

#: bartenders/migrations/0001_initial.py:136
msgid "Eventuelle ekstra info til bestyrelsen skrives her"
msgstr ""

#: bartenders/templates/index.html:8
msgid ""
"Velkommen til Fredagscaféens webside, her kan du finde information om "
"åbningstider, sortiment, udlejning af fadølsanlæg og grill mm."
msgstr ""

#: bartenders/templates/index.html:12
msgid "Bartendertilmelding"
msgstr ""

#: bartenders/templates/index.html:13
msgid ""
"Er du interesseret i at være med i et fedt fællesskab hvor vi hygger bag "
"baren og serverer nogle kolde drikkevarer?"
msgstr ""

#: bartenders/templates/index.html:14
msgid ""
"Du vil som bartender få ca. 2 vagter pr. semester, hvor du er med til at "
"sikre at alle får slukket tørsten."
msgstr ""

#: bartenders/templates/index.html:15
msgid ""
"Udover dette inviteres du til vores årlige arrangementer for bartendere, "
"såsom Sommerfesten og Julefrokosten. Derudover vil der løbende være fede "
"begivenheder, såsom ølsmagning og lign. Alt sammen gratis for bartendere."
msgstr ""

#: bartenders/templates/index.html:16
msgid "Det er en god idé at læse"
msgstr ""

#: bartenders/templates/index.html:16
msgid "barvagt-guiden"
msgstr ""

#: bartenders/templates/index.html:17
msgid ""
"før du tilmelder dig, så du ved hvad en typisk vagt i Fredagscaféen "
"indebærer."
msgstr ""

#: bartenders/templates/index.html:27
msgid "Bartendertilmeldingen er lukket."
msgstr ""

#: fredagscafeen/admin_filters.py:30
msgid "All"
msgstr "Alle"

#: fredagscafeen/admin_filters.py:30
msgid "Yes"
msgstr "Ja"

#: fredagscafeen/admin_filters.py:30
msgid "No"
msgstr "Nej"

#: fredagscafeen/settings/base.py:262
msgid "Danish"
msgstr "Dansk"

#: fredagscafeen/settings/base.py:263
msgid "English"
msgstr "Engelsk"

#: web/templates/base.html:59
msgid "Forside"
msgstr ""

#: web/templates/base.html:60
msgid "Barplan"
msgstr ""

#: web/templates/base.html:61
msgid "Bartendere"
msgstr ""

#: web/templates/base.html:65
msgid "Udlejning"
msgstr ""

#: web/templates/base.html:67
msgid "Udlejning af fadølsanlæg"
msgstr ""

#: web/templates/base.html:68
msgid "Udlejning af grill"
msgstr ""

#: web/templates/base.html:69
msgid "Udlejning af projektor"
msgstr ""

#: web/templates/base.html:69
msgid "lærred"
msgstr ""

#: web/templates/base.html:70
msgid "Udlejning af højtalere"
msgstr ""

#: web/templates/base.html:74
msgid "Guides"
msgstr ""

#: web/templates/base.html:76
msgid "Bestyrelsen"
msgstr ""

#: web/templates/base.html:77
msgid "Events"
msgstr ""

#: web/templates/base.html:78
msgid "Om baren"
msgstr ""

#: web/templates/base.html:80
msgid "Profil"
msgstr ""

#: web/templates/base.html:82
msgid "Krydlistestatus"
msgstr ""

#: web/templates/base.html:83
msgid "Bartenderprofil"
msgstr ""

#: web/templates/base.html:86
msgid "Admin"
msgstr ""

#: web/templates/base.html:91
msgid "Log ud"
msgstr ""

#: web/templates/base.html:109
msgid "er en fredagsbar for datalogi og IT på Aarhus Universitet."
msgstr ""
Binary file added locale/en/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit 46a4a73

Please sign in to comment.