Issues switching languages

11 views
Skip to first unread message

Thomas Wright

unread,
Sep 21, 2023, 8:53:58 AM9/21/23
to FixMyStreet
Hi All,

I'm having some issues getting multi-language support working. I've got the default set to English and I've added multiple language options, as well as edited /etc/locale.gen to enable each language in UTF-8 and run sudo locale-gen.

I'm just trying to enable languages which have already been translated, so they already exist in /locale

When accessing e.g. pt.mysite.com I'm hardly seeing anything getting localised though, anything I translate myself works, as well as a few random things like dates get localised, but most of the site remains in English.

language.png

My general.yml-docker currently has LANGUAGES like so (to match the directory names in /locale):
LANGUAGES:
  - 'en,English,en_GB'
  - 'pt,Português,pt.UTF-8'
  - 'es,Español,es_ES.UTF-8'
  - 'fr,Français,fr_FR.UTF-8'
  - 'nl,Nederlands,nl_NL.UTF-8'

I've also tried:
  - 'en,English,en_GB'
  - 'pt,Português,pt_PT'
  - 'es,Español,es_ES'
  - 'fr,Français,fr_FR'
  - 'nl,Nederlands,nl_NL'

Output of locale-gen command:
sudo locale-gen
Generating locales (this might take a while)...
  en_GB.UTF-8... done
  es_ES.UTF-8... done
  fr_FR.UTF-8... done
  nl_NL.UTF-8... done
  pt_PT.UTF-8... done

Is there anything I'm missing here?

Matthew Somerville

unread,
Sep 21, 2023, 8:59:42 AM9/21/23
to FixMyStreet
Hi,

LANGUAGES shouldn't have the ".UTF-8", that gets added by the code, so it definitely wouldn't work with them included.

Have you run commonlib/bin/gettext-makemo? That script needs to be run to convert the .po files into compiled .mo files that the server reads to fetch the translations.
It is run by script/setup so probably has been, but worth checking/running again. The fact dates are being translated implies the server language stuff is set up okay, and it's not finding the translation files themselves, so hopefully it might be that. You might also need to restart your server, some only read translation files at start up.

Hope that's helpful.

ATB,
Matthew

Thomas Wright

unread,
Sep 21, 2023, 9:31:23 AM9/21/23
to FixMyStreet, Matthew Somerville
Thanks, okay so I added these languages after the initial setup so no the script hasn't been run with them in place.

So I don't appear to have commonlib installed - I installed using docker compose so I'm kinda confused by that!
My commonlib folder is empty.
I don't believe I missed any steps in the docker installation method. I guess I need to clone https://github.com/mysociety/commonlib but I don't really understand how my environment is running without it

Matthew Somerville

unread,
Sep 21, 2023, 9:55:44 AM9/21/23
to FixMyStreet
It shouldn't matter that you added the languages after, the script compiles all the .po files, so once it's run, you shouldn't need to run it again until a .po file changes.
You could see if the .mo files exist in the same directory as the .po files, e.g. locale/fr_FR.UTF-8/LC_MESSAGES/FixMyStreet.mo should be present if it's compiled the French .po file.

If the site is running, commonlib must be somewhere :) Do you mean the development Docker compose, or production? If you just ran docker compose, it's production by default, see the install documentation for development. In which case it's plausible it's in the container, but not outside. Only the development Docker would use your current directory mapped inside the container, if I remember it right.
You shouldn't need to clone it separately, it's a submodule, so is (or should be) pulled in when cloned.

And perhaps then it needs to run that script inside the container, where hopefully it, and commonlib, are present.

ATB,
Matthew

Thomas Wright

unread,
Sep 21, 2023, 11:01:26 AM9/21/23
to FixMyStreet, Matthew Somerville
Oh yes, each locale language directory has LC_MESSSAGES containing a FixMyStreet.po
Looking in the files they're nice and full of translations, e.g from the pt file
#: templates/web/base/status/stats.html:17
#: templates/web/zurich/admin/index.html:4
msgid "<strong>%s</strong> live problems"
msgstr "<strong>%s</strong> problemas ao vivo"

I went with the production environment, it's just me setting up for a local community so I'm not planning on running a full stack.

I ran commonlib/bin/gettext-makemo from the console of the fixmystreet/fixmystreet:stable container, which comes back with "No such file or directory"
Running ls within commonlib/ shows it's empty for that container too.

I don't see another container that I'd expect to run it from, here's my stack within Portainer (created with docker compose up from the cloned respoistory directory)
fixmystreet-stack.png

Matthew Somerville

unread,
Sep 21, 2023, 12:01:28 PM9/21/23
to FixMyStreet
Yes, the .po files are human readable and what one would edit, but it is the .mo files in the same directory are what need to exist for translations to work on the site.

I would probably not recommend the production Docker unless you're actually in production and know how it is set up and works (and perhaps not even then), it pulls from Docker images and as you have found is not really set up for making developmental changes easy.

The commonlib must be present somewhere, otherwise the site would not be working at all, but I'm afraid at this point I'm not sure where it could be.
My assumption is it would be in /var/www/fixmystreet/fixmystreet/commonlib, I don't know where you may be looking.

As a hammer, something like `find / -name Locale.pm` would search the whole disk for a file that is in commonlib and used by the main code...

ATB,
Matthew
Reply all
Reply to author
Forward
0 new messages