Traduction de l'interface en Français

This commit is contained in:
Olivier DOSSMANN 2017-08-24 22:36:55 +02:00
parent 67afac3d45
commit 8afd6dec6e
7 changed files with 243 additions and 9 deletions

1
TODO
View File

@ -1,6 +1,5 @@
# À faire
* traduction de l'interface pour l'avoir en Français de base
* tester django-split-settings pour voir ce que ça donne
* étudier la possibilité à l'utilisateur, via des variables d'environnement, de configurer un email, une autre BDD, etc.

View File

@ -0,0 +1,26 @@
# OpenBackloggery.
# Copyright (C) 2017
# This file is distributed under the same license as the openbackloggery package.
# Olivier DOSSMANN <git@dossmann.net>, 2017.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-24 22:23+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Olivier DOSSMANN <git@dossmann.net>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: collection/settings.py:114
msgid "French"
msgstr "Français"
#: collection/settings.py:115
msgid "English"
msgstr "Anglais"

View File

@ -11,6 +11,8 @@ https://docs.djangoproject.com/en/1.11/ref/settings/
"""
import os
from django.utils.translation import ugettext_lazy as _
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -44,6 +46,7 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@ -105,7 +108,12 @@ AUTH_PASSWORD_VALIDATORS = [
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
LANGUAGE_CODE = 'fr'
LANGUAGES = (
('fr', _('French')),
('en', _('English')),
)
TIME_ZONE = 'UTC'
@ -123,3 +131,9 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.abspath(os.path.curdir), 'static')
if os.getenv('STATIC_ROOT', None):
STATIC_ROOT = os.path.abspath(os.getenv('STATIC_ROOT'))
# Translation directories
LOCALE_PATHS = [
os.path.join(BASE_DIR, 'conf/locale'),
os.path.join(BASE_DIR, 'collection/locale')
]

View File

@ -0,0 +1,102 @@
# OpenBackloggery.
# Copyright (C) 2017
# This file is distributed under the same license as the openbackloggery package.
# Olivier DOSSMANN <git@dossmann.net>, 2017.
#
msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-08-24 22:23+0200\n"
"PO-Revision-Date: 2017-08-24 22:28+0200\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.0.3\n"
#: core/models.py:7 core/models.py:28
msgid "name"
msgstr "nom"
#: core/models.py:24
msgid "New"
msgstr "Nouveau"
#: core/models.py:48 core/models.py:80
msgid "status"
msgstr "état"
#: core/models.py:65
msgid "date"
msgstr "date"
#: games/models.py:14 games/models.py:24
msgid "console"
msgstr "console"
#: games/models.py:15
msgid "consoles"
msgstr "consoles"
#: games/models.py:35
msgid "Beaten"
msgstr "Terminé (quête principale)"
#: games/models.py:36
msgid "Completed"
msgstr "Terminé complètement"
#: games/models.py:37
msgid "Excluded"
msgstr "Exclu"
#: games/models.py:38
msgid "Mastered"
msgstr "Usé / Épuisé"
#: games/models.py:39
msgid "Unfinished"
msgstr "Inachevé"
#: games/models.py:46
msgid "playing?"
msgstr "en train d'y jouer ?"
#: games/models.py:47
msgid "You're currently playing this game."
msgstr "Vous jouez actuellement à ce jeu."
#: games/models.py:50
msgid "unplayed?"
msgstr "jamais joué ?"
#: games/models.py:51
msgid "You never played this game."
msgstr "Vous n'avez jamais joué à ce jeu."
#: games/models.py:54
msgid "wish?"
msgstr "envie de l'avoir ?"
#: games/models.py:55
msgid "You're waiting X-mas father offers you this game."
msgstr "Vous patientez que le père Noël vous offre ce jeu."
#: games/models.py:59
msgid "game"
msgstr "jeu"
#: games/models.py:60
msgid "games"
msgstr "jeux"
#: games/models.py:70
msgid "Timeline"
msgstr "Chronologie"
#: games/models.py:71
msgid "Timelines"
msgstr "Chronologies"

View File

@ -4,7 +4,7 @@ from django.utils.translation import ugettext as _
class Collection(models.Model):
name = models.CharField(max_length=255)
name = models.CharField(max_length=255, verbose_name=_('name'))
def __str__(self):
return '%s' % self.name
@ -25,7 +25,7 @@ class Item(models.Model):
)
DEFAULT_CHOICE = CREATED
name = models.CharField(max_length=255)
name = models.CharField(max_length=255, verbose_name=_('name'))
def __str__(self):
return '%s' % self.name
@ -39,12 +39,13 @@ class Item(models.Model):
target_field = models.ForeignKey(
cls.TARGET_MODEL,
related_name=cls.RELATED_TARGET_NAME,
verbose_name=cls.TARGET_VERBOSE_NAME)
verbose_name=_(cls.TARGET_VERBOSE_NAME))
target_field.contribute_to_class(cls, 'collection')
status_field = models.CharField(
max_length=30,
choices=Item.STATUS_CHOICES + cls.STATUS_CHOICES,
default=cls.DEFAULT_CHOICE)
default=cls.DEFAULT_CHOICE,
verbose_name=_('status'))
status_field.contribute_to_class(cls, 'status')
class Meta:
@ -58,21 +59,25 @@ class Timeline(models.Model):
For an example, a game cretion date. Or when you completed a game.
"""
TARGET_MODEL = None
TARGET_VERBOSE_NAME = None
STATUS_CHOICES = Item.STATUS_CHOICES
DEFAULT_CHOICE = Item.CREATED
date = models.DateTimeField(default=datetime.now)
date = models.DateTimeField(default=datetime.now, verbose_name=_('date'))
@classmethod
def on_class_prepared(cls):
"""
Add new field 'item' which is a link to TARGET_MODEL
"""
target_field = models.ForeignKey(cls.TARGET_MODEL)
target_field = models.ForeignKey(
cls.TARGET_MODEL,
verbose_name=_(cls.TARGET_VERBOSE_NAME))
target_field.contribute_to_class(cls, 'item')
status_field = models.CharField(
max_length=30,
choices=Item.STATUS_CHOICES + cls.STATUS_CHOICES,
default=cls.DEFAULT_CHOICE)
default=cls.DEFAULT_CHOICE,
verbose_name=_('status'))
status_field.contribute_to_class(cls, 'status')
def __str__(self):

