Browse Source

rebooted project

rendu-univ
Phuntsok Drak-pa 1 year ago
parent
commit
ef83822a74
No known key found for this signature in database GPG Key ID: 9CB34B6827C66D22
22 changed files with 243 additions and 746 deletions
  1. +0
    -0
      conlangdict/__init__.py
  2. +6
    -5
      conlangdict/settings.py
  3. +1
    -3
      conlangdict/urls.py
  4. +2
    -2
      conlangdict/wsgi.py
  5. +0
    -3
      dict/admin.py
  6. +0
    -5
      dict/apps.py
  7. +0
    -668
      dict/templates/dict/index.html
  8. +0
    -31
      dict/urls.py
  9. +0
    -20
      dict/views.py
  10. +0
    -0
      dictionary/__init__.py
  11. +7
    -0
      dictionary/admin.py
  12. +5
    -0
      dictionary/apps.py
  13. +67
    -0
      dictionary/migrations/0001_initial.py
  14. +0
    -0
      dictionary/migrations/__init__.py
  15. +7
    -8
      dictionary/models.py
  16. +3
    -0
      dictionary/static/dictionary/style.css
  17. +22
    -0
      dictionary/templates/dictionary/base.html
  18. +51
    -0
      dictionary/templates/dictionary/details.html
  19. +0
    -0
      dictionary/tests.py
  20. +44
    -0
      dictionary/urls.py
  21. +27
    -0
      dictionary/views.py
  22. +1
    -1
      manage.py

dict/__init__.py → conlangdict/__init__.py View File


languephundrakfr/settings.py → conlangdict/settings.py View File

@@ -1,7 +1,7 @@
"""
Django settings for languephundrakfr project.
Django settings for conlangdict project.

Generated by 'django-admin startproject' using Django 2.1.2.
Generated by 'django-admin startproject' using Django 2.1.3.

For more information on this file, see
https://docs.djangoproject.com/en/2.1/topics/settings/
@@ -20,7 +20,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '#oc=#a@%svwxw^r9j%x2+@9_ea1lc&(@x(q9$ddape-_kgsa0m'
SECRET_KEY = 'udbex%6hseo5tys7ovemjy&cu5x@r*qc9=2gqufh$md%#(ofx*'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
@@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition

INSTALLED_APPS = [
'dictionary.apps.DictionaryConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
@@ -49,7 +50,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'languephundrakfr.urls'
ROOT_URLCONF = 'conlangdict.urls'

TEMPLATES = [
{
@@ -67,7 +68,7 @@ TEMPLATES = [
},
]

WSGI_APPLICATION = 'languephundrakfr.wsgi.application'
WSGI_APPLICATION = 'conlangdict.wsgi.application'


# Database

languephundrakfr/urls.py → conlangdict/urls.py View File

@@ -1,4 +1,4 @@
"""languephundrakfr URL Configuration
"""conlangdict URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
@@ -15,9 +15,7 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path
from django.conf.urls import include

urlpatterns = [
path('admin/', admin.site.urls),
path('dictionary', include('dict.urls')),
]

languephundrakfr/wsgi.py → conlangdict/wsgi.py View File

@@ -1,5 +1,5 @@
"""
WSGI config for languephundrakfr project.
WSGI config for conlangdict project.

It exposes the WSGI callable as a module-level variable named ``application``.

@@ -11,6 +11,6 @@ import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'languephundrakfr.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conlangdict.settings')

application = get_wsgi_application()

+ 0
- 3
dict/admin.py View File

@@ -1,3 +0,0 @@
from django.contrib import admin

# Register your models here.

+ 0
- 5
dict/apps.py View File

@@ -1,5 +0,0 @@
from django.apps import AppConfig


class DictConfig(AppConfig):
name = 'dict'

+ 0
- 668
dict/templates/dict/index.html View File

@@ -1,668 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Ressources grammaticales des langues construites de P’undrak</title>
<meta name="author" content="Lucien Cartier-Tilet" />
<style type="text/css">
< !--

/*--><![CDATA[/*><!--*/
.title {
text-align: center;
margin-bottom: .2em;
}

.subtitle {
text-align: center;
font-size: medium;
font-weight: bold;
margin-top: 0;
}

.todo {
font-family: monospace;
color: red;
}

