Skip to content

Commit

Permalink
chore: translate 404 errors to dutch #57
Browse files Browse the repository at this point in the history
  • Loading branch information
bsilkyn committed Mar 7, 2024
1 parent 7c6fa12 commit 22b7e32
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
14 changes: 14 additions & 0 deletions backend/ypovoli/handlers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rest_framework.views import exception_handler
from django.utils.translation import gettext_lazy as _


def translate_exception_handler(exc, context):
response = exception_handler(exc, context)

if response.status_code == 401:
response.data['detail'] = _('Given token not valid for any token type')

if response.status_code == 404:
response.data['detail'] = _('Not found.')

return response
35 changes: 35 additions & 0 deletions backend/ypovoli/locale/nl/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# 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-03-07 14:34+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\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"

#: ypovoli/handlers.py:9
msgid "Given token not valid for any token type"
msgstr "Gegeven token is niet geldig voor eender welk token type"

#: ypovoli/handlers.py:12
msgid "Not found."
msgstr "Niet gevonden."

#: ypovoli/settings.py:113
msgid "English"
msgstr "Engels"

#: ypovoli/settings.py:113
msgid "Dutch"
msgstr "Nederlands"
5 changes: 4 additions & 1 deletion backend/ypovoli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

from django.utils.translation import gettext_lazy as _
from datetime import timedelta
from pathlib import Path

Expand Down Expand Up @@ -69,7 +70,8 @@
],
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated'
]
],
'EXCEPTION_HANDLERE': 'ypovoli'
}

SIMPLE_JWT = {
Expand Down Expand Up @@ -108,6 +110,7 @@
LANGUAGE_CODE = "en-us"
TIME_ZONE = "UTC"
USE_I18N = True
LANGUAGES = [('en', _('English')), ('nl', _('Dutch'))]
USE_L10N = False
USE_TZ = True

Expand Down

0 comments on commit 22b7e32

Please sign in to comment.