mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Fix translation feature. Add translation support to the notmyidea theme.
This commit is contained in:
parent
2f6300af46
commit
79576f25b6
9 changed files with 33 additions and 40 deletions
|
|
@ -16,7 +16,7 @@ class Page(object):
|
||||||
|
|
||||||
self.status = "published" # default value
|
self.status = "published" # default value
|
||||||
for key, value in metadatas.items():
|
for key, value in metadatas.items():
|
||||||
setattr(self, key, value)
|
setattr(self, key.lower(), value)
|
||||||
|
|
||||||
if not hasattr(self, 'author'):
|
if not hasattr(self, 'author'):
|
||||||
if 'AUTHOR' in settings:
|
if 'AUTHOR' in settings:
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,7 @@
|
||||||
rel="bookmark" title="Permalink to {{ article.title }}">{{ article.title
|
rel="bookmark" title="Permalink to {{ article.title }}">{{ article.title
|
||||||
}}</a></h1> {% include 'twitter.html' %} </header>
|
}}</a></h1> {% include 'twitter.html' %} </header>
|
||||||
<div class="entry-content">
|
<div class="entry-content">
|
||||||
<footer class="post-info">
|
{% include 'article_infos.html' %}
|
||||||
<abbr class="published" title="{{ article.date.isoformat() }}">
|
|
||||||
{{ article.date.strftime('%a %d %B %Y') }}
|
|
||||||
</abbr>
|
|
||||||
{% if article.author %}
|
|
||||||
<address class="vcard author">
|
|
||||||
By <a class="url fn" href="#">{{ article.author }}</a>
|
|
||||||
</address>
|
|
||||||
{% endif %}
|
|
||||||
<p>In <a href="{{ SITEURL }}/category/{{ article.category }}.html">{{ article.category }}</a>.
|
|
||||||
{% include 'taglist.html' %}
|
|
||||||
</footer><!-- /.post-info -->
|
|
||||||
{{ article.content }}
|
{{ article.content }}
|
||||||
</div><!-- /.entry-content -->
|
</div><!-- /.entry-content -->
|
||||||
{% if DISQUS_SITENAME %}
|
{% if DISQUS_SITENAME %}
|
||||||
|
|
|
||||||
14
pelican/themes/notmyidea/templates/article_infos.html
Normal file
14
pelican/themes/notmyidea/templates/article_infos.html
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<footer class="post-info">
|
||||||
|
<abbr class="published" title="{{ article.date.isoformat() }}">
|
||||||
|
{{ article.date.strftime('%a %d %B %Y') }}
|
||||||
|
</abbr>
|
||||||
|
|
||||||
|
{% if article.author %}
|
||||||
|
<address class="vcard author">
|
||||||
|
By <a class="url fn" href="#">{{ article.author }}</a>
|
||||||
|
</address>
|
||||||
|
{% endif %}
|
||||||
|
<p>In <a href="{{ SITEURL }}/category/{{ article.category }}.html">{{ article.category }}</a>. {% if PDF_PROCESSOR %}<a href="{{ SITEURL }}/pdf/{{ article.slug }}.pdf">get the pdf</a>{% endif %}</p>
|
||||||
|
{% include 'taglist.html' %}
|
||||||
|
{% include 'translations.html' %}
|
||||||
|
</footer><!-- /.post-info -->
|
||||||
|
|
@ -7,19 +7,7 @@
|
||||||
<aside id="featured" class="body"><article>
|
<aside id="featured" class="body"><article>
|
||||||
<h1 class="entry-title"><a href="{{ SITEURL }}/{{ article.url
|
<h1 class="entry-title"><a href="{{ SITEURL }}/{{ article.url
|
||||||
}}">{{ article.title }}</a></h1>
|
}}">{{ article.title }}</a></h1>
|
||||||
<footer class="post-info">
|
{% include 'article_infos.html' %}
|
||||||
<abbr class="published" title="{{ article.date.isoformat() }}">
|
|
||||||
{{ article.date.strftime('%a %d %B %Y') }}
|
|
||||||
</abbr>
|
|
||||||
|
|
||||||
{% if article.author %}
|
|
||||||
<address class="vcard author">
|
|
||||||
By <a class="url fn" href="#">{{ article.author }}</a>
|
|
||||||
</address>
|
|
||||||
{% endif %}
|
|
||||||
<p>In <a href="{{ SITEURL }}/category/{{ article.category }}.html">{{ article.category }}</a>. {% if PDF_PROCESSOR %}<a href="{{ SITEURL }}/pdf/{{ article.slug }}.pdf">get the pdf</a>{% endif %}</p>
|
|
||||||
{% include 'taglist.html' %}
|
|
||||||
</footer><!-- /.post-info -->
|
|
||||||
{{ article.content }}
|
{{ article.content }}
|
||||||
{% include 'comments.html' %}
|
{% include 'comments.html' %}
|
||||||
</article>
|
</article>
|
||||||
|
|
@ -37,18 +25,7 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="entry-content">
|
<div class="entry-content">
|
||||||
<footer class="post-info">
|
{% include 'article_infos.html' %}
|
||||||
<abbr class="published" title="{{ article.date.isoformat() }}">
|
|
||||||
{{ article.date.strftime('%a %d %B %Y') }}
|
|
||||||
</abbr>
|
|
||||||
|
|
||||||
<address class="vcard author">
|
|
||||||
By <a class="url fn" href="#">{{ article.author }}</a>
|
|
||||||
</address>
|
|
||||||
<p> In <a href="{{ SITEURL }}/category/{{ article.category }}.html">{{ article.category }}</a></p>
|
|
||||||
{% include 'taglist.html' %}
|
|
||||||
<p>{% if PDF_PROCESSOR %}<a href="{{ SITEURL }}/pdf/{{ article.slug }}.pdf">pdf</a>{% endif %}</p>
|
|
||||||
</footer><!-- /.post-info -->
|
|
||||||
{{ article.summary }}
|
{{ article.summary }}
|
||||||
<a class="readmore" href="{{ SITEURL }}/{{ article.url }}">read more</a>
|
<a class="readmore" href="{{ SITEURL }}/{{ article.url }}">read more</a>
|
||||||
{% include 'comments.html' %}
|
{% include 'comments.html' %}
|
||||||
|
|
|
||||||
6
pelican/themes/notmyidea/templates/translations.html
Normal file
6
pelican/themes/notmyidea/templates/translations.html
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{% if article.translations %}
|
||||||
|
Translations:
|
||||||
|
{% for translation in article.translations %}
|
||||||
|
<a href="{{ SITEURL }}/{{ translation.url }}">{{ translation.lang }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
@ -159,6 +159,7 @@ def process_translations(content_list):
|
||||||
Also, for each content_list item, it
|
Also, for each content_list item, it
|
||||||
sets attribute 'translations'
|
sets attribute 'translations'
|
||||||
"""
|
"""
|
||||||
|
content_list.sort(key=attrgetter('slug'))
|
||||||
grouped_by_slugs = groupby(content_list, attrgetter('slug'))
|
grouped_by_slugs = groupby(content_list, attrgetter('slug'))
|
||||||
index = []
|
index = []
|
||||||
translations = []
|
translations = []
|
||||||
|
|
|
||||||
6
samples/content/another_super_article-fr.rst
Normal file
6
samples/content/another_super_article-fr.rst
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
Oh yeah !
|
||||||
|
#########
|
||||||
|
|
||||||
|
:lang: fr
|
||||||
|
|
||||||
|
Et voila du contenu en français
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Oh yeah !
|
Oh yeah !
|
||||||
#########################
|
#########
|
||||||
|
|
||||||
:tags: oh, bar, yeah
|
:tags: oh, bar, yeah
|
||||||
:date: 2010-10-20 10:14
|
:date: 2010-10-20 10:14
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ And here comes the cool stuff_.
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
>>> from ipdb import set trace
|
>>> from ipdb import set_trace
|
||||||
>>> set_trace()
|
>>> set_trace()
|
||||||
|
|
||||||
→ And now try with some utf8 hell: ééé
|
→ And now try with some utf8 hell: ééé
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue