Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale fix #29

Merged
merged 10 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignoring compiled localization files

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit funky, but it works


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

# delete this
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"

# delete this too
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

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
sudo -E docker compose exec web python3 manage.py makemessages -a
sudo -E docker compose cp web:/locale .

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


build:
sudo -E docker-compose build

down:
sudo -E docker-compose down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two are referred to in the README, so it should be updated with new build instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also just revert the change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also works

sudo -E docker compose cp ./locale web:.
sudo -E docker compose exec web python3 manage.py compilemessages
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.
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
Loading