Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make info boxes for posts translatable #484

Merged
merged 8 commits into from
Mar 4, 2020
Merged
19 changes: 12 additions & 7 deletions components/post/default.htm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% set post = __SELF__.post %}

<div class="content">{{ post.content_html|raw }}</div>
<div class="content">{{ post.content_html | raw }}</div>

{% if post.featured_images.count %}
<div class="featured-images text-center">
Expand All @@ -17,11 +17,16 @@
{% endif %}

<p class="info">
Posted
{% if post.categories.count %} in
{% for category in post.categories %}
<a href="{{ category.url }}">{{ category.name }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
{% if post.categories.count %}
{% set categoryLinks = post.categories | map(c => "<a href=\"#{c.url}\">#{c.name}</a>") | join(', ') %}

{{ 'rainlab.blog::lang.post.posted_byline' | trans({
date: post.published_at | date('rainlab.blog::lang.post.date_format' | trans),
categories: categoryLinks
}) }}
{% else %}
{{ 'rainlab.blog::lang.post.posted_byline_no_categories' | trans({
date: post.published_at | date('rainlab.blog::lang.post.date_format'|trans)
}) }}
{% endif %}
on {{ post.published_at|date('M d, Y') }}
</p>
26 changes: 16 additions & 10 deletions components/posts/default.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>

<p class="info">
Posted
{% if post.categories.count %} in {% endif %}
{% for category in post.categories %}
<a href="{{ category.url }}">{{ category.name }}</a>{% if not loop.last %}, {% endif %}
{% endfor %}
on {{ post.published_at|date('M d, Y') }}
{% if post.categories.count %}
{% set categoryLinks = post.categories | map(c => "<a href=\"#{c.url}\">#{c.name}</a>") | join(', ') %}

{{ 'rainlab.blog::lang.post.posted_byline' | trans({
date: post.published_at | date('rainlab.blog::lang.post.date_format' | trans),
categories: categoryLinks
}) }}
{% else %}
{{ 'rainlab.blog::lang.post.posted_byline_no_categories' | trans({
date: post.published_at | date('rainlab.blog::lang.post.date_format' | trans)
}) }}
{% endif %}
</p>

<p class="excerpt">{{ post.summary|raw }}</p>
<p class="excerpt">{{ post.summary | raw }}</p>
</li>
{% else %}
<li class="no-data">{{ __SELF__.noPostsMessage }}</li>
Expand All @@ -24,17 +30,17 @@ <h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
{% if posts.lastPage > 1 %}
<ul class="pagination">
{% if posts.currentPage > 1 %}
<li><a href="{{ this.page.baseFileName|page({ (__SELF__.pageParam): (posts.currentPage-1) }) }}">&larr; Prev</a></li>
<li><a href="{{ this.page.baseFileName | page({ (__SELF__.pageParam): (posts.currentPage-1) }) }}">&larr; Prev</a></li>
{% endif %}

{% for page in 1..posts.lastPage %}
<li class="{{ posts.currentPage == page ? 'active' : null }}">
<a href="{{ this.page.baseFileName|page({ (__SELF__.pageParam): page }) }}">{{ page }}</a>
<a href="{{ this.page.baseFileName | page({ (__SELF__.pageParam): page }) }}">{{ page }}</a>
</li>
{% endfor %}

{% if posts.lastPage > posts.currentPage %}
<li><a href="{{ this.page.baseFileName|page({ (__SELF__.pageParam): (posts.currentPage+1) }) }}">Next &rarr;</a></li>
<li><a href="{{ this.page.baseFileName | page({ (__SELF__.pageParam): (posts.currentPage+1) }) }}">Next &rarr;</a></li>
{% endif %}
</ul>
{% endif %}
5 changes: 4 additions & 1 deletion lang/de/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@
'featured_images' => 'Zugehörige Bilder',
'delete_confirm' => 'Möchtest du diesen Artikel wirklich löschen?',
'close_confirm' => 'Der Artikel ist noch nicht gespeichert.',
'return_to_posts' => 'Zurück zur Artikel-Übersicht'
'return_to_posts' => 'Zurück zur Artikel-Übersicht',
'posted_byline' => 'Veröffentlicht in :categories am :date',
'posted_byline_no_categories' => 'Veröffentlicht am :date',
'date_format' => 'd. F Y',
],
'categories' => [
'list_title' => 'Blog Kategorien verwalten',
Expand Down
5 changes: 4 additions & 1 deletion lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@
'delete_confirm' => 'Delete this post?',
'delete_success' => 'Successfully deleted those posts.',
'close_confirm' => 'The post is not saved.',
'return_to_posts' => 'Return to posts list'
'return_to_posts' => 'Return to posts list',
'posted_byline' => 'Posted in :categories on :date.',
'posted_byline_no_categories' => 'Posted on :date.',
'date_format' => 'M d, Y',
],
'categories' => [
'list_title' => 'Manage the blog categories',
Expand Down