Skip to content

Commit

Permalink
Merge pull request #54 from SADiLaR/feature/internationalisation_sett…
Browse files Browse the repository at this point in the history
…ings

Add initial settings for internationalisation
  • Loading branch information
OnaMosimege authored May 22, 2024
2 parents 82365dc + 5de494a commit 0070b00
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Thumbs.db

# Django template
*.pot
*.mo
*.pyc
__pycache__/
local_settings.py
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ COPY requirements.txt /app/

RUN apt-get update && apt-get -y upgrade
RUN apt-get install libmagic1 -y
RUN apt-get install -y gettext

# Install dependencies
RUN pip install --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY requirements-dev.txt /app/
RUN apt-get update && apt-get -y upgrade
RUN apt-get install libmagic1 -y
RUN apt-get install --no-install-recommends -y graphviz graphviz-dev
RUN apt-get install -y gettext

# Install dependencies
RUN pip install --upgrade pip
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ list:
@echo "ruff-fix - Run ruff check --fix"
@echo "pre-commit-install - Install pre-commit"
@echo "dev-quick-install - Run all the necessary commands to start the project"
@echo "make-messages - Run command to ensure translation .po files are created"
@echo "compile-messages - Run command to ensure translation .mo files are created"

up:
clear
Expand Down Expand Up @@ -120,3 +122,11 @@ docker-shell:
check:
clear
@docker-compose run --rm web python manage.py check

make-messages:
clear
@docker-compose run --rm web python manage.py makemessages --all

compile-messages:
clear
@docker-compose run --rm web python manage.py compilemessages
16 changes: 16 additions & 0 deletions app/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"simple_history.middleware.HistoryRequestMiddleware",
"django.middleware.locale.LocaleMiddleware",
]

ROOT_URLCONF = "app.urls"
Expand Down Expand Up @@ -173,6 +174,21 @@

LOGGING_FOLDER_DEFAULT = os.path.abspath(os.path.join("/logging/"))

# Internationalization

USE_I18N = True

LANGUAGES = [
("af", "Afrikaans"),
("en", "English"),
]

LANGUAGE_CODE = "en"

LOCALE_PATHS = [
os.path.join(BASE_DIR, "locale"),
]

# Check if the application is under testing
if "test" in sys.argv:
DEBUG = False
Expand Down
22 changes: 22 additions & 0 deletions app/locale/af/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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-05-21 12:07+0200\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"
#: templates/admin/base_site.html:11
msgid "Django site admin"
msgstr ""
22 changes: 22 additions & 0 deletions app/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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-05-21 11:54+0200\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"
#: templates/admin/base_site.html:11
msgid "Django site admin"
msgstr ""

0 comments on commit 0070b00

Please sign in to comment.