Add documentation and source
Added documentation, source and extra files.
This commit is contained in:
9
source/translation/birds/__init__.py
Normal file
9
source/translation/birds/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class BirdsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "birds"
|
||||
|
||||
|
||||
default_app_config = "birds.BirdsConfig"
|
1
source/translation/birds/admin/__init__.py
Normal file
1
source/translation/birds/admin/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .bird import BirdAdmin
|
15
source/translation/birds/admin/bird.py
Normal file
15
source/translation/birds/admin/bird.py
Normal file
@ -0,0 +1,15 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from birds.models import Bird
|
||||
|
||||
|
||||
@admin.register(Bird)
|
||||
class BirdAdmin(admin.ModelAdmin):
|
||||
"""
|
||||
Administration configuration for birds.
|
||||
|
||||
"""
|
||||
|
||||
list_display = ["id", "uuid", "vernacular_name", "scientific_name", "weight"]
|
||||
list_editable = ["vernacular_name", "scientific_name", "weight"]
|
||||
readonly_fields = ["uuid"]
|
92
source/translation/birds/locale/fr/LC_MESSAGES/django.po
Normal file
92
source/translation/birds/locale/fr/LC_MESSAGES/django.po
Normal file
@ -0,0 +1,92 @@
|
||||
# SOME DESCRIPTIVE TITLE.
|
||||
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
||||
# This file is distributed under the same license as the PACKAGE package.
|
||||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
||||
#
|
||||
#, fuzzy
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-04-23 16:28+0200\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: birds/models/bird.py:13
|
||||
msgid "UUID"
|
||||
msgstr "UUID"
|
||||
|
||||
#: birds/models/bird.py:14
|
||||
msgid "vernacular name"
|
||||
msgstr "nom courant"
|
||||
|
||||
#: birds/models/bird.py:15
|
||||
msgid "scientific name"
|
||||
msgstr "nom scientifique"
|
||||
|
||||
#: birds/models/bird.py:16
|
||||
msgid "weight"
|
||||
msgstr "poids"
|
||||
|
||||
#: birds/models/bird.py:17
|
||||
msgctxt "bird (adjective)"
|
||||
msgid "extinct"
|
||||
msgstr "disparu"
|
||||
|
||||
#: birds/models/bird.py:20
|
||||
msgid "bird"
|
||||
msgstr "oiseau"
|
||||
|
||||
#: birds/models/bird.py:21
|
||||
msgid "birds"
|
||||
msgstr "oiseaux"
|
||||
|
||||
#: birds/templates/birds/translation-page.html:7
|
||||
msgid "example page"
|
||||
msgstr "page d'exemple"
|
||||
|
||||
#: birds/templates/birds/translation-page.html:11
|
||||
msgid "The crazy dog"
|
||||
msgstr "Le chien fou"
|
||||
|
||||
#: birds/templates/birds/translation-page.html:12
|
||||
msgctxt "task completion"
|
||||
msgid "done"
|
||||
msgstr "terminée"
|
||||
|
||||
#: birds/templates/birds/translation-page.html:13
|
||||
#, fuzzy, python-format
|
||||
#| msgid "The page title is %(text_title)s."
|
||||
msgid "The page title is %(str_title)s."
|
||||
msgstr "Le titre de la page est %(str_title)s."
|
||||
|
||||
#: birds/templates/birds/translation-page.html:15
|
||||
#, fuzzy, python-format
|
||||
#| msgid ""
|
||||
#| "\n"
|
||||
#| " There is %(counter)s bird on the roof.\n"
|
||||
#| " "
|
||||
#| msgid_plural ""
|
||||
#| "\n"
|
||||
#| " There are %(counter)s birds on the roof.\n"
|
||||
#| " "
|
||||
msgid ""
|
||||
"\n"
|
||||
" There is %(counter)s bird on the roof.\n"
|
||||
" "
|
||||
msgid_plural ""
|
||||
"\n"
|
||||
" There are %(counter)s birds on the roof.\n"
|
||||
" "
|
||||
msgstr[0] ""
|
||||
"\n"
|
||||
"Il y a %(counter)s oiseau sur le toit."
|
||||
msgstr[1] ""
|
||||
"\n"
|
||||
"Il y a %(counter)s oiseaux sur le toit."
|
30
source/translation/birds/migrations/0001_initial.py
Normal file
30
source/translation/birds/migrations/0001_initial.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 3.2 on 2021-04-15 16:24
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Bird',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('uuid', models.UUIDField(default=uuid.uuid4, verbose_name='UUID')),
|
||||
('vernacular_name', models.CharField(max_length=64, unique=True, verbose_name='vernacular name')),
|
||||
('scientific_name', models.CharField(max_length=64, unique=True, verbose_name='scientific name')),
|
||||
('weight', models.PositiveIntegerField(default=100, verbose_name='weight')),
|
||||
('is_extinct', models.BooleanField(default=False, verbose_name='extinct')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'bird',
|
||||
'verbose_name_plural': 'birds',
|
||||
},
|
||||
),
|
||||
]
|
0
source/translation/birds/migrations/__init__.py
Normal file
0
source/translation/birds/migrations/__init__.py
Normal file
1
source/translation/birds/models/__init__.py
Normal file
1
source/translation/birds/models/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .bird import Bird
|
22
source/translation/birds/models/bird.py
Normal file
22
source/translation/birds/models/bird.py
Normal file
@ -0,0 +1,22 @@
|
||||
from uuid import uuid4
|
||||
|
||||
from django.db import models
|
||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||
|
||||
|
||||
class Bird(models.Model):
|
||||
"""
|
||||
Bird definition.
|
||||
|
||||
"""
|
||||
|
||||
uuid = models.UUIDField(default=uuid4, verbose_name=_("UUID"))
|
||||
vernacular_name = models.CharField(max_length=64, unique=True, verbose_name=_("vernacular name"))
|
||||
scientific_name = models.CharField(max_length=64, unique=True, verbose_name=_("scientific name"))
|
||||
weight = models.PositiveIntegerField(default=100, verbose_name=_("weight"))
|
||||
is_extinct = models.BooleanField(default=False, verbose_name=pgettext_lazy("bird (adjective)", "extinct"))
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("bird")
|
||||
verbose_name_plural = _("birds")
|
||||
app_label = "birds"
|
@ -0,0 +1,22 @@
|
||||
{% load i18n %}
|
||||
{# Context: bird_count (int) #}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{% translate "example page" as str_title %}
|
||||
<title>{{ str_title|title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{% translate "The crazy dog" %}</h1>
|
||||
<p>Task status: {% translate "done" context "task completion" %}</p>
|
||||
<p>{% blocktranslate %}The page title is {{ str_title }}.{% endblocktranslate %}</p>
|
||||
<p>
|
||||
{% blocktranslate count counter=bird_count %}
|
||||
There is {{ counter }} bird on the roof.
|
||||
{% plural %}
|
||||
There are {{ counter }} birds on the roof.
|
||||
{% endblocktranslate %}
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
3
source/translation/birds/tests.py
Normal file
3
source/translation/birds/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
1
source/translation/birds/views/__init__.py
Normal file
1
source/translation/birds/views/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
from .base import *
|
9
source/translation/birds/views/base.py
Normal file
9
source/translation/birds/views/base.py
Normal file
@ -0,0 +1,9 @@
|
||||
from annoying.decorators import render_to
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest
|
||||
|
||||
|
||||
@render_to("birds/translation-page.html")
|
||||
def view_translation_page(request: HttpRequest) -> dict:
|
||||
print(settings.LANGUAGES)
|
||||
return {"bird_count": 1}
|
Reference in New Issue
Block a user