.done {
font-family: monospace;
color: green;
}

.priority {
font-family: monospace;
color: orange;
}

.tag {
background-color: #eee;
font-family: monospace;
padding: 2px;
font-size: 80%;
font-weight: normal;
}

.timestamp {
color: #bebebe;
}

.timestamp-kwd {
color: #5f9ea0;
}

.org-right {
margin-left: auto;
margin-right: 0px;
text-align: right;
}

.org-left {
margin-left: 0px;
margin-right: auto;
text-align: left;
}

.org-center {
margin-left: auto;
margin-right: auto;
text-align: center;
}

.underline {
text-decoration: underline;
}

#postamble p,
#preamble p {
font-size: 90%;
margin: .2em;
}

p.verse {
margin-left: 3%;
}

pre {
border: 1px solid #ccc;
box-shadow: 3px 3px 3px #eee;
padding: 8pt;
font-family: monospace;
overflow: auto;
margin: 1.2em;
}

pre.src {
position: relative;
overflow: visible;
padding-top: 1.2em;
}

pre.src:before {
display: none;
position: absolute;
background-color: white;
top: -10px;
right: 10px;
padding: 3px;
border: 1px solid black;
}

pre.src:hover:before {
display: inline;
}

/* Languages per Org manual */
pre.src-asymptote:before {
content: 'Asymptote';
}

pre.src-awk:before {
content: 'Awk';
}

pre.src-C:before {
content: 'C';
}

/* pre.src-C++ doesn't work in CSS */
pre.src-clojure:before {
content: 'Clojure';
}

pre.src-css:before {
content: 'CSS';
}

pre.src-D:before {
content: 'D';
}

pre.src-ditaa:before {
content: 'ditaa';
}

pre.src-dot:before {
content: 'Graphviz';
}

pre.src-calc:before {
content: 'Emacs Calc';
}

pre.src-emacs-lisp:before {
content: 'Emacs Lisp';
}

pre.src-fortran:before {
content: 'Fortran';
}

pre.src-gnuplot:before {
content: 'gnuplot';
}

pre.src-haskell:before {
content: 'Haskell';
}

pre.src-hledger:before {
content: 'hledger';
}

pre.src-java:before {
content: 'Java';
}

pre.src-js:before {
content: 'Javascript';
}

pre.src-latex:before {
content: 'LaTeX';
}

pre.src-ledger:before {
content: 'Ledger';
}

pre.src-lisp:before {
content: 'Lisp';
}

pre.src-lilypond:before {
content: 'Lilypond';
}

pre.src-lua:before {
content: 'Lua';
}

pre.src-matlab:before {
content: 'MATLAB';
}

pre.src-mscgen:before {
content: 'Mscgen';
}

pre.src-ocaml:before {
content: 'Objective Caml';
}

pre.src-octave:before {
content: 'Octave';
}

pre.src-org:before {
content: 'Org mode';
}

pre.src-oz:before {
content: 'OZ';
}

pre.src-plantuml:before {
content: 'Plantuml';
}

pre.src-processing:before {
content: 'Processing.js';
}

pre.src-python:before {
content: 'Python';
}

pre.src-R:before {
content: 'R';
}

pre.src-ruby:before {
content: 'Ruby';
}

pre.src-sass:before {
content: 'Sass';
}

pre.src-scheme:before {
content: 'Scheme';
}

pre.src-screen:before {
content: 'Gnu Screen';
}

pre.src-sed:before {
content: 'Sed';
}

pre.src-sh:before {
content: 'shell';
}

pre.src-sql:before {
content: 'SQL';
}

pre.src-sqlite:before {
content: 'SQLite';
}

/* additional languages in org.el's org-babel-load-languages alist */
pre.src-forth:before {
content: 'Forth';
}

pre.src-io:before {
content: 'IO';
}

pre.src-J:before {
content: 'J';
}

pre.src-makefile:before {
content: 'Makefile';
}

pre.src-maxima:before {
content: 'Maxima';
}

pre.src-perl:before {
content: 'Perl';
}

pre.src-picolisp:before {
content: 'Pico Lisp';
}

pre.src-scala:before {
content: 'Scala';
}

pre.src-shell:before {
content: 'Shell Script';
}

pre.src-ebnf2ps:before {
content: 'ebfn2ps';
}

