From 0d6cbea6198ea3f404924dc4861f56e35e03e82c Mon Sep 17 00:00:00 2001 From: Tobenna Peter Igwe Date: Thu, 6 Apr 2017 07:38:23 +0100 Subject: [PATCH 1/3] Localization of the template files --- templates/archives.html | 4 ++-- templates/article.html | 10 +++++----- templates/author.html | 6 +++--- templates/authors.html | 4 ++-- templates/categories.html | 4 ++-- templates/category.html | 4 ++-- templates/index.html | 4 ++-- templates/pagination.html | 4 ++-- templates/period_archives.html | 4 ++-- templates/tag.html | 2 +- templates/tags.html | 6 +++--- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/templates/archives.html b/templates/archives.html index 15149cb..071835d 100644 --- a/templates/archives.html +++ b/templates/archives.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ SITENAME }} - Archives{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Archives') }} {% endblock %} {% block header %} @@ -15,7 +15,7 @@
-

Archives for {{ SITENAME }}

+

{{ gettext('Archives for %(name)s', name=SITENAME) }}

diff --git a/templates/article.html b/templates/article.html index c5dc9dc..e7f6086 100644 --- a/templates/article.html +++ b/templates/article.html @@ -105,14 +105,14 @@ {% if article.headline %}

{{ article.headline }}

{% endif %} - Posted by + {{ gettext('Posted by') }} {% for author in article.authors %} {{ author }} {% endfor %} - on {{ article.locale_date }} + {{ gettext('on') }} {{ article.locale_date }} {% if article.modified %} - Updated on {{ article.locale_modified }} + {{ gettext('Updated on %(moddate)s', moddate=article.locale_modified) }} {% endif %} {% import 'translations.html' as translations with context %} {{ translations.translations_for(article) }} @@ -131,7 +131,7 @@ {% if article.tags %}
-

tags: {% for tag in article.tags %}{{ tag | escape }}{% if not loop.last %}, {% endif %}{% endfor %}

+

{{ gettext('tags') }} : {% for tag in article.tags %}{{ tag | escape }}{% if not loop.last %}, {% endif %}{% endfor %}

{% endif %} @@ -152,7 +152,7 @@ (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })(); - + {% endif %} {% endblock content %} diff --git a/templates/author.html b/templates/author.html index 65aff95..f526ad5 100644 --- a/templates/author.html +++ b/templates/author.html @@ -1,10 +1,10 @@ {% extends "index.html" %} -{% block title %}{{ SITENAME }} - Articles by {{ author }}{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Articles by %(name)s', name=author) }}{% endblock %} {% block opengraph %} {{ super() }} - + @@ -24,7 +24,7 @@
-

Articles by {{ author }}

+

{{ gettext('Articles by %(name)s', name=author) }}

diff --git a/templates/authors.html b/templates/authors.html index 74917a8..73c9df9 100644 --- a/templates/authors.html +++ b/templates/authors.html @@ -1,6 +1,6 @@ {% extends "index.html" %} -{% block title %}{{ SITENAME }} - Authors{% endblock title %} +{% block title %}{{ SITENAME }} - {{ gettext('Authors') }}{% endblock title %} {% block header %} @@ -15,7 +15,7 @@
-

Articles by {{ author }}

+

{{ gettext('Articles by %(name)s', name=author) }}

diff --git a/templates/categories.html b/templates/categories.html index 7af5236..0883d7b 100644 --- a/templates/categories.html +++ b/templates/categories.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ SITENAME }} - Categories{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Categories') }}{% endblock %} {% block header %} @@ -15,7 +15,7 @@
-

{{ SITENAME }} - Categories

+

{{ SITENAME }} - {{ gettext('Categories') }}

diff --git a/templates/category.html b/templates/category.html index 53b8879..443b208 100644 --- a/templates/category.html +++ b/templates/category.html @@ -1,6 +1,6 @@ {% extends "index.html" %} -{% block title %}{{ SITENAME }} - Articles in the {{ category }} category{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Articles in the %(category)s category', category=category) }}{% endblock %} {% block header %} @@ -15,7 +15,7 @@
-

Articles in the {{ category }} category

+

{{ gettext('Articles in the %(category)s category', category=category) }}

diff --git a/templates/index.html b/templates/index.html index 6eeba7a..168742a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -58,11 +58,11 @@ {% endif %}

{% endif %} - {% include 'comments.html' %} diff --git a/templates/pagination.html b/templates/pagination.html index 22b7e54..1cc50c8 100644 --- a/templates/pagination.html +++ b/templates/pagination.html @@ -4,10 +4,10 @@ diff --git a/templates/period_archives.html b/templates/period_archives.html index 19fdaa9..8c6b6aa 100644 --- a/templates/period_archives.html +++ b/templates/period_archives.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ SITENAME }} - Archives for {{ period | reverse | join (' ') }}{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Archives for %(period)s', period=period | reverse | join (' ')) }}{% endblock %} {% block header %} @@ -15,7 +15,7 @@
-

Archives for {{ period | reverse | join (' ') }}

+

{{ gettext('Archives for %(period)s', period=period | reverse | join (' ')) }}

diff --git a/templates/tag.html b/templates/tag.html index 108d5be..9a8ad78 100644 --- a/templates/tag.html +++ b/templates/tag.html @@ -1,5 +1,5 @@ {% extends "index.html" %} -{% block title %}{{ SITENAME }} - Tag {{ tag }}{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Tag %(tag)s', tag=tag) }}{% endblock %} {% block header %} {% if HEADER_COVER %}
diff --git a/templates/tags.html b/templates/tags.html index bab699f..48ef873 100644 --- a/templates/tags.html +++ b/templates/tags.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% block title %}{{ SITENAME }} - Tags{% endblock %} +{% block title %}{{ SITENAME }} - {{ gettext('Tags') }}{% endblock %} {% block header %} @@ -15,7 +15,7 @@
-

{{ SITENAME }} - Tags

+

{{ SITENAME }} - {{ gettext('Tags') }}

@@ -24,7 +24,7 @@ {% endblock header %} {% block content %} -

Tags for {{ SITENAME }}

+

{{ gettext('Tags for %(sitename)s', sitename=SITENAME) }}

{%- for tag, articles in tags|sort %}
  • {{ tag }} ({{ articles|count }})
  • {% endfor %} From 4fbc94492efdc68ad6c17062292fa2fe6c9bf5b7 Mon Sep 17 00:00:00 2001 From: Tobenna Peter Igwe Date: Thu, 6 Apr 2017 07:44:43 +0100 Subject: [PATCH 2/3] Build script for generation of localization files --- Makefile | 21 ++++++++++++ babel.cfg | 1 + messages.pot | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 Makefile create mode 100644 babel.cfg create mode 100644 messages.pot diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6174f19 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +help: + @echo 'Makefile for localization' + @echo '' + @echo 'Usage:' + @echo ' make extract Extract translatable strings from templates' + @echo ' make init lang=lang Initialize the message catalogs with a new language (e.g make init lang=ja)' + @echo ' make compile Compile the message catalogs' + @echo ' make update Update the catalogs when templates change' + +extract: + pybabel extract --mapping babel.cfg --output messages.pot ./ + +init: + pybabel init --input-file messages.pot --output-dir translations/ --locale $$lang --domain messages + +compile: + pybabel compile --directory translations/ --domain messages + +update: + pybabel update --input-file messages.pot --output-dir translations/ --domain messages + 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..191ff8e --- /dev/null +++ b/messages.pot @@ -0,0 +1,95 @@ +# Translations template for PROJECT. +# Copyright (C) 2017 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2017. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2017-04-06 06:29+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 2.3.4\n" + +#: templates/archives.html:3 +msgid "Archives" +msgstr "" + +#: templates/archives.html:18 +#, python-format +msgid "Archives for %(name)s" +msgstr "" + +#: templates/article.html:108 templates/index.html:61 +msgid "Posted by" +msgstr "" + +#: templates/article.html:112 templates/index.html:65 +msgid "on" +msgstr "" + +#: templates/article.html:115 +#, python-format +msgid "Updated on %(moddate)s" +msgstr "" + +#: templates/article.html:134 +msgid "tags" +msgstr "" + +#: templates/article.html:155 +msgid "Please enable JavaScript to view the comments." +msgstr "" + +#: templates/author.html:3 templates/author.html:7 templates/author.html:27 +#: templates/authors.html:18 +#, python-format +msgid "Articles by %(name)s" +msgstr "" + +#: templates/authors.html:3 +msgid "Authors" +msgstr "" + +#: templates/categories.html:3 templates/categories.html:18 +msgid "Categories" +msgstr "" + +#: templates/category.html:3 templates/category.html:18 +#, python-format +msgid "Articles in the %(category)s category" +msgstr "" + +#: templates/pagination.html:7 +msgid "Older Posts" +msgstr "" + +#: templates/pagination.html:10 +msgid "Newest Posts" +msgstr "" + +#: templates/period_archives.html:3 templates/period_archives.html:18 +#, python-format +msgid "Archives for %(period)s" +msgstr "" + +#: templates/tag.html:2 +#, python-format +msgid "Tag %(tag)s" +msgstr "" + +#: templates/tags.html:3 templates/tags.html:18 +msgid "Tags" +msgstr "" + +#: templates/tags.html:27 +#, python-format +msgid "Tags for %(sitename)s" +msgstr "" + From 6f59960e8d1c770e9205b36aad8b8dfb53f40d4f Mon Sep 17 00:00:00 2001 From: Tobenna Peter Igwe Date: Thu, 6 Apr 2017 07:45:32 +0100 Subject: [PATCH 3/3] Complete Japanese Translations --- translations/ja/LC_MESSAGES/messages.mo | Bin 0 -> 1350 bytes translations/ja/LC_MESSAGES/messages.po | 95 ++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 translations/ja/LC_MESSAGES/messages.mo create mode 100644 translations/ja/LC_MESSAGES/messages.po diff --git a/translations/ja/LC_MESSAGES/messages.mo b/translations/ja/LC_MESSAGES/messages.mo new file mode 100644 index 0000000000000000000000000000000000000000..effb29042948a466486bf3cc423287cda820b256 GIT binary patch literal 1350 zcmZva+iP4!9LGnEw^LClRS^{iA<&{{JsWEqPm-G3RyJ&!WwY&r_%gd^a&pSqGt10u zV%~DjdTT|Bg|vYdyildIUJ4ex6YwAK4-kBrbPb4)J_>$kFG)*#*mFMfyUg$Vo7vx= z`-e6Np8a^A!~2yrZhOY>Bjgd-6X28JaqwyIE${%S!C~+W_%Qe_=z!mYkAc5|`@rA9 z9QX(LDCpeZ^B(|*U{lc69|oTS$3Xl@1s@wf37*H^H^C=h|MLJL&w~Gf&x6k($)4dT zX#1H19|D`8&0htr?)!cJ$6y8aX5are_&Dr;`|+U%dwuK!ZC@{dw%%x;uY+Vt)|aCd zu67r6Nk}?;FkuaT=q_)Q%SZ%WzmDoLSG2Zvdvf0yB~&kS1nNxlP{_4IiVl`!s->5O zRAirb#W`HkF{i|mu*E{ipJuy;Tji`_J#@TO znvA2Ikl`_>9JeHk-Qz+wluwgp*HjbvG1^;Bc+PxrzOZ*M`JCs>hy+)Q&eodH(EM%v zax-R8GDhpmOe(G?T6)PH-OIBlSmM$xBy|x)N$AtjTBMyfc*3RqW8CRApH8zHkLgJ6 zmE2*6nCx@Y{>5b1O?Jh!FOb2cQj>mjcWf}P_m1|4z{Ym2Zf^hdA&L#A6a#BD+V7d{ zrfFZZlDk>kzh2&1e;1wH5htAsH%xlbr0^sx`%(U_Sz+~rlu6=FNt+HvPn8saa3=rW#3|%V%z#{n4b?yQRJ~={b{rYSInVGwT`YoZa~A>XudS4>!8p kGT9AibuoN!Z@7DB?z%gdZlb%+#V_uda@gBHZw|Kp4}8tJmjD0& literal 0 HcmV?d00001 diff --git a/translations/ja/LC_MESSAGES/messages.po b/translations/ja/LC_MESSAGES/messages.po new file mode 100644 index 0000000..02ff265 --- /dev/null +++ b/translations/ja/LC_MESSAGES/messages.po @@ -0,0 +1,95 @@ +# Japanese translations for PROJECT. +# Copyright (C) 2017 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2017-04-06 06:29+0100\n" +"PO-Revision-Date: 2017-04-06 05:18+0100\n" +"Last-Translator: Tobenna Peter, Igwe\n" +"Language: ja\n" +"Language-Team: ja \n" +"Plural-Forms: nplurals=1; plural=0\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.3.4\n" + +#: templates/archives.html:3 +msgid "Archives" +msgstr "アーカイブ" + +#: templates/archives.html:18 +#, python-format +msgid "Archives for %(name)s" +msgstr "%(name)s のアーカイブ" + +#: templates/article.html:108 templates/index.html:61 +msgid "Posted by" +msgstr "投稿者" + +#: templates/article.html:112 templates/index.html:65 +msgid "on" +msgstr "日付" + +#: templates/article.html:115 +#, python-format +msgid "Updated on %(moddate)s" +msgstr "更新日 %(moddate)s" + +#: templates/article.html:134 +msgid "tags" +msgstr "タグ" + +#: templates/article.html:155 +msgid "Please enable JavaScript to view the comments." +msgstr "コメントを読み書きのため、JavaScriptを有効にしてください。" + +#: templates/author.html:3 templates/author.html:7 templates/author.html:27 +#: templates/authors.html:18 +#, python-format +msgid "Articles by %(name)s" +msgstr "%(name)s の記事" + +#: templates/authors.html:3 +msgid "Authors" +msgstr "作者" + +#: templates/categories.html:3 templates/categories.html:18 +msgid "Categories" +msgstr "カテゴリー" + +#: templates/category.html:3 templates/category.html:18 +#, python-format +msgid "Articles in the %(category)s category" +msgstr "%(category)s カテゴリーの記事" + +#: templates/pagination.html:7 +msgid "Older Posts" +msgstr "古い" + +#: templates/pagination.html:10 +msgid "Newest Posts" +msgstr "新しい" + +#: templates/period_archives.html:3 templates/period_archives.html:18 +#, python-format +msgid "Archives for %(period)s" +msgstr "%(period)s のアーカイブ" + +#: templates/tag.html:2 +#, python-format +msgid "Tag %(tag)s" +msgstr "%(tag)s タグ" + +#: templates/tags.html:3 templates/tags.html:18 +msgid "Tags" +msgstr "タグ" + +#: templates/tags.html:27 +#, python-format +msgid "Tags for %(sitename)s" +msgstr "%(sitename)s のタグ"