Skip to content

Commit

Permalink
feat: l10n support
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudLigny committed Sep 8, 2022
1 parent 5713ec1 commit f7a2c21
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 13 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hyde theme

The _Hyde_ theme for [Cecil](https://cecil.app) is a port of the [Hyde](https://github.com/poole/hyde) theme for Jekyll created by [Mark Otto](https://github.com/mdo).
The _Hyde_ theme for [Cecil](https://cecil.app) is a port of the [Hyde theme for Jekyll](https://github.com/poole/hyde) created by [Mark Otto](https://github.com/mdo).

![Demo screenshot](docs/screenshot.png)

Expand Down Expand Up @@ -31,6 +31,18 @@ hyde:
reverse: false # Reverse layout
```
### Internationalization
This theme support [localization](https://cecil.app/documentation/templates/#localization), and provides french (`fr_FR`) translation (see `translations/messages.fr_FR.po`).

Configuration:

```yaml
languages:
- code: fr
locale: fr_FR
```

## License

_Hyde_ is a free software distributed under the terms of the MIT license.
Expand Down
1 change: 1 addition & 0 deletions assets/css/poole.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ blockquote p:last-child {
img {
display: block;
max-width: 100%;
height: auto;
margin: 0 0 1rem;
border-radius: 5px;
}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<h1 class="post-title">
<a href="{{ url(post) }}">{{ post.title|e }}</a>
</h1>
<span class="post-date">{{ post.date|date('j M Y') }}</span>
<span class="post-date">{{ post.date|format_date('long') }}</span>
{{ post.content|excerpt_html }}
{%- endblock post ~%}
</div>
Expand Down
5 changes: 4 additions & 1 deletion layouts/_default/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@
{%- endfor ~%}
{%- endif ~%}
</nav>
<p>Powered by <a href="{{ cecil.url }}">Cecil</a> &amp; <a href="https://github.com/poole/hyde#readme">Hyde</a>.</p>
{%- set powered_by -%}
<a href="{{ cecil.url }}">Cecil</a> &amp; <a href="https://github.com/poole/hyde#readme">Hyde</a>
{%- endset ~%}
<p>{% trans %}Powered by %powered_by%.{% endtrans %}</p>
{%- endblock sidebar ~%}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions layouts/blog/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
{% block content %}
<h1 class="page-title">{{ page.title }}</h1>
{%- if page.date is defined ~%}
<span class="post-date">{{ page.date|date("j M Y") }}</span>
<span class="post-date">{{ page.date|format_date('long') }}</span>
{%- endif ~%}
{%- if page.image is defined ~%}
<img src="{{ asset(page.image)|url }}" />
{{ asset(page.image)|html({alt: page.title}) }}
{%- endif ~%}
{{ page.content }}
<p>
Expand Down
4 changes: 2 additions & 2 deletions layouts/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<div class="post">
{%- block post ~%}
<h1 class="post-title"><a href="{{ url(post) }}">{{ post.title }}</a></h1>
<span class="post-date">{{ post.date|date('j M Y') }}</span>
<span class="post-date">{{ post.date|format_date('long') }}</span>
{%- if post.image is defined ~%}
<img src="{{ asset(post.image)|url }}" />
{%- endif ~%}
{{ post.content|excerpt_html }}
<footer class="readmore">
<a href="{{ url(post) }}#more">Read more ›</a>
<a href="{{ url(post) }}#more">{% trans %}Read more{% endtrans %} ›</a>
</footer>
{%- endblock post ~%}
</div>
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/lastposts.html.twig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="lastposts">
<h2>Recent posts</h2>
<h2>{% trans %}Recent posts{% endtrans %}</h2>
<ul>
{%- for post in site.pages|filter_by('section', 'blog')|sort_by_date|slice(1, 5) ~%}
<li><a href="{{ url(post) }}">{{ post.title }}</a></li>
Expand Down
10 changes: 5 additions & 5 deletions layouts/partials/pagination.html.twig
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{% if page.pagination is defined %}
{% if page.pagination %}
{%- set pagination = page.pagination ~%}
<div class="pagination">
{%- if pagination.links.next is defined ~%}
<a class="pagination-item older" href="{{ url(site.pages[pagination.links.next]) }}">Older</a>
<a class="pagination-item older" href="{{ url(site.pages[pagination.links.next]) }}">{% trans %}Older{% endtrans %}</a>
{%- else ~%}
<span class="pagination-item older">Older</span>
<span class="pagination-item older">{% trans %}Older{% endtrans %}</span>
{%- endif ~%}
{%- if pagination.links.prev is defined ~%}
<a class="pagination-item newer" href="{{ url(site.pages[pagination.links.prev]) }}">Newer</a>
<a class="pagination-item newer" href="{{ url(site.pages[pagination.links.prev]) }}">{% trans %}Newer{% endtrans %}</a>
{%- else ~%}
<span class="pagination-item newer">Newer</span>
<span class="pagination-item newer">{% trans %}Newer{% endtrans %}</span>
{%- endif ~%}
</div>
{% endif %}
Binary file added translations/messages.fr_FR.mo
Binary file not shown.
37 changes: 37 additions & 0 deletions translations/messages.fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
msgid ""
msgstr ""
"Project-Id-Version: \n"
"POT-Creation-Date: 2022-09-08 16:28+0200\n"
"PO-Revision-Date: 2022-09-08 17:33+0200\n"
"Last-Translator: Arnaud Ligny <[email protected]>\n"
"Language-Team: \n"
"Language: fr_FR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"X-Generator: Poedit 3.1.1\n"
"X-Poedit-Basepath: ../layouts\n"
"X-Poedit-SearchPath-0: .\n"

#: themes/hyde/layouts/_default/page.html.twig:60
msgid "Powered by %powered_by%."
msgstr "Propulsé par %powered_by%."

#: themes/hyde/layouts/index.html.twig:17
msgid "Read more"
msgstr "Lire la suite"

#: themes/hyde/layouts/partials/lastposts.html.twig:2
msgid "Recent posts"
msgstr "Articles récents"

#: themes/hyde/layouts/partials/pagination.html.twig:5
#: themes/hyde/layouts/partials/pagination.html.twig:7
msgid "Older"
msgstr "Plus ancien"

#: themes/hyde/layouts/partials/pagination.html.twig:10
#: themes/hyde/layouts/partials/pagination.html.twig:12
msgid "Newer"
msgstr "Plus récent"

0 comments on commit f7a2c21

Please sign in to comment.