diff options
Diffstat (limited to 'weblog')
-rwxr-xr-x | weblog/locale/es/LC_MESSAGES/django.mo | bin | 3534 -> 3595 bytes | |||
-rwxr-xr-x | weblog/locale/es/LC_MESSAGES/django.po | 26 | ||||
-rwxr-xr-x | weblog/locale/ru/LC_MESSAGES/django.mo | bin | 4447 -> 4530 bytes | |||
-rwxr-xr-x | weblog/locale/ru/LC_MESSAGES/django.po | 26 | ||||
-rwxr-xr-x | weblog/static/weblog/js/weblog.js | 2 | ||||
-rwxr-xr-x | weblog/templates/weblog/post.html | 22 | ||||
-rwxr-xr-x | weblog/urls.py | 1 | ||||
-rwxr-xr-x | weblog/views.py | 24 |
8 files changed, 70 insertions, 31 deletions
diff --git a/weblog/locale/es/LC_MESSAGES/django.mo b/weblog/locale/es/LC_MESSAGES/django.mo Binary files differindex 51b607c..bb29fdf 100755 --- a/weblog/locale/es/LC_MESSAGES/django.mo +++ b/weblog/locale/es/LC_MESSAGES/django.mo diff --git a/weblog/locale/es/LC_MESSAGES/django.po b/weblog/locale/es/LC_MESSAGES/django.po index b3b69ff..ef7e1ef 100755 --- a/weblog/locale/es/LC_MESSAGES/django.po +++ b/weblog/locale/es/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-31 14:31+0300\n" +"POT-Creation-Date: 2018-07-17 23:24+0300\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" @@ -36,7 +36,7 @@ msgctxt "Post category" msgid "Category" msgstr "Categoría" -#: models.py:20 models.py:46 templates/weblog/post.html:16 +#: models.py:20 models.py:46 templates/weblog/post.html:28 #: templates/weblog/sidebar_categories.html:3 msgctxt "Post categories" msgid "Categories" @@ -131,7 +131,7 @@ msgid "Comments" msgstr "Comentarios" #: templates/weblog/index.html:6 templatetags/weblog_extras.py:43 views.py:94 -#: views.py:178 +#: views.py:181 msgctxt "Posts without category" msgid "Uncategorized" msgstr "Sin categoría" @@ -209,28 +209,32 @@ msgstr "Última" msgid "Nothing has been posted yet." msgstr "No hay ninguna publicación." -#: templates/weblog/post.html:24 +#: templates/weblog/post.html:12 +msgid "Read in another language" +msgstr "Leer en otro idioma" + +#: templates/weblog/post.html:36 msgid "Leave a comment" msgstr "Dejar un comentario" -#: templates/weblog/post.html:31 +#: templates/weblog/post.html:43 msgid "Submit comment" msgstr "Enviar comentario" -#: templates/weblog/post.html:35 +#: templates/weblog/post.html:47 msgid "To leave a comment you need to sign in" msgstr "Para poder comentar, necesitar iniciar sesión." -#: templates/weblog/post.html:47 +#: templates/weblog/post.html:59 msgid "Comment submited successfully" msgstr "Comentario enviado exitosamente" -#: templates/weblog/post.html:54 +#: templates/weblog/post.html:66 msgctxt "Unauthenticated comment poster" msgid "Anonymous" msgstr "Anónimo" -#: templates/weblog/post.html:62 +#: templates/weblog/post.html:74 msgid "Nobody has left a comment on this post yet" msgstr "No hay ningún comentario relacionado a esta entrada" @@ -287,11 +291,11 @@ msgstr "" msgid "December" msgstr "" -#: views.py:199 +#: views.py:202 msgid "You need to sign in to submit a comment" msgstr "Para poder comentar necesita iniciar sesión" -#: views.py:201 +#: views.py:204 msgid "Error submitting comment: Invalid data" msgstr "Error al intentar enviar el comentario: Información invalida" diff --git a/weblog/locale/ru/LC_MESSAGES/django.mo b/weblog/locale/ru/LC_MESSAGES/django.mo Binary files differindex 723a8e1..f9de0a0 100755 --- a/weblog/locale/ru/LC_MESSAGES/django.mo +++ b/weblog/locale/ru/LC_MESSAGES/django.mo diff --git a/weblog/locale/ru/LC_MESSAGES/django.po b/weblog/locale/ru/LC_MESSAGES/django.po index 6af07da..fc5e897 100755 --- a/weblog/locale/ru/LC_MESSAGES/django.po +++ b/weblog/locale/ru/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-05-31 14:31+0300\n" +"POT-Creation-Date: 2018-07-17 23:24+0300\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" @@ -38,7 +38,7 @@ msgctxt "Post category" msgid "Category" msgstr "Категория" -#: models.py:20 models.py:46 templates/weblog/post.html:16 +#: models.py:20 models.py:46 templates/weblog/post.html:28 #: templates/weblog/sidebar_categories.html:3 msgctxt "Post categories" msgid "Categories" @@ -131,7 +131,7 @@ msgid "Comments" msgstr "Комментарии" #: templates/weblog/index.html:6 templatetags/weblog_extras.py:43 views.py:94 -#: views.py:178 +#: views.py:181 msgctxt "Posts without category" msgid "Uncategorized" msgstr "Без категории" @@ -209,28 +209,32 @@ msgstr "Последняя" msgid "Nothing has been posted yet." msgstr "Нет записи на данный момент." -#: templates/weblog/post.html:24 +#: templates/weblog/post.html:12 +msgid "Read in another language" +msgstr "Читать на другом языке" + +#: templates/weblog/post.html:36 msgid "Leave a comment" msgstr "Оставьте комментарий" -#: templates/weblog/post.html:31 +#: templates/weblog/post.html:43 msgid "Submit comment" msgstr "Отправить комметарий" -#: templates/weblog/post.html:35 +#: templates/weblog/post.html:47 msgid "To leave a comment you need to sign in" msgstr "Для того чтобы оставить комментарий, зайдите в свою учетную запись" -#: templates/weblog/post.html:47 +#: templates/weblog/post.html:59 msgid "Comment submited successfully" msgstr "Ваш комментарий был успешно отправлен" -#: templates/weblog/post.html:54 +#: templates/weblog/post.html:66 msgctxt "Unauthenticated comment poster" msgid "Anonymous" msgstr "Анонимный" -#: templates/weblog/post.html:62 +#: templates/weblog/post.html:74 msgid "Nobody has left a comment on this post yet" msgstr "У этой записи нет комментарии." @@ -287,11 +291,11 @@ msgstr "" msgid "December" msgstr "" -#: views.py:199 +#: views.py:202 msgid "You need to sign in to submit a comment" msgstr "Для того чтобы оставить комментарий, зайдите в свою учетную запись" -#: views.py:201 +#: views.py:204 msgid "Error submitting comment: Invalid data" msgstr "Ошибка: неправильный формат данных" diff --git a/weblog/static/weblog/js/weblog.js b/weblog/static/weblog/js/weblog.js index b802841..164cc3b 100755 --- a/weblog/static/weblog/js/weblog.js +++ b/weblog/static/weblog/js/weblog.js @@ -10,4 +10,4 @@ function toggleNode(caller){ $(caller).attr('node-state', 'closed'); } $('#'+target).toggle(); -}
\ No newline at end of file +} diff --git a/weblog/templates/weblog/post.html b/weblog/templates/weblog/post.html index 364e17c..0459744 100755 --- a/weblog/templates/weblog/post.html +++ b/weblog/templates/weblog/post.html @@ -5,6 +5,18 @@ <div class="container-fluid blogpost"> <h2>{% if post_translation %}{{ post_translation.title }}{% else %}{{ post.title }}{% endif %}</h2> <p class="publish-info">{% blocktrans with publish_date=post.publish_date %}Published on {{ publish_date }}{% endblocktrans %}{% if post_author %}{% blocktrans with author=post_author context 'Written by (Author)' %}, by {{ author }}{% endblocktrans %}{% endif %}</p> + {% if post_languages %} + <form> + <div class="form-group"> + <select class="form-control" id="post-languages" name="post-language" onchange="changeLang(this.value)"> + <option disabled selected>{% trans 'Read in another language' %}</option> + {% for lang in post_languages %} + <option value="{{ lang.0 }}">{{ lang.1 }}</option> + {% endfor %} + </select> + </div> + </form> + {% endif %} <hr> {% if post_translation %} {{ post_translation.content|safe }} @@ -13,7 +25,7 @@ {% endif %} {% if post_categories %} <hr> - <p>{% trans 'Categories' context 'Post categories' %}: + <p>{% trans 'Categories' context 'Post categories' %}: {% for post_category in post_categories %} <a class="label label-info" href="{% url 'weblog:CategoryIndex' category_slug=post_category.slug %}">{{ post_category.name }}</a> {% endfor %} @@ -64,4 +76,10 @@ {% endif %} {% endif %} </div> -{% endblock %}
\ No newline at end of file +<script> + function changeLang(lang){ + window.location = "{{ post_url }}"+lang; + } +</script> +{% endblock %} + diff --git a/weblog/urls.py b/weblog/urls.py index b3e95b1..ddc2c9f 100755 --- a/weblog/urls.py +++ b/weblog/urls.py @@ -20,4 +20,5 @@ urlpatterns += [ url(r'^(?P<year>[0-9]{4})/(?P<month>[0-9]{1,2})/$', views.Index, name='ArchiveIndex'),
url(r'^(?P<category_slug>[-\w]+)/$', views.Index, name='CategoryIndex'),
url(r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/$', views.PostView, name='PostView'),
+ url(r'^(?P<category_slug>[-\w]+)/(?P<post_slug>[-\w]+)/(?P<language>[-\w]+)/$', views.PostView, name='TranslationView'),
]
diff --git a/weblog/views.py b/weblog/views.py index e082d05..95558fc 100755 --- a/weblog/views.py +++ b/weblog/views.py @@ -47,7 +47,7 @@ def Index(request, **kwargs): all_pages = all_pages.filter(published=True, publish_date__lte=now, publish_date__month=month) context_dict['breadcrumbs'].append({'url': reverse('weblog:ArchiveIndex', kwargs={'year': year, 'month': month}), 'name': MONTHS[int(month)-1]}) - # Check how many blog posts are there in total, to calculate into how many pages + # Check how many blog posts there are in total, to calculate into how many pages # the index needs to be divided post_count = all_pages.count() if post_count < 1: @@ -153,10 +153,13 @@ def Index(request, **kwargs): return render(request, 'weblog/index.html', context_dict) -def PostView(request, category_slug, post_slug): +def PostView(request, category_slug, post_slug, language=None): + if language and not IS_MULTILINGUAL: + redirect('weblog:PostView', category_slug=category_slug, post_slug=post_slug) post = get_object_or_404(BlogPost, slug=post_slug) context_dict = blog_settings.copy() context_dict['comment_form'] = PostCommentForm() + context_dict['post_url'] = post.get_absolute_url() post_translations = Translation.objects.filter(post=post) category = None current_language = translation.get_language() @@ -214,12 +217,21 @@ def PostView(request, category_slug, post_slug): return render(request, 'weblog/post.html', context_dict) orig_lang = post.original_language if len(orig_lang) < 2: - orig_lang = settings.LANGUAGE_CODE[0:2] - context_dict['languages'] = [orig_lang,] + orig_lang = settings.LANGUAGE_CODE[:2] + context_dict['post_languages'] = [] + post_languages = [] for post_translation in post_translations: - context_dict['languages'].append(post_translation.language) - if current_language[0:2] == post_translation.language[0:2]: + post_languages.append(post_translation.language[:2].lower()) + if language and language == post_translation.language[0:2]: context_dict['post_translation'] = post_translation + elif current_language[0:2] == post_translation.language[0:2]: + context_dict['post_translation'] = post_translation + for lang in settings.LANGUAGES: + if lang[0][:2] == orig_lang.lower(): + context_dict['post_languages'].append(lang) + continue + if lang[0][:2] in post_languages: + context_dict['post_languages'].append(lang) if 'post_translation' in context_dict: context_dict['breadcrumbs'].append({'url': post.get_absolute_url(), 'name': post_translation.title}) else: |