From cc347258b5723c058714b5ef9df6e292ab143029 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 27 Aug 2025 11:11:55 -0700 Subject: [PATCH] Makefile, settings: Use full paths in pot files - As reported on IRC, links to source code files in Weblate are broken. This is due to incorrect paths to files inside the POT file. Instead of plinth/views.py it contains views.py. This might be a regression introduced when switching to Makefile for all build tasks. - To fix, we need to run 'django-admin makemessages' command at the topic level directory in the source code repository. However, running at the top-level has problems: - Various unnecessary directories are considered. This was remedied using --ignore aruments. - The default locales directory was not being detected. This was remedied using LOCALE_PATHS in Django settings. - Django settings file was not being picked up. This was remedied using --settings option. - Django settings were being picked up from system's module path. This was remedied using --pythonpath . option. Tests: - Running 'make update-translations' updates all the files. Newly generated POT file contains plinth/ in the file paths. All locales were updated. There are no other major changes POT or language files (other than what seemed to be pending updates). - Running freedombox-develop, locale can be changed to Spanish. The changed locale is visible in UI. Changes to .po file are reflected in the UI after running 'django-admin compilemessages'. - After running freedombox using plinth.service systemd unit, locale can be changed to Spanish. The changed locale is visible in UI. Changes to .po file are reflected in the UI after running 'make build install'. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- Makefile | 6 +++++- plinth/settings.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f2953c622..bc5cb22cf 100644 --- a/Makefile +++ b/Makefile @@ -58,7 +58,11 @@ ROOT_DATA_FILES := $(shell find data -type f $(FIND_ARGS)) MODULE_DATA_FILES := $(shell find $(wildcard plinth/modules/*/data) -type f $(FIND_ARGS)) update-translations: - cd plinth; $(DJANGO_ADMIN) makemessages --all --domain django --keep-pot --verbosity=1 + $(DJANGO_ADMIN) makemessages --all --domain django --keep-pot \ + --verbosity=1 --ignore conftest.py --ignore doc --ignore build \ + --ignore htmlcov --ignore screenshots --ignore debian --ignore \ + actions --ignore preseed --ignore static --ignore data \ + --settings plinth.settings --pythonpath . configure: # Nothing to do diff --git a/plinth/settings.py b/plinth/settings.py index 61862f668..8a192425a 100644 --- a/plinth/settings.py +++ b/plinth/settings.py @@ -135,6 +135,9 @@ IPWARE_META_PRECEDENCE_ORDER = ('REMOTE_ADDR', ) # Overridden by get_languages() LANGUAGES = [('en', 'English')] +# A list of directories where Django looks for translation files. +LOCALE_PATHS = ['plinth/locale'] + # Overridden by log configuration in log.py LOGGING = {'version': 1}