From b41b2bebc05585a6e374dafafae9bed2503becad Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sat, 13 Oct 2018 03:29:33 +0200 Subject: I18N --- kpov_judge/web/kpov_judge/babel.cfg | 3 + kpov_judge/web/kpov_judge/kpov_judge.py | 27 +++++-- .../web/kpov_judge/templates/class_tasks.html | 6 +- kpov_judge/web/kpov_judge/templates/index.html | 9 +-- .../web/kpov_judge/templates/task_greeting.html | 23 +++--- .../translations/en/LC_MESSAGES/messages.po | 86 +++++++++++++++++++++ .../translations/sl/LC_MESSAGES/messages.po | 87 ++++++++++++++++++++++ 7 files changed, 216 insertions(+), 25 deletions(-) create mode 100644 kpov_judge/web/kpov_judge/babel.cfg create mode 100644 kpov_judge/web/kpov_judge/translations/en/LC_MESSAGES/messages.po create mode 100644 kpov_judge/web/kpov_judge/translations/sl/LC_MESSAGES/messages.po (limited to 'kpov_judge/web') 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 @@

{{clas.name}}

-Zdravo, {{student_id}}. +{{ _('Zdravo, %(student)s.', student=student_id) }} -

-Trenutno so na voljo naloge: +

+

{{ _('Naloge') }}

{% endfor %}
{% if backing_images %} -

Osnovne slike

+

{{ _('Osnovne slike') }}

-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.') }}

    {% for b in backing_images %} @@ -77,14 +78,14 @@ Te slike so enake za vse naloge in jih prenesete samo enkrat.
-

Rezultati

+

{{ _('Rezultati') }}

-Ogledate si lahko: +{{ _('Ogledate si lahko:') }}

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 , 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 \n" +"Language-Team: en \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 , 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 \n" +"Language-Team: sl \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 "" + -- cgit v1.2.1