View File

@ -0,0 +1,74 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-08-24 20:22
from __future__ import unicode_literals
import datetime
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('games', '0002_auto_20170824_1843'),
]
operations = [
migrations.AlterModelOptions(
name='console',
options={'verbose_name': 'console', 'verbose_name_plural': 'consoles'},
),
migrations.AlterModelOptions(
name='game',
options={'ordering': ('-playing', 'name'), 'verbose_name': 'game', 'verbose_name_plural': 'games'},
),
migrations.AlterModelOptions(
name='timeline',
options={'verbose_name': 'Timeline', 'verbose_name_plural': 'Timelines'},
),
migrations.AlterField(
model_name='console',
name='name',
field=models.CharField(max_length=255, verbose_name='nom'),
),
migrations.AlterField(
model_name='game',
name='name',
field=models.CharField(max_length=255, verbose_name='nom'),
),
migrations.AlterField(
model_name='game',
name='playing',
field=models.BooleanField(default=False, help_text="You're currently playing this game.", verbose_name='playing?'),
),
migrations.AlterField(
model_name='game',
name='status',
field=models.CharField(choices=[('created', 'New'), ('beaten', 'Beaten'), ('completed', 'Completed'), ('excluded', 'Excluded'), ('mastered', 'Mastered'), ('unfinished', 'Unfinished')], default='unfinished', max_length=30, verbose_name='status'),
),
migrations.AlterField(
model_name='game',
name='unplayed',
field=models.BooleanField(default=False, help_text='You never played this game.', verbose_name='unplayed?'),
),
migrations.AlterField(
model_name='game',
name='wish',
field=models.BooleanField(default=False, help_text="You're waiting X-mas father offers you this game.", verbose_name='wish?'),
),
migrations.AlterField(
model_name='timeline',
name='date',
field=models.DateTimeField(default=datetime.datetime.now, verbose_name='date'),
),
migrations.AlterField(
model_name='timeline',
name='item',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='games.Game', verbose_name='game'),
),
migrations.AlterField(
model_name='timeline',
name='status',
field=models.CharField(choices=[('created', 'New'), ('beaten', 'Beaten'), ('completed', 'Completed'), ('excluded', 'Excluded'), ('mastered', 'Mastered'), ('unfinished', 'Unfinished')], default='created', max_length=30, verbose_name='status'),
),
]

View File

@ -10,6 +10,10 @@ class Console(Collection):
def __str__(self):
return '%s' % self.name
class Meta:
verbose_name = _('console')
verbose_name_plural = _('consoles')
class Game(Item):
"""
@ -39,19 +43,29 @@ class Game(Item):
# others
playing = models.BooleanField(
default=False,
verbose_name=_('playing?'),
help_text=_('You\'re currently playing this game.'))
unplayed = models.BooleanField(
default=False,
verbose_name=_('unplayed?'),
help_text=_('You never played this game.'))
wish = models.BooleanField(
default=False,
verbose_name=_('wish?'),
help_text=_('You\'re waiting X-mas father offers you this game.'))
class Meta:
ordering = ('-playing', 'name')
verbose_name = _('game')
verbose_name_plural = _('games')
class Timeline(BaseTimeline):
TARGET_MODEL = 'games.Game'
TARGET_VERBOSE_NAME = 'game'
STATUS_CHOICES = Game.STATUS_CHOICES
DEFAULT_CHOICE = Item.DEFAULT_CHOICE
class Meta:
verbose_name = _('Timeline')
verbose_name_plural = _('Timelines')