Skip to content
Permalink
Browse files

Sort translations for consistent py2/py3 output

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 11, 2015
1 parent 88c220f commit d68351880ae4a025d30a65de7c7cfa72719d2a88
@@ -4,7 +4,7 @@
{% block extra_head %}
{{ super() }}
{% if translations|length > 1 and generate_atom %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/atom+xml" title="Atom for the {{ archive_name }} section ({{ language }})" href="{{ _link("archive_atom", archive_name, language) }}">
{% endfor %}
{% elif generate_atom %}
@@ -90,7 +90,7 @@ lang="{{ lang }}">
{{ rss_link }}
{% elif generate_rss %}
{% if translations|length > 1 %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/rss+xml" title="RSS ({{ language }})" href="{{ _link('rss', None, language) }}">
{% endfor %}
{% else %}
@@ -99,7 +99,7 @@ lang="{{ lang }}">
{% endif %}
{% if generate_atom %}
{% if translations|length > 1 %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/atom+xml" title="Atom ({{ language }})" href="{{ _link('index_atom', None, language) }}">
{% endfor %}
{% else %}
@@ -110,7 +110,7 @@ lang="{{ lang }}">

{% macro html_translations() %}
<ul class="translations">
{% for langname in translations.keys() %}
{% for langname in translations|sort %}
{% if langname != lang %}
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
@@ -12,7 +12,7 @@
{% if post.translated_to|length > 1 %}
<div class="metadata posttranslations translations">
<h3 class="posttranslations-intro">{{ messages("Also available in:") }}</h3>
{% for langname in translations.keys() %}
{% for langname in translations|sort %}
{% if langname != lang and post.is_translation_available(langname) %}
<p><a href="{{ post.permalink(langname) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></p>
{% endif %}
@@ -2,7 +2,7 @@

{% macro meta_translations(post) %}
{% if translations|length > 1 %}
{% for langname in translations.keys() %}
{% for langname in translations|sort %}
{% if langname != lang and post.is_translation_available(langname) %}
<link rel="alternate" hreflang="{{ langname }}" href="{{ post.permalink(langname) }}">
{% endif %}
@@ -4,7 +4,7 @@
{% block extra_head %}
{{ super() }}
{% if translations|length > 1 and generate_rss %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/rss+xml" type="application/rss+xml" title="RSS for {{ kind }} {{ tag }} ({{ language }})" href="{{ _link(kind + "_rss", tag, language) }}">
{% endfor %}
{% elif generate_rss %}
@@ -30,7 +30,7 @@
{% endif %}
<div class="metadata">
{% if translations|length > 1 and generate_rss %}
{% for language in translations %}
{% for language in translations|sort %}
<p class="feedlink">
<a href="{{ _link(kind + "_rss", tag, language) }}" hreflang="{{ language }}" type="application/rss+xml">{{ messages('RSS feed', language) }} ({{ language }})</a>&nbsp;
</p>
@@ -15,7 +15,7 @@
{% block extra_head %}
{{ super() }}
{% if translations|length > 1 and generate_atom %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/atom+xml" title="Atom for the {{ tag }} section ({{ language }})" href="{{ _link(kind + "_atom", tag, language) }}">
{% endfor %}
{% elif generate_atom %}
@@ -4,7 +4,7 @@
<%block name="extra_head">
${parent.extra_head()}
%if len(translations) > 1 and generate_atom:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/atom+xml" title="Atom for the ${archive_name} section (${language})" href="${_link("archive_atom", archive_name, language)}">
%endfor
%elif generate_atom:
@@ -90,7 +90,7 @@ lang="${lang}">
${rss_link}
%elif generate_rss:
%if len(translations) > 1:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/rss+xml" title="RSS (${language})" href="${_link('rss', None, language)}">
%endfor
%else:
@@ -99,7 +99,7 @@ lang="${lang}">
%endif
%if generate_atom:
%if len(translations) > 1:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/atom+xml" title="Atom (${language})" href="${_link('index_atom', None, language)}">
%endfor
%else:
@@ -110,7 +110,7 @@ lang="${lang}">

<%def name="html_translations()">
<ul class="translations">
%for langname in translations.keys():
%for langname in sorted(translations):
%if langname != lang:
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
@@ -12,7 +12,7 @@
% if len(post.translated_to) > 1:
<div class="metadata posttranslations translations">
<h3 class="posttranslations-intro">${messages("Also available in:")}</h3>
% for langname in translations.keys():
% for langname in sorted(translations):
% if langname != lang and post.is_translation_available(langname):
<p><a href="${post.permalink(langname)}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></p>
% endif
@@ -2,7 +2,7 @@

<%def name="meta_translations(post)">
%if len(translations) > 1:
%for langname in translations.keys():
%for langname in sorted(translations):
%if langname != lang and post.is_translation_available(langname):
<link rel="alternate" hreflang="${langname}" href="${post.permalink(langname)}">
%endif
@@ -4,7 +4,7 @@
<%block name="extra_head">
${parent.extra_head()}
%if len(translations) > 1 and generate_rss:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/rss+xml" type="application/rss+xml" title="RSS for ${kind} ${tag} (${language})" href="${_link(kind + "_rss", tag, language)}">
%endfor
%elif generate_rss:
@@ -30,7 +30,7 @@
%endif
<div class="metadata">
%if len(translations) > 1 and generate_rss:
%for language in translations:
%for language in sorted(translations):
<p class="feedlink">
<a href="${_link(kind + "_rss", tag, language)}" hreflang="${language}" type="application/rss+xml">${messages('RSS feed', language)} (${language})</a>&nbsp;
</p>
@@ -15,7 +15,7 @@
<%block name="extra_head">
${parent.extra_head()}
%if len(translations) > 1 and generate_atom:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/atom+xml" title="Atom for the ${tag} section (${language})" href="${_link(kind + "_atom", tag, language)}">
%endfor
%elif generate_atom:
@@ -154,7 +154,7 @@ lang="{{ lang }}">
{{ rss_link }}
{% elif generate_rss %}
{% if translations|length > 1 %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/rss+xml" title="RSS ({{ language }})" href="{{ _link('rss', None, language) }}">
{% endfor %}
{% else %}
@@ -163,7 +163,7 @@ lang="{{ lang }}">
{% endif %}
{% if generate_atom %}
{% if translations|length > 1 %}
{% for language in translations %}
{% for language in translations|sort %}
<link rel="alternate" type="application/atom+xml" title="Atom ({{ language }})" href="{{ _link('index_atom', None, language) }}">
{% endfor %}
{% else %}
@@ -173,7 +173,7 @@ lang="{{ lang }}">
{% endmacro %}

{% macro html_translations() %}
{% for langname in translations.keys() %}
{% for langname in translations|sort %}
{% if langname != lang %}
<li><a href="{{ abs_link(_link("root", None, langname)) }}" rel="alternate" hreflang="{{ langname }}">{{ messages("LANGUAGE", langname) }}</a></li>
{% endif %}
@@ -154,7 +154,7 @@ lang="${lang}">
${rss_link}
%elif generate_rss:
%if len(translations) > 1:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/rss+xml" title="RSS (${language})" href="${_link('rss', None, language)}">
%endfor
%else:
@@ -163,7 +163,7 @@ lang="${lang}">
%endif
%if generate_atom:
%if len(translations) > 1:
%for language in translations:
%for language in sorted(translations):
<link rel="alternate" type="application/atom+xml" title="Atom (${language})" href="${_link('index_atom', None, language)}">
%endfor
%else:
@@ -173,7 +173,7 @@ lang="${lang}">
</%def>

<%def name="html_translations()">
%for langname in translations.keys():
%for langname in sorted(translations):
%if langname != lang:
<li><a href="${abs_link(_link("root", None, langname))}" rel="alternate" hreflang="${langname}">${messages("LANGUAGE", langname)}</a></li>
%endif
@@ -18,7 +18,8 @@
["og: http://ogp.me/ns# \\", "og: http://ogp.me/ns#"],
["article: http://ogp.me/ns/article# \\", "article: http://ogp.me/ns/article#"],
["fb: http://ogp.me/ns/fb# \\", "fb: http://ogp.me/ns/fb#"],
['dir="rtl" \\', 'dir="rtl"']
['dir="rtl" \\', 'dir="rtl"'],
['sorted(translations)', 'translations|sort'],
]

dumber_replacements = [

0 comments on commit d683518

Please sign in to comment.
You can’t perform that action at this time.