misc: add django app for translations (#71292)

This commit is contained in:
Frédéric Péters 2024-03-06 13:03:55 +01:00
parent 081fe9dec8
commit a899695dab
6 changed files with 74 additions and 0 deletions

22
manage.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'publik_base_theme.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
'available on your PYTHONPATH environment variable? Did you '
'forget to activate a virtual environment?'
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View File

View File

View File

@ -0,0 +1,29 @@
# publik-base-theme
# Copyright (C) 2014-2024 Entr'ouvert
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.core.management.commands import makemessages
class Command(makemessages.Command):
def handle(self, *args, **options):
if not options.get('add_location') and self.gettext_version >= (0, 19):
options['add_location'] = 'file'
return super().handle(*args, **options)
def find_files(self, root):
for file in super().find_files('templates'):
file.locale_dir = 'publik_base_theme/locale'
yield file

View File

@ -0,0 +1,23 @@
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Application definition
INSTALLED_APPS = ['publik_base_theme']
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'fr-fr'
TIME_ZONE = 'Europe/Paris'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (BASE_DIR / 'publik_base_theme' / 'locale',)