/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre.src-cpp:before {
content: 'C++';
}

pre.src-abc:before {
content: 'ABC';
}

pre.src-coq:before {
content: 'Coq';
}

pre.src-groovy:before {
content: 'Groovy';
}

/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre.src-bash:before {
content: 'bash';
}

pre.src-csh:before {
content: 'csh';
}

pre.src-ash:before {
content: 'ash';
}

pre.src-dash:before {
content: 'dash';
}

pre.src-ksh:before {
content: 'ksh';
}

pre.src-mksh:before {
content: 'mksh';
}

pre.src-posh:before {
content: 'posh';
}

/* Additional Emacs modes also supported by the LaTeX listings package */
pre.src-ada:before {
content: 'Ada';
}

pre.src-asm:before {
content: 'Assembler';
}

pre.src-caml:before {
content: 'Caml';
}

pre.src-delphi:before {
content: 'Delphi';
}

pre.src-html:before {
content: 'HTML';
}

pre.src-idl:before {
content: 'IDL';
}

pre.src-mercury:before {
content: 'Mercury';
}

pre.src-metapost:before {
content: 'MetaPost';
}

pre.src-modula-2:before {
content: 'Modula-2';
}

pre.src-pascal:before {
content: 'Pascal';
}

pre.src-ps:before {
content: 'PostScript';
}

pre.src-prolog:before {
content: 'Prolog';
}

pre.src-simula:before {
content: 'Simula';
}

pre.src-tcl:before {
content: 'tcl';
}

pre.src-tex:before {
content: 'TeX';
}

pre.src-plain-tex:before {
content: 'Plain TeX';
}

pre.src-verilog:before {
content: 'Verilog';
}

pre.src-vhdl:before {
content: 'VHDL';
}

pre.src-xml:before {
content: 'XML';
}

pre.src-nxml:before {
content: 'XML';
}

/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre.src-conf:before {
content: 'Configuration File';
}

table {
border-collapse: collapse;
}

caption.t-above {
caption-side: top;
}

caption.t-bottom {
caption-side: bottom;
}

td,
th {
vertical-align: top;
}

th.org-right {
text-align: center;
}

th.org-left {
text-align: center;
}

th.org-center {
text-align: center;
}

td.org-right {
text-align: right;
}

td.org-left {
text-align: left;
}

td.org-center {
text-align: center;
}

dt {
font-weight: bold;
}

.footpara {
display: inline;
}

.footdef {
margin-bottom: 1em;
}

.figure {
padding: 1em;
}

.figure p {
text-align: center;
}

.inlinetask {
padding: 10px;
border: 2px solid gray;
margin: 10px;
background: #ffffcc;
}

#org-div-home-and-up {
text-align: right;
font-size: 70%;
white-space: nowrap;
}

textarea {
overflow-x: auto;
}

.linenr {
font-size: smaller
}

.code-highlighted {
background-color: #ffff00;
}

.org-info-js_info-navigation {
border-style: none;
}

#org-info-js_console-label {
font-size: 10px;
font-weight: bold;
white-space: nowrap;
}

.org-info-js_search-highlight {
background-color: #ffff00;
color: #000000;
font-weight: bold;
}

.org-svg {
width: 90%;
}

/*]]>*/
-->
</style>
<link rel="stylesheet" type="text/css" href="https://langue.phundrak.fr/css/htmlize.css" />
<link rel="stylesheet" type="text/css" href="https://langue.phundrak.fr/css/readtheorg.css" />
<script src="https://langue.phundrak.fr/js/jquery.min.js" type="9d15bb63fe2ebd1673c7926d-text/javascript"></script>
<script src="https://langue.phundrak.fr/js/bootstrap.min.js" type="9d15bb63fe2ebd1673c7926d-text/javascript"></script>
<script type="9d15bb63fe2ebd1673c7926d-text/javascript" src="https://langue.phundrak.fr/js/jquery.stickytableheaders.min.js"></script>
<script type="9d15bb63fe2ebd1673c7926d-text/javascript" src="https://langue.phundrak.fr/js/readtheorg.js"></script>
<script type="9d15bb63fe2ebd1673c7926d-text/javascript">
/*
@licstart The following is the entire license notice for the
JavaScript code in this tag.

Copyright (C) 2012-2018 Free Software Foundation, Inc.

The JavaScript code in this tag is free software: you can
redistribute it and/or modify it under the terms of the GNU
General Public License (GNU GPL) as published by the Free Software
Foundation, either version 3 of the License, or (at your option)
any later version. The code is distributed WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.

As additional permission under GNU GPL version 3 section 7, you
may distribute non-source (e.g., minimized or compacted) forms of
that code without the copy of the GNU GPL normally required by
section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.


@licend The above is the entire license notice
for the JavaScript code in this tag.
*/
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id) {
var target = document.getElementById(id);
if (null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}

function CodeHighlightOff(elem, id) {
var target = document.getElementById(id);
if (elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if (elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*/ //-->
</script>
</head>

<body>
<div id="content">
<h1 class="title">Ressources grammaticales des langues construites de P’undrak</h1>
<p>
</p>
<div id="table-of-contents">
<h2>Table des matières</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#org1036381">1. Langues divines</a></li>
<li><a href="#org8545bfe">2. Langues draconiennes</a></li>
<li><a href="#orgc179637">3. Langues humaines</a></li>
</ul>
</div>
</div>
<p>
</p>
<div id="outline-container-org1036381" class="outline-2">
<h2 id="org1036381"><span class="section-number-2">1</span> Langues divines</h2>
<div class="outline-text-2" id="text-1">
<p>
<a href="https://langue.phundrak.fr/hjalpi">Hjalpi’ Originel</a> (<a href="https://langue.phundrak.fr/hjalpi/hjalpi.pdf">version pdf</a>)
</p>
</div>
</div>
<div id="outline-container-org8545bfe" class="outline-2">
<h2 id="org8545bfe"><span class="section-number-2">2</span> Langues draconiennes</h2>
<div class="outline-text-2" id="text-2">
<p>
<a href="https://langue.phundrak.fr/lijokken">Łijökken</a> (en cours)
</p>
<p>
<a href="https://langue.phundrak.fr/zohaen">Zöhæň</a> (en cours)
</p>
</div>
</div>
<div id="outline-container-orgc179637" class="outline-2">
<h2 id="orgc179637"><span class="section-number-2">3</span> Langues humaines</h2>
<div class="outline-text-2" id="text-3">
<p>
Enánon (à venir)
</p>
</div>
</div>
</div>
<div id="postamble" class="status">
<p class="author">Auteur: Lucien Cartier-Tilet</p>
<p class="date">Created: 2018-10-05 ven. 13:20</p>
<p class="validation"></p>
</div>
<script src="https://ajax.cloudflare.com/cdn-cgi/scripts/2448a7bd/cloudflare-static/rocket-loader.min.js" data-cf-nonce="9d15bb63fe2ebd1673c7926d-" defer=""></script>
</body>

</html>

+ 0
- 31
dict/urls.py View File

@@ -1,31 +0,0 @@
from django.conf.urls import url
from . import views

app_name = 'dict'

urlpatterns = [
# /dict/from=FRA/to=HJA/a
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<destlang>[a-zA-Z]+)/(?P<initial>[a-zA-Z])/*$',
views.listwords,
name='listwords'),

# /dict/lang=HJA/tay => renvoie cinq mots commençant par `tay`
url(r'^from=(?P<sourcelang>[a-zA-Z]+)/(?P<word>\w)/*$',
views.guess,
name='guess'),

# /dict/from=FRA/to=HJA/jour => renvoie le sommaire de la traduction de
# `jour`
url(
r'^from=<sourcelang>\w/to=<destlang>\w/<word>\w/*$',
views.translate,
name='translate',
),

# /dict/from=HJA/details=bém
url(
r'^lang=(?P<language>[a-zA-Z)+]/details=(?P<word>\w)/*$',
views.details,
name='details',
),
]

+ 0
- 20
dict/views.py View File

@@ -1,20 +0,0 @@
from django.shortcuts import render
from .models import Word
from django.utils import slugify
from django.shortcuts import render, get_object_or_404


def listwords(request, sourcelang, destlang, initial):
all_words = Word.objects.filter(
name__startswith=initial, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})


def guess(request, sourcelang, word):
all_words = Word.objects.filter(name__startswith=word, language=sourcelang)
return render(request, 'dict/index.html', {'all_words': all_words})

def translate(request, sourcelang, destlang, word):
detailed_word = get_object_or_404(Word, slug=slugify(word), language=sourcelang)
translations = get_object_or_404(Word, slug=slugify(word), language)
return render(request, 'dict/detailed.html', {'detailed_word': detailed_word})

dict/migrations/__init__.py → dictionary/__init__.py View File


+ 7
- 0
dictionary/admin.py View File

@@ -0,0 +1,7 @@
from django.contrib import admin
from .models import Language, Gender, Word, Wordclass

admin.site.register(Language)
admin.site.register(Gender)
admin.site.register(Word)
admin.site.register(Wordclass)

+ 5
- 0
dictionary/apps.py View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig


class DictionaryConfig(AppConfig):
name = 'dictionary'

+ 67
- 0
dictionary/migrations/0001_initial.py View File

@@ -0,0 +1,67 @@
# Generated by Django 2.1.3 on 2018-12-05 11:53

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Gender',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
],
options={
'ordering': ('name',),
},
),
migrations.CreateModel(
name='Language',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=128)),
],
options={
'ordering': ('code',),
},
),
migrations.CreateModel(
name='Word',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('word', models.CharField(max_length=128)),
('slug', models.CharField(max_length=128)),
('details', models.CharField(blank=True, max_length=8192)),
('etymology', models.CharField(blank=True, max_length=8192)),
('gender', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='dictionary.Gender')),
('language', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dictionary.Language')),
('roots', models.ManyToManyField(related_name='_word_roots_+', to='dictionary.Word')),
('translation', models.ManyToManyField(related_name='_word_translation_+', to='dictionary.Word')),
],
options={
'ordering': ('word',),
},
),
migrations.CreateModel(
name='Wordclass',
fields=[
('code', models.CharField(max_length=4, primary_key=True, serialize=False)),
('name', models.CharField(max_length=64)),
],
options={
'ordering': ('code',),
},
),
migrations.AddField(
model_name='word',
name='wordclass',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='dictionary.Wordclass'),
),
]

languephundrakfr/__init__.py → dictionary/migrations/__init__.py View File


dict/models.py → dictionary/models.py View File

@@ -4,7 +4,7 @@ bilingual dictionary capable of translating back and forth between natlangs
and the conlangs of https://langue.phundrak.fr
"""
from django.db import models
from django.utils import slugify
from django.utils.text import slugify


class Language(models.Model):
@@ -56,16 +56,15 @@ class Word(models.Model):
its \"etymology\" (no more than 5000 chars) and a list of words that can be
its etymological \"roots\"
"""
word = models.CharField(max_length=124)
slug = models.CharField(max_length=124)
word = models.CharField(max_length=128)
slug = models.CharField(max_length=128)
language = models.ForeignKey(Language, on_delete=models.CASCADE)
translation = models.ManyToManyField("self", blank=True)
gender = models.ForeignKey(Gender, on_delete=models.SET_NULL)
wordclass = models.ForeignKey(Wordclass, on_delete=models.SET_NULL)
translation = models.ManyToManyField("self")
gender = models.ForeignKey(Gender, on_delete=models.SET_NULL, null=True)
wordclass = models.ForeignKey(Wordclass, on_delete=models.SET_NULL, null=True)
details = models.CharField(max_length=8192, blank=True)
etymology = models.CharField(max_length=8192, blank=True)
roots = models.ManyToManyField(
"self", on_delete=models.SET_NULL, blank=True)
roots = models.ManyToManyField("self")

def __str__(self):
return self.word

+ 3
- 0
dictionary/static/dictionary/style.css View File

@@ -0,0 +1,3 @@
* {
background: #ecf0f1;
}

+ 22
- 0
dictionary/templates/dictionary/base.html View File

@@ -0,0 +1,22 @@
{% load staticfiles %}
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'dictionary/style.css' %}" type="text/css" media="screen" />
{% block addhead %}{% endblock %}
</head>

<body>

{% if error_message %}
<p><strong>{{ error_message }}</strong></p>
{% endif %}
{% block body %}
{% endblock %}

</body>

</html>

+ 51
- 0
dictionary/templates/dictionary/details.html View File

@@ -0,0 +1,51 @@
{% extends 'dictionary/base.html' %}
{% load staticfiles %}

<!--
`word` is the main word of the page, Word
`translations` are all the words that translate `word` to other languages, Word[]
`from_lang` is the original language, Language
`to_lang` is the target language, Language
-->

{% block title %}{{ word.word }} - {{ from_lang.name }}{% endblock %}

{% block addhead %}
<link rel="stylesheet" href="{% static 'dictionary/details.css' %}" type="text/css" media="screen" />
{% endblock %}

{% block body %}
<word>{{ word.word }}</word>
<fromlang>Language: {{ from_lang.name }}</fromlang>
<gender>Gender: {{ word.gender }}</gender>
<wordclass>Word class:{{ word.class }} ({{ word.class.code }})</wordclass>
{% if translations %}
<listtrans>
<p>Translations of {{ word.word }} in {{ to_lang.name }}:</p>
<ul>
{% for translation in translations %}
<li>{{ translation.word }}</li>
<!--TODO: link to the word's page-->
{% endfor %}
</ul>
</listtrans>
{% endif %}

<transdetails>{{ word.details }}</transdetails>

{% if word.etymology %}
<etymology>
{% if word.roots.all %}
<roots>
<p>Etymological roots:</p>
<ul>
{% for root in word.roots.all %}
<li>{{ root.word }}</li>
<!--TODO: Link to the word's page-->
{% endfor %}
</ul>
</roots>
{% endif %}
</etymology>
{% endif %}
{% endblock %}

dict/tests.py → dictionary/tests.py View File


+ 44
- 0
dictionary/urls.py View File

@@ -0,0 +1,44 @@
from django.urls import path
from django.conf.urls import url
from . import views

app_name = 'dictionary'

urlpatterns = [

# choix du langage traduit et du langage de traduction
# /dictionary/
url(r'^$', views.index, name='index'),

# renvoie la liste des lettres initiales des mots de `from_lang` enregistrés
# et prépare le renvoi vers la liste des mots commençant par cette initiale
# traduits vers `to_lang`
# /dictionary/from=<from_lang>/to=<to_lang>/
# /dictionary/from=HJLP/to=FRA/
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/$',
views.indexlang,
name='listinitials'),

# renvoie la liste des mots de `from_lang` et leur traduction abrégée en
# `to_lang` commençant par la lettre `initial`
# /dictionary/from=<from_lang>/to=<to_lang>/init=<initial>
# /dictionary/from=HJLP/to=FRA/a
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/init=(?P<initial>\S)/$',
views.listwords,
name='listwords'),

# renvoie le détail de la traduction de `word` en `from_lang` vers
# `to_lang`
# /dictionary/from=<from_lang>/to=<to_lang>/word=<word>/
# /dictionary/from=HJLP/to=FRA/hj-lp/
url(r'^from=(?P<from_lang>[:alpha:]+)/to=(?P<to_lang>[:alpha:]+)/(?P<word>[^\/]+)/$',
views.details,
name='details'),

# renvoie cinq mots de `from_lang` commençant par `word`
# /dictionary/from=<from_lang>/guess/<word>/
# /dictionary/from=HJLP/guess/hj/
url(r'^from=(?P<from_lang>[:alpha:]+)/guess/(?P<word>[^\/]+)/$',
views.guessword,
name='guessword'),
]

+ 27
- 0
dictionary/views.py View File

@@ -0,0 +1,27 @@
from django.shortcuts import render
from django.utils.text import slugify
from .models import Language, Gender, Wordclass, Word


def index(request):
pass

def indexlang(request, from_lang, to_lang):
pass


def listwords(request, from_lang, to_lang, initial):
initial_lang = Language.objects.get(code=from_lang)
target_lang = Language.objects.get(code=to_lang)
words = Word.objects.filter(language=initial_lang).filter(
word__startswith(initial))


def details(request, from_lang, to_lang, word):
word = Word.objects.filter(language=from_lang).get(slug=slugify(word))
translations = word.translations.filter(language=to_lang)


def guessword(request, from_lang, word):
words = Word.object.filter(language=from_lang).filter(
slug__stratswith(slugify(word)))[:5]

+ 1
- 1
manage.py View File

@@ -3,7 +3,7 @@ import os
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'languephundrakfr.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'conlangdict.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc: