From db5388e47885b76083ee6a169863b5e718ca1246 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 6 Oct 2016 15:02:40 +0200 Subject: Make pelican-bootstrap3 multilingual This makes use of the i18n jinja extension as described in README.md. A Makefile is provided to facilitate new translations. A translation to German is also included. --- pelican-bootstrap3/Makefile | 19 + pelican-bootstrap3/README.md | 12 +- pelican-bootstrap3/babel.cfg | 1 + pelican-bootstrap3/i18n.patch | 832 +++++++++++++++++++++ pelican-bootstrap3/messages.pot | 148 ++++ pelican-bootstrap3/templates/archives.html | 6 +- pelican-bootstrap3/templates/article.html | 2 +- pelican-bootstrap3/templates/article_list.html | 2 +- pelican-bootstrap3/templates/author.html | 4 +- pelican-bootstrap3/templates/authors.html | 6 +- pelican-bootstrap3/templates/base.html | 2 +- pelican-bootstrap3/templates/categories.html | 6 +- pelican-bootstrap3/templates/category.html | 2 +- pelican-bootstrap3/templates/includes/aboutme.html | 4 +- .../templates/includes/article_info.html | 8 +- .../templates/includes/cc-license.html | 6 +- .../templates/includes/comment_count.html | 2 +- .../templates/includes/comments.html | 2 +- pelican-bootstrap3/templates/includes/footer.html | 6 +- pelican-bootstrap3/templates/includes/links.html | 4 +- .../templates/includes/pagination.html | 10 +- pelican-bootstrap3/templates/includes/sidebar.html | 14 +- pelican-bootstrap3/templates/includes/taglist.html | 2 +- .../templates/includes/translations.html | 4 +- pelican-bootstrap3/templates/search.html | 2 +- pelican-bootstrap3/templates/tags.html | 2 +- .../translations/de/LC_MESSAGES/messages.mo | Bin 0 -> 1648 bytes .../translations/de/LC_MESSAGES/messages.po | 151 ++++ 28 files changed, 1210 insertions(+), 49 deletions(-) create mode 100644 pelican-bootstrap3/Makefile create mode 100644 pelican-bootstrap3/babel.cfg create mode 100644 pelican-bootstrap3/i18n.patch create mode 100644 pelican-bootstrap3/messages.pot create mode 100644 pelican-bootstrap3/translations/de/LC_MESSAGES/messages.mo create mode 100644 pelican-bootstrap3/translations/de/LC_MESSAGES/messages.po diff --git a/pelican-bootstrap3/Makefile b/pelican-bootstrap3/Makefile new file mode 100644 index 0000000..aa45c0d --- /dev/null +++ b/pelican-bootstrap3/Makefile @@ -0,0 +1,19 @@ +help: + @echo 'Makefile for translation ' + @echo ' ' + @echo 'Usage: ' + @echo ' make extract Extract message strings ' + @echo ' make update Extract strings and update po files ' + @echo ' make compile Compile po files to mo files ' + @echo ' ' + +extract: + pybabel extract --mapping babel.cfg --output messages.pot ./ + +update: extract + pybabel update --input-file messages.pot --output-dir translations/ --domain messages + +compile: + pybabel compile --directory translations/ --domain messages + +.PHONY: help extract update compile diff --git a/pelican-bootstrap3/README.md b/pelican-bootstrap3/README.md index 00ed5d3..c53c1d7 100644 --- a/pelican-bootstrap3/README.md +++ b/pelican-bootstrap3/README.md @@ -21,7 +21,12 @@ First: Then: -Point the `THEME` variable in your `pelicanconf.py` to `/path/to/pelican-bootstrap3` +Point the `THEME` variable in your `pelicanconf.py` to +`/path/to/pelican-bootstrap3` and add + +`JINJA_EXTENSIONS = ['jinja2.ext.i18n']` + +to your Pelican configuration, as this template can be translated (see below). ## Usage @@ -347,6 +352,11 @@ Originally developed for including certification marks in your sidebar. E.g., http://dmark.github.io +### Translations + +This template can be translated using pybabel and the enclosed Makefile. See +[Localizing themes with Jinja2](https://github.com/getpelican/pelican-plugins/blob/master/i18n_subsites/localizing_using_jinja2.rst) for more details and pointers. + ## Live example [This is the website of the original author](http://dandydev.net) diff --git a/pelican-bootstrap3/babel.cfg b/pelican-bootstrap3/babel.cfg new file mode 100644 index 0000000..2274808 --- /dev/null +++ b/pelican-bootstrap3/babel.cfg @@ -0,0 +1 @@ +[jinja2: templates/**.html] diff --git a/pelican-bootstrap3/i18n.patch b/pelican-bootstrap3/i18n.patch new file mode 100644 index 0000000..b64eb7c --- /dev/null +++ b/pelican-bootstrap3/i18n.patch @@ -0,0 +1,832 @@ +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..aa45c0d +--- /dev/null ++++ b/Makefile +@@ -0,0 +1,19 @@ ++help: ++ @echo 'Makefile for translation ' ++ @echo ' ' ++ @echo 'Usage: ' ++ @echo ' make extract Extract message strings ' ++ @echo ' make update Extract strings and update po files ' ++ @echo ' make compile Compile po files to mo files ' ++ @echo ' ' ++ ++extract: ++ pybabel extract --mapping babel.cfg --output messages.pot ./ ++ ++update: extract ++ pybabel update --input-file messages.pot --output-dir translations/ --domain messages ++ ++compile: ++ pybabel compile --directory translations/ --domain messages ++ ++.PHONY: help extract update compile +diff --git a/README.md b/README.md +index 1ddb48a..7e7a260 100644 +--- a/README.md ++++ b/README.md +@@ -17,7 +17,12 @@ First: + + Then: + +-Point the `THEME` variable in your `pelicanconf.py` to `/path/to/pelican-bootstrap3` ++Point the `THEME` variable in your `pelicanconf.py` to ++`/path/to/pelican-bootstrap3` and add ++ ++`JINJA_EXTENSIONS = ['jinja2.ext.i18n']` ++ ++to your Pelican configuration, as this template can be translated (see below). + + ## Usage + +@@ -296,6 +301,11 @@ Include a series of images in the sidebar. + + SIDEBAR_IMAGES = ["/path/to/image1.png", "/path/to/image2.png"] + ++### Translations ++ ++This template can be translated using pybabel and the enclosed Makefile. See ++[Localizing themes with Jinja2](https://github.com/getpelican/pelican-plugins/blob/master/i18n_subsites/localizing_using_jinja2.rst) for more details and pointers. ++ + ## Live example + + [This is my website](http://dandydev.net) +diff --git a/babel.cfg b/babel.cfg +new file mode 100644 +index 0000000..2274808 +--- /dev/null ++++ b/babel.cfg +@@ -0,0 +1 @@ ++[jinja2: templates/**.html] +diff --git a/messages.pot b/messages.pot +new file mode 100644 +index 0000000..8730b65 +--- /dev/null ++++ b/messages.pot +@@ -0,0 +1,148 @@ ++# Translations template for PROJECT. ++# Copyright (C) 2016 ORGANIZATION ++# This file is distributed under the same license as the PROJECT project. ++# FIRST AUTHOR , 2016. ++# ++#, fuzzy ++msgid "" ++msgstr "" ++"Project-Id-Version: PROJECT VERSION\n" ++"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" ++"POT-Creation-Date: 2016-01-08 00:30+0100\n" ++"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" ++"Last-Translator: FULL NAME \n" ++"Language-Team: LANGUAGE \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/archives.html:2 templates/archives.html:7 templates/base.html:147 ++msgid "Archives" ++msgstr "" ++ ++#: templates/archives.html:14 ++msgid "Archives for" ++msgstr "" ++ ++#: templates/article.html:77 ++msgid "Permalink to" ++msgstr "" ++ ++#: templates/article_list.html:14 ++msgid "more" ++msgstr "" ++ ++#: templates/author.html:3 ++msgid "Articles by" ++msgstr "" ++ ++#: templates/author.html:9 templates/authors.html:3 templates/authors.html:9 ++msgid "Authors" ++msgstr "" ++ ++#: templates/authors.html:15 ++msgid "Authors on" ++msgstr "" ++ ++#: templates/categories.html:2 templates/categories.html:8 ++#: templates/category.html:11 templates/includes/sidebar.html:45 ++msgid "Categories" ++msgstr "" ++ ++#: templates/categories.html:15 ++msgid "All Categories for" ++msgstr "" ++ ++#: templates/search.html:4 ++msgid "Search" ++msgstr "" ++ ++#: templates/tags.html:16 ++msgid "Tags for" ++msgstr "" ++ ++#: templates/includes/aboutme.html:8 ++msgid "About" ++msgstr "" ++ ++#: templates/includes/article_info.html:8 ++msgid "Modified" ++msgstr "" ++ ++#: templates/includes/article_info.html:17 templates/includes/sidebar.html:80 ++msgid "Series" ++msgstr "" ++ ++#: templates/includes/article_info.html:24 ++msgid "By" ++msgstr "" ++ ++#: templates/includes/article_info.html:30 ++msgid "Category" ++msgstr "" ++ ++#: templates/includes/cc-license.html:62 ++msgid "Content" ++msgstr "" ++ ++#: templates/includes/cc-license.html:64 ++msgid "licensed under a" ++msgstr "" ++ ++#: templates/includes/cc-license.html:64 ++msgid "except where indicated otherwise" ++msgstr "" ++ ++#: templates/includes/comment_count.html:1 ++msgid "View comments" ++msgstr "" ++ ++#: templates/includes/comments.html:4 ++msgid "Comments" ++msgstr "" ++ ++#: templates/includes/footer.html:11 ++msgid "Powered by" ++msgstr "" ++ ++#: templates/includes/footer.html:21 ++msgid "Back to top" ++msgstr "" ++ ++#: templates/includes/links.html:2 ++msgid "Links" ++msgstr "" ++ ++#: templates/includes/pagination.html:5 templates/includes/pagination.html:7 ++msgid "Newer" ++msgstr "" ++ ++#: templates/includes/pagination.html:11 templates/includes/pagination.html:13 ++msgid "Older" ++msgstr "" ++ ++#: templates/includes/sidebar.html:8 ++msgid "Social" ++msgstr "" ++ ++#: templates/includes/sidebar.html:31 ++msgid "Recent Posts" ++msgstr "" ++ ++#: templates/includes/sidebar.html:64 templates/includes/taglist.html:2 ++msgid "Tags" ++msgstr "" ++ ++#: templates/includes/sidebar.html:84 ++msgid "Previous article" ++msgstr "" ++ ++#: templates/includes/sidebar.html:90 ++msgid "Next article" ++msgstr "" ++ ++#: templates/includes/translations.html:3 ++msgid "Lang" ++msgstr "" ++ +diff --git a/templates/archives.html b/templates/archives.html +index 8875de0..2a8dcfc 100644 +--- a/templates/archives.html ++++ b/templates/archives.html +@@ -1,17 +1,17 @@ + {% extends "base.html" %} +-{% block title %}Archives - {{ SITENAME }}{% endblock %} ++{% block title %}{{ _('Archives') }} - {{ SITENAME }}{% endblock %} + {% block breadcrumbs %} + {% if DISPLAY_BREADCRUMBS %} + + {% endif %} + {% endblock %} + + {% block content %} +
+-

Archives for {{ SITENAME }}

++

{{ _('Archives for') }} {{ SITENAME }}

+
+ {% for article in dates %} +

+diff --git a/templates/article.html b/templates/article.html +index 4cb6a70..957d9e7 100644 +--- a/templates/article.html ++++ b/templates/article.html +@@ -74,7 +74,7 @@ +

+ ++ title="{{ _('Permalink to') }} {{ article.title|striptags }}"> + {{ article.title }} + +

+diff --git a/templates/article_list.html b/templates/article_list.html +index 2d3c8cd..885a880 100644 +--- a/templates/article_list.html ++++ b/templates/article_list.html +@@ -11,7 +11,7 @@ + {% endif %} +
{{ article.summary }} + {% include 'includes/comment_count.html' %} +- more ... ++ {{ _('more') }} ... +
+ +
+diff --git a/templates/author.html b/templates/author.html +index 07dab6e..72cff95 100644 +--- a/templates/author.html ++++ b/templates/author.html +@@ -1,12 +1,12 @@ + {% extends "article_list.html" %} + +-{% block title %}Articles by {{ author }} - {{ SITENAME }}{% endblock %} ++{% block title %}{{ _('Articles by') }} {{ author }} - {{ SITENAME }}{% endblock %} + + {% block breadcrumbs %} + {% if DISPLAY_BREADCRUMBS %} + + {% endif %} +diff --git a/templates/authors.html b/templates/authors.html +index 9aa93ac..54589bf 100644 +--- a/templates/authors.html ++++ b/templates/authors.html +@@ -1,18 +1,18 @@ + {% extends "base.html" %} + +-{% block title %}Authors - {{ SITENAME }}{% endblock %} ++{% block title %}{{ _('Authors') }} - {{ SITENAME }}{% endblock %} + + {% block breadcrumbs %} + {% if DISPLAY_BREADCRUMBS %} + + {% endif %} + {% endblock %} + + {% block content %} +-

Authors on {{ SITENAME }}

++

{{ _('Authors on') }} {{ SITENAME }}

+ {% for author, articles in authors|sort %} +
  • {{ author }} ({{ articles|count }})
  • + {% endfor %} +diff --git a/templates/base.html b/templates/base.html +index 610d050..23fb8a2 100644 +--- a/templates/base.html ++++ b/templates/base.html +@@ -144,7 +144,7 @@ + + + {% endif %} +-
  • Archives
  • ++
  • {{ _('Archives') }}
  • + +
    + +diff --git a/templates/categories.html b/templates/categories.html +index 6898f97..6f3e8f5 100644 +--- a/templates/categories.html ++++ b/templates/categories.html +@@ -1,18 +1,18 @@ + {% extends "base.html" %} +-{% block title %}Categories - {{ SITENAME }}{% endblock %} ++{% block title %}{{ _('Categories') }} - {{ SITENAME }}{% endblock %} + + {% block breadcrumbs %} + {% if DISPLAY_BREADCRUMBS %} + + {% endif %} + {% endblock %} + + {% block content %} +
    +-

    All Categories for {{ SITENAME }}

    ++

    {{ _('All Categories for') }} {{ SITENAME }}

    +
    + {% for category, articles in categories %} +
    +diff --git a/templates/category.html b/templates/category.html +index 0eac7dd..bf87bf5 100644 +--- a/templates/category.html ++++ b/templates/category.html +@@ -8,7 +8,7 @@ + {% if DISPLAY_BREADCRUMBS %} + + {% endif %} +diff --git a/templates/includes/aboutme.html b/templates/includes/aboutme.html +index f38f0bc..01a940f 100644 +--- a/templates/includes/aboutme.html ++++ b/templates/includes/aboutme.html +@@ -5,7 +5,7 @@ +

    + {% endif %} +

    +- About {{ AUTHOR }}
    ++ {{ _('About') }} {{ AUTHOR }}
    + {{ ABOUT_ME }} +

    +-
    +\ No newline at end of file ++
    +diff --git a/templates/includes/article_info.html b/templates/includes/article_info.html +index e0c93b5..1cb85d5 100644 +--- a/templates/includes/article_info.html ++++ b/templates/includes/article_info.html +@@ -5,7 +5,7 @@ + + {% if SHOW_DATE_MODIFIED %} + {% if article.modified %} +- Modified ++ {{ _('Modified') }} + + + +@@ -14,20 +14,20 @@ + + {% if SHOW_SERIES %} + {% if article.series %} +- Series ++ {{ _('Series') }} + Part {{ article.series.index}} of {{ article.series.name }} + {% endif %} + {% endif %} + + {% if SHOW_ARTICLE_AUTHOR %} + {% if article.author %} +- By ++ {{ _('By') }} + {{ article.author }} + {% endif %} + {% endif %} + + {% if SHOW_ARTICLE_CATEGORY %} +- Category ++ {{ _('Category') }} + {{ article.category }} + {% endif %} + +diff --git a/templates/includes/cc-license.html b/templates/includes/cc-license.html +index c64f265..42234f6 100644 +--- a/templates/includes/cc-license.html ++++ b/templates/includes/cc-license.html +@@ -54,12 +54,12 @@ + {% endif %} + {% endif %} + {% set cc_title, cc_uri, cc_icon = ("Creative Commons AttributionCCSUFFIX 4.0 International License","http://creativecommons.org/licenses/CCNAME/4.0/","//i.creativecommons.org/l/CCNAME/4.0/80x15.png") %} +- Creative Commons License ++ Creative Commons License + {% if br_after_img %}
    {% endif %} + {% if attr_markup %} + "{{ attr_props['title'] }}" by {{ attr_props['name'] }} is + {% else %} +- Content ++ {{ _('Content') }} + {% endif %} +- licensed under a {{ cc_title|replace('CCSUFFIX',cc_title_suffix) }}, except where indicated otherwise. ++ {{ _('licensed under a') }} {{ cc_title|replace('CCSUFFIX',cc_title_suffix) }}, {{ _('except where indicated otherwise') }}. + {% endmacro %} +diff --git a/templates/includes/comment_count.html b/templates/includes/comment_count.html +index 4b42dde..1e83035 100644 +--- a/templates/includes/comment_count.html ++++ b/templates/includes/comment_count.html +@@ -1 +1 @@ +-{% if DISQUS_SITENAME and DISQUS_DISPLAY_COUNTS %}

    View comments.

    {% endif %} ++{% if DISQUS_SITENAME and DISQUS_DISPLAY_COUNTS %}

    {{ _('View comments') }}.

    {% endif %} +diff --git a/templates/includes/comments.html b/templates/includes/comments.html +index eade006..b37e2bf 100644 +--- a/templates/includes/comments.html ++++ b/templates/includes/comments.html +@@ -1,7 +1,7 @@ + {% if DISQUS_SITENAME %} +
    +
    +-

    Comments

    ++

    {{ _('Comments') }}

    + +
    +