summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-13 03:29:33 +0200
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-10-13 03:29:44 +0200
commitb41b2bebc05585a6e374dafafae9bed2503becad (patch)
treebb8689bde958278f681f01de1906609c68221ee9
parentc5a8b2c72841ad0b58fb36870624737634778056 (diff)
I18N
-rw-r--r--kpov_judge/web/kpov_judge/babel.cfg3
-rwxr-xr-xkpov_judge/web/kpov_judge/kpov_judge.py27
-rw-r--r--kpov_judge/web/kpov_judge/templates/class_tasks.html6
-rw-r--r--kpov_judge/web/kpov_judge/templates/index.html9
-rw-r--r--kpov_judge/web/kpov_judge/templates/task_greeting.html23
-rw-r--r--kpov_judge/web/kpov_judge/translations/en/LC_MESSAGES/messages.po86
-rw-r--r--kpov_judge/web/kpov_judge/translations/sl/LC_MESSAGES/messages.po87
7 files changed, 216 insertions, 25 deletions
diff --git a/kpov_judge/web/kpov_judge/babel.cfg b/kpov_judge/web/kpov_judge/babel.cfg
new file mode 100644
index 0000000..f0234b3
--- /dev/null
+++ b/kpov_judge/web/kpov_judge/babel.cfg
@@ -0,0 +1,3 @@
+[python: **.py]
+[jinja2: **/templates/**.html]
+extensions=jinja2.ext.autoescape,jinja2.ext.with_
diff --git a/kpov_judge/web/kpov_judge/kpov_judge.py b/kpov_judge/web/kpov_judge/kpov_judge.py
index 4dfed7b..db2359d 100755
--- a/kpov_judge/web/kpov_judge/kpov_judge.py
+++ b/kpov_judge/web/kpov_judge/kpov_judge.py
@@ -1,18 +1,33 @@
#!/usr/bin/env python3
-import flask
-from flask import Flask, g, session, redirect, url_for, abort, render_template, flash, app, request, Response
-import pymongo
+import collections
+import datetime
import json
import random
import settings
-import datetime
-import kpov_util
-from kpov_draw_setup import draw_setup
import traceback
+from kpov_draw_setup import draw_setup
+import kpov_util
+
+import pymongo
+import flask
+from flask import Flask, g, session, redirect, url_for, abort, render_template, flash, app, request, Response
+from flask.ext.babel import Babel, gettext, ngettext
+import jinja2
+
app = Flask(__name__)
app.config.from_object(settings)
+babel = Babel(app)
+
+@babel.localeselector
+def get_locale():
+ # terrible hack, should store as user preference in the DB
+ if '/en/' in request.path:
+ return 'en'
+ if '/si/' in request.path:
+ return 'sl'
+ return request.accept_languages.best_match(['sl', 'en'])
dummy_task = """
def task(neznano_ime_naloge):
diff --git a/kpov_judge/web/kpov_judge/templates/class_tasks.html b/kpov_judge/web/kpov_judge/templates/class_tasks.html
index 050874b..4b6a523 100644
--- a/kpov_judge/web/kpov_judge/templates/class_tasks.html
+++ b/kpov_judge/web/kpov_judge/templates/class_tasks.html
@@ -4,10 +4,10 @@
<h1><a href="{{ url_for('index') }}" class="back">↩</a> {{clas.name}}</h1>
<p>
-Zdravo, {{student_id}}.
+{{ _('Zdravo, %(student)s.', student=student_id) }}
-<p>
-Trenutno so na voljo naloge:
+<section>
+<h1>{{ _('Naloge') }}</h1>
<ul>
{% for t in tasks %}
diff --git a/kpov_judge/web/kpov_judge/templates/index.html b/kpov_judge/web/kpov_judge/templates/index.html
index 49895b0..4c2ba47 100644
--- a/kpov_judge/web/kpov_judge/templates/index.html
+++ b/kpov_judge/web/kpov_judge/templates/index.html
@@ -4,14 +4,13 @@
<h1>KPOV Judge</h1>
<p>
-Zdravo, {{student_id}}.
+{{ _('Zdravo, %(student)s.', student=student_id) }}
-<p>
-Trenutno so na voljo predmeti:
+<section>
+<h1>{{ _('Predmeti') }}</h1>
<ul>
{% for c in classes %}
-<li><a href="{{url_for('class_tasks', class_id=c.class_id)}}">{{c.name}}</a></li>
+ <li><a href="{{url_for('class_tasks', class_id=c.class_id)}}">{{c.name}}</a>
{% endfor %}
</ul>
-</li>
diff --git a/kpov_judge/web/kpov_judge/templates/task_greeting.html b/kpov_judge/web/kpov_judge/templates/task_greeting.html
index 5a59fe0..086d6b1 100644
--- a/kpov_judge/web/kpov_judge/templates/task_greeting.html
+++ b/kpov_judge/web/kpov_judge/templates/task_greeting.html
@@ -10,6 +10,7 @@ img.setup {
max-width: 20em;
}
section.data {
+ clear: both;
columns: 2;
}
section.data > section {
@@ -37,14 +38,14 @@ section > ul {
{% include instructions %}
<p>
-<a href="howto/">Podrobna navodila (HOWTO)</a>
+<a href="howto/">{{ _('Podrobna navodila.') }}</a>
</section>
<section class="data">
<section class="disks">
-<h1>Računalniki</h1>
+<h1>{{ _('Računalniki') }}</h1>
<p>
-Slike diskov za to nalogo:
+{{ _('Slike diskov za to nalogo:') }}
{% for c in computers %}
<ul>
@@ -56,16 +57,16 @@ Slike diskov za to nalogo:
{% endfor %}
</ul>
{% else %}
- Slike navideznih diskov so v izdelavi in bodo kmalu na voljo.
+ <br>{{ _('Slike navideznih diskov so v izdelavi in bodo kmalu na voljo.') }}
{% endif %}
</ul>
{% endfor %}
<section>
{% if backing_images %}
-<h1>Osnovne slike</h1>
+<h1>{{ _('Osnovne slike') }}</h1>
<p>
-Te slike so enake za vse naloge in jih prenesete samo enkrat.
+{{ _('Te slike so enake za vse naloge. Prenesite samo tiste, ki jih še nimate.') }}
<ul>
{% for b in backing_images %}
@@ -77,14 +78,14 @@ Te slike so enake za vse naloge in jih prenesete samo enkrat.
</section>
<section>
-<h1>Rezultati</h1>
+<h1>{{ _('Rezultati') }}</h1>
<p>
-Ogledate si lahko:
+{{ _('Ogledate si lahko:') }}
<ul>
-<li><a href='results.html'>rezultate</a> (<a href='../results.json'>json</a>)</li>
-<li><a href='params.html'>parametre</a> (<a href='../params.json'>json</a>, <a href='../params_meta.json'>opisi parametrov</a>)</li>
-<li><a href='../task.html'>preverjalni program</a> (<a href='../task.py'>source</a>)</li>
+<li><a href='results.html'>{{ _('rezultate') }}</a> (<a href='../results.json'>json</a>)</li>
+<li><a href='params.html'>{{ _('parametre') }}</a> (<a href='../params.json'>json</a>, <a href='../params_meta.json'>{{ _('opisi parametrov') }}</a>)</li>
+<li><a href='../task.html'>{{ _('preverjalni program') }}</a> (<a href='../task.py'>source</a>)</li>
</ul>
</p>
diff --git a/kpov_judge/web/kpov_judge/translations/en/LC_MESSAGES/messages.po b/kpov_judge/web/kpov_judge/translations/en/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..9708420
--- /dev/null
+++ b/kpov_judge/web/kpov_judge/translations/en/LC_MESSAGES/messages.po
@@ -0,0 +1,86 @@
+# English translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2018-10-13 02:41+0200\n"
+"PO-Revision-Date: 2018-10-13 02:29+0200\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: en <LL@li.org>\n"
+"Plural-Forms: nplurals=2; plural=(n != 1)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 1.3\n"
+
+#: templates/class_tasks.html:7 templates/index.html:7
+#, python-format
+msgid "Zdravo, %(student)s."
+msgstr "Hi, %(student)s."
+
+#: templates/class_tasks.html:10
+msgid "Naloge"
+msgstr "Tasks"
+
+#: templates/index.html:10
+msgid "Predmeti"
+msgstr "Classes"
+
+#: templates/task_greeting.html:41
+msgid "Podrobna navodila."
+msgstr "Detalied instructions."
+
+#: templates/task_greeting.html:46
+msgid "Računalniki"
+msgstr "Computers"
+
+#: templates/task_greeting.html:48
+msgid "Slike diskov za to nalogo:"
+msgstr "Disk images for this task:"
+
+#: templates/task_greeting.html:60
+msgid "Slike navideznih diskov so v izdelavi in bodo kmalu na voljo."
+msgstr "Disk images are being generated, please wait."
+
+#: templates/task_greeting.html:67
+msgid "Osnovne slike"
+msgstr "Backing images"
+
+#: templates/task_greeting.html:69
+msgid "Te slike so enake za vse naloge. Prenesite samo tiste, ki jih še nimate."
+msgstr "These disk images are the same for all exercises. Download only those you don’t have yet."
+
+#: templates/task_greeting.html:81
+msgid "Rezultati"
+msgstr "Results"
+
+#: templates/task_greeting.html:83
+msgid "Ogledate si lahko:"
+msgstr "You can view:"
+
+#: templates/task_greeting.html:86
+msgid "rezultate"
+msgstr "results"
+
+#: templates/task_greeting.html:87
+msgid "parametre"
+msgstr "parameters"
+
+#: templates/task_greeting.html:87
+msgid "opisi parametrov"
+msgstr "parameter descriptions"
+
+#: templates/task_greeting.html:88
+msgid "preverjalni program"
+msgstr "checking program"
+
+#~ msgid "Trenutno so na voljo naloge:"
+#~ msgstr "Available tasks:"
+
+#~ msgid "Trenutno so na voljo predmeti:"
+#~ msgstr "Available classes"
+
diff --git a/kpov_judge/web/kpov_judge/translations/sl/LC_MESSAGES/messages.po b/kpov_judge/web/kpov_judge/translations/sl/LC_MESSAGES/messages.po
new file mode 100644
index 0000000..7027a4c
--- /dev/null
+++ b/kpov_judge/web/kpov_judge/translations/sl/LC_MESSAGES/messages.po
@@ -0,0 +1,87 @@
+# Slovenian translations for PROJECT.
+# Copyright (C) 2018 ORGANIZATION
+# This file is distributed under the same license as the PROJECT project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2018.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
+"POT-Creation-Date: 2018-10-13 02:41+0200\n"
+"PO-Revision-Date: 2018-10-13 02:29+0200\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: sl <LL@li.org>\n"
+"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 "
+"|| n%100==4 ? 2 : 3)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 1.3\n"
+
+#: templates/class_tasks.html:7 templates/index.html:7
+#, python-format
+msgid "Zdravo, %(student)s."
+msgstr ""
+
+#: templates/class_tasks.html:10
+msgid "Naloge"
+msgstr ""
+
+#: templates/index.html:10
+msgid "Predmeti"
+msgstr ""
+
+#: templates/task_greeting.html:41
+msgid "Podrobna navodila."
+msgstr ""
+
+#: templates/task_greeting.html:46
+msgid "Računalniki"
+msgstr ""
+
+#: templates/task_greeting.html:48
+msgid "Slike diskov za to nalogo:"
+msgstr ""
+
+#: templates/task_greeting.html:60
+msgid "Slike navideznih diskov so v izdelavi in bodo kmalu na voljo."
+msgstr ""
+
+#: templates/task_greeting.html:67
+msgid "Osnovne slike"
+msgstr ""
+
+#: templates/task_greeting.html:69
+msgid "Te slike so enake za vse naloge. Prenesite samo tiste, ki jih še nimate."
+msgstr ""
+
+#: templates/task_greeting.html:81
+msgid "Rezultati"
+msgstr ""
+
+#: templates/task_greeting.html:83
+msgid "Ogledate si lahko:"
+msgstr ""
+
+#: templates/task_greeting.html:86
+msgid "rezultate"
+msgstr ""
+
+#: templates/task_greeting.html:87
+msgid "parametre"
+msgstr ""
+
+#: templates/task_greeting.html:87
+msgid "opisi parametrov"
+msgstr ""
+
+#: templates/task_greeting.html:88
+msgid "preverjalni program"
+msgstr ""
+
+#~ msgid "Trenutno so na voljo naloge:"
+#~ msgstr ""
+
+#~ msgid "Trenutno so na voljo predmeti:"
+#~ msgstr ""
+