add i18n support

This commit is contained in:
Frédéric Péters 2019-03-17 11:30:38 +01:00
parent 601772a250
commit dd472b7200
4 changed files with 53 additions and 4 deletions

View File

@ -1,3 +1,7 @@
# locales
recursive-include eo_gestion/locale *.po *.mo
# templates & static
recursive-include eo_gestion/templates *
recursive-include eo_gestion/eo_banque/templates *
recursive-include eo_gestion/eo_facture/static *

View File

@ -18,8 +18,8 @@
<div class="breadcrumbs">
<a href="../../../">{% trans "Home" %}</a> &rsaquo;
<a href="../../">{{ app_label|capfirst|escape }}</a> &rsaquo;
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
{% trans "Rapid' facture" %}
{% if has_change_permission %}<a href="../">{{ opts.verbose_name_plural|capfirst }}</a>{% else %}{{ opts.verbose_name_plural|capfirst }}{% endif %} &rsaquo;
Rapid' facture
</div>
{% endif %}{% endblock %}

View File

@ -51,6 +51,8 @@ USE_L10N = True
# Use timezone aware datetime
USE_TZ = True
LOCALE_PATHS = (os.path.join(BASE_DIR, 'eo_gestion', 'locale'), )
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"

View File

@ -2,9 +2,13 @@
import os
import subprocess
import sys
from distutils.cmd import Command
from distutils.command.build import build as _build
from distutils.command.sdist import sdist
from setuptools import setup, find_packages
from setuptools.command.install_lib import install_lib as _install_lib
install_requires=[
'Django>=1.8,<1.12',
@ -59,6 +63,41 @@ class eo_sdist(sdist):
if os.path.exists('VERSION'):
os.remove('VERSION')
class compile_translations(Command):
description = 'compile message catalogs to MO files via django compilemessages'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
try:
from django.core.management import call_command
for path, dirs, files in os.walk('eo_gestion'):
if 'locale' not in dirs:
continue
curdir = os.getcwd()
os.chdir(os.path.realpath(path))
call_command('compilemessages')
os.chdir(curdir)
except ImportError:
sys.stderr.write('!!! Please install Django >= 1.4 to build translations\n')
class build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands
class install_lib(_install_lib):
def run(self):
self.run_command('compile_translations')
_install_lib.run(self)
setup(name="barbacompta",
version=get_version(),
license="AGPLv3 or later",
@ -72,6 +111,10 @@ setup(name="barbacompta",
scripts=['manage.py'],
packages=find_packages(),
install_requires=install_requires,
cmdclass={'sdist': eo_sdist},
cmdclass={
'build': build,
'compile_translations': compile_translations,
'install_lib': install_lib,
'sdist': eo_sdist,
},
)