Skip to content

Commit

Permalink
Merge pull request #29 from dtekcth/locale-fix
Browse files Browse the repository at this point in the history
Locale fix
  • Loading branch information
The1Penguin authored Sep 5, 2024
2 parents dfec640 + 6b12103 commit 50fa8fe
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 85 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ __pycache__
secret-key.txt
portal-env
*.swp
*.mo
static/*
logs/*
db
Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ ENV DB_PORT="5432"

EXPOSE 80

CMD ["uwsgi", "--socket", "0.0.0.0:3000", \
"--protocol", "uwsgi", \
"--module", "dtekportal.wsgi"]
CMD python3 manage.py migrate && python3 manage.py compilemessages && uwsgi --socket 0.0.0.0:3000 --protocol uwsgi --module dtekportal.wsgi

#CMD /scripts/wait-for-it.sh "$DB_HOST:$DB_PORT" -- \
# uwsgi --http-socket ":$PORT" --module dtekportal.wsgi
25 changes: 8 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,21 @@ export $(shell sed 's/=.*//' .env)
test:
env

up-prod:
sudo -E docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
sudo -E docker-compose exec web /bin/sh -c "python3 manage.py migrate"
sudo -E docker-compose exec web /bin/sh -c "python3 manage.py compilemessages -l en"
sudo -E docker-compose exec web /bin/sh -c "python3 manage.py collectstatic --noinput"

up-develop:
# sleep 5 && sudo docker-compose exec web /bin/sh -c "python3 manage.py migrate" &
sudo -E docker-compose run web /bin/sh -c "python3 manage.py compilemessages -l en"
sudo -E docker-compose -f docker-compose.yml -f docker-compose.develop.yml up
docker compose run web /bin/sh -c "python3 manage.py compilemessages -l en"
docker compose -f docker-compose.yml -f docker-compose.develop.yml up

makemessages:
sudo -E docker-compose run web python3 manage.py makemessages -l en

# Use when the container is running
makemessages-exec:
sudo -E docker-compose exec web python3 manage.py makemessages -l en
docker compose exec web python3 manage.py makemessages -a
docker compose cp web:/locale .

compilemessages:
sudo -E docker-compose exec web python3 manage.py compilemessages -l en

docker compose cp ./locale web:.
docker compose exec web python3 manage.py compilemessages

build:
sudo -E docker-compose build
docker compose build

down:
sudo -E docker-compose down
docker compose down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,5 +162,6 @@ parameter in the url as defined in `urls.py`.

The website is written with Swedish as its original language. In order to make a string translatable, it must be wrapped in a function. For details on how to do this in pyton code and template code respectively, see the [Django docs on translation](https://docs.djangoproject.com/en/2.1/topics/i18n/translation/).

The mapping from Swedish to English lives in `locale/en/LC_MESSAGES/django.po
`. When you have edited a file and added strings that need to be created, run `make makemessages`. This will update the .po file to contain the new strings, whose translation can now be filled in. For the website to update, you need to compile the .po file. This can be done by running `make compilemessages`. If this does not work, try stopping the container using `make down` and starting it up again; the makefile is configured to compile the messages as the container starts.
The mapping from Swedish to English lives in `locale/en/LC_MESSAGES/django.po`. When you have edited a file and added strings that need to be created, run `make makemessages`. This will update the .po file to contain the new strings, whose translations can now be filled in. Any translation strings that have been marked as "fuzzy" will be ignored by Django, so make sure to clean those up before finishing.

For the website to update, you need to compile the .po file. This can be done by running `make compilemessages`. If this does not work, try stopping the container using `make down` and starting it up again; the makefile is configured to compile the messages as the container starts.
5 changes: 4 additions & 1 deletion docker-compose.develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ version: '3.7'
services:
web:
# use wait for it script to make sure db is ready before launching
command: ["/scripts/wait-for-it.sh", "db:5432", "--", "python", "manage.py", "runserver", "0.0.0.0:8000"]
command: ["/scripts/boot.sh"]
ports:
- "8000:8000"
volumes:
- ./dtekportal:/code
- ./scripts:/scripts
environment:
- DJANGO_DEBUG=1
Binary file removed locale/en/LC_MESSAGES/django.mo
Binary file not shown.
83 changes: 21 additions & 62 deletions locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-10-26 19:34+0200\n"
"POT-Creation-Date: 2024-09-04 21:03+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"
Expand All @@ -30,29 +30,29 @@ msgstr "The divison on Facebook"
msgid "Mat på Campus:"
msgstr "Food on campus:"

#: homepage/templates/homepage/index/welcome-box.html:10
#: homepage/templates/homepage/index/welcome-box.html:11
msgid "Välkommen"
msgstr "Welcome"

#: homepage/templates/homepage/index/welcome-box.html:14
#: homepage/templates/homepage/index/welcome-box.html:15
msgid ""
"Detta är DTEK-portalen, med ett gäng nyttiga länkar till ställen där du kan "
"tänkas vilja gå."
msgstr ""
"This is the DTEK portal, containing a bunch of useful links to places you "
"might want to go."

#: homepage/templates/homepage/index/welcome-box.html:16
#: homepage/templates/homepage/index/welcome-box.html:17
msgid ""
"Datateknologsektionen är en icke vinstdrivande organisation som är till för "
"alla studenter på civilingenjörsprogrammet Datateknik på Chalmers och dess "
"relaterade <a class=\"wikilink\" href=\"//dtek.se/wiki/Main/Masterprogram"
"\">masterprogram</a>. Vi ordnar <a class=\"wikilink\" href=\"//dtek.se/wiki/"
"Main/Mottagning\">mottagning</a> för nyantagna, arrangerar <a class="
"\"categorylink\" href=\"//dtek.se/wiki/Kategorier/Fester\">fester</a>, "
"bedriver <a class=\"wikilink\" href=\"https://dns.dtek.se/"
"\">studiebevakning</a> och <a class=\"wikilink\" href=\"//dtek.se/wiki/Main/"
"Index\">mycket mer</a>."
"relaterade <a class=\"wikilink\" href=\"https://wiki.dtek.se/wiki/"
"Masterprogram\">masterprogram</a>. Vi ordnar <a class=\"wikilink\" "
"href=\"https://wiki.dtek.se/wiki/Mottagning\">mottagning</a> för nyantagna, "
"arrangerar <a class=\"categorylink\" href=\"https://wiki.dtek.se/wiki/"
"D6\">fester</a>, bedriver <a class=\"wikilink\" href=\"https://dns.dtek.se/"
"\">studiebevakning</a> och <a class=\"wikilink\" href=\"https://wiki.dtek.se/"
"wiki/Main_Page\">mycket mer</a>."
msgstr ""
"The Student Division of Computer Science and Engineering,&quot;Data&quot; "
"(officially &quot;Datateknologsektionen&quot; in Swedish),is a nonprofit "
Expand All @@ -61,12 +61,13 @@ msgstr ""
"Masterprogram\">master's programmes</a>. We arrange receptions for "
"newlyadmitted students at both the <a class=\"wikilink\" href=\"//dtek.se/"
"wiki/Main/Mottagning\">bachelor's</a> and <a class=\"wikilink\" href=\"//"
"dtek.se/wiki/Main/DMNollK\">master's</a> programmes, arrange <a class="
"\"categorylink\" href=\"//dtek.se/wiki/Kategorier/Fester\">parties</a>, <a "
"class=\"wikilink\" href=\"https://dns.dtek.se/\">monitor your education</a> "
"and <a class=\"wikilink\" href=\"//dtek.se/wiki/Main/Index\">much more</a>."
"dtek.se/wiki/Main/DMNollK\">master's</a> programmes, arrange <a "
"class=\"categorylink\" href=\"//dtek.se/wiki/Kategorier/Fester\">parties</"
"a>, <a class=\"wikilink\" href=\"https://dns.dtek.se/\">monitor your "
"education</a> and <a class=\"wikilink\" href=\"//dtek.se/wiki/Main/"
"Index\">much more</a>."

#: homepage/templates/homepage/index/welcome-box.html:18
#: homepage/templates/homepage/index/welcome-box.html:19
msgid ""
"En del av <a href=\"https://chalmersstudentkar.se/\">Chalmers Studentkår </a>"
msgstr ""
Expand All @@ -87,9 +88,9 @@ msgid ""
"dHack <[email protected]>\">dHack</a> med URL-en och förklara vad du förväntade "
"dig att hitta där."
msgstr ""
"If you think there's an error behind the scenes, please contact <a hrek="
"\"mailto:dHack <[email protected]>\">dHack</a> with the URL and explain what you "
"were expecting to see."
"If you think there's an error behind the scenes, please contact <a "
"hrek=\"mailto:dHack <[email protected]>\">dHack</a> with the URL and explain "
"what you were expecting to see."

#: templates/footer/footer-foot.html:8
msgid "Utvecklad av "
Expand Down Expand Up @@ -210,7 +211,7 @@ msgstr "Master Reception Committee"
msgid "Matlagningskommitté"
msgstr "Cooking Committee"

#: templates/footer/footer-right-col.html:142
#: templates/footer/footer-right-col.html:144
msgid "Jämlikhetskommitté"
msgstr "Equality Committee"

Expand Down Expand Up @@ -326,45 +327,3 @@ msgstr "Studies"
#: templates/top-nav-banner.html:23
msgid "Foton"
msgstr "Photos"

#~ msgid "Dbrus"
#~ msgstr "DBrus"

#~ msgid "PingPong"
#~ msgstr "PingPong"

#~ msgid "Chalmers Tekniska Högskola"
#~ msgstr "Chalmers University of Technology"

#~ msgid "en del av Chalmers Studentkår"
#~ msgstr "part of Chalmers Student Union"

#~ msgid "Jobb"
#~ msgstr "Jobs"

#~ msgid "Twitter"
#~ msgstr "Twitter"

#~ msgid "Twitter!"
#~ msgstr "Twitter!"

#~ msgid "Reddit"
#~ msgstr "Reddit"

#~ msgid "Schysst subreddit med stor potential"
#~ msgstr "Cool subreddit with huge potential"

#~ msgid "Cremona"
#~ msgstr "Cremona"

#~ msgid "Cremona bokhandel, numera kallat Store"
#~ msgstr "Cremona bookstore, now called Store"

#~ msgid "IRC"
#~ msgstr "IRC"

#~ msgid "Slack, fast utan GUI. För äkta Datateknologer!"
#~ msgstr "Slack, but without the GUI. For real computer geeks!"

#~ msgid "Datateknologsektionen Full Title"
#~ msgstr "Student Division of Computer Science and Engineering"
Loading

0 comments on commit 50fa8fe

Please sign in to comment.