pmoreno-rodriguez / grav-theme-editorial

Editorial is a GravCMS port of the Editorial theme from HTML5Up.net.
Other
13 stars 2 forks source link

Date translation in blog listings #34

Closed Fazarel closed 10 months ago

Fazarel commented 10 months ago

The date translation is correct on the post page. This is not the case for the blog post listings (modular recent-posts and blog page).

In comparison with /templates/item.html.twig, you have to add {% set lang = grav.language.getActive ?: grav.config.site.default_lang %} and change {{ datestamp|date(system.pages.dateformat.short) }} to {{ datestamp }} in: /templates/partials/blog-list-item.html.twig and /templates/modular/recent-posts.html.twig

Tested with the Twig Extensions plugin, I haven't tried Translate Date. By the way, any arguments for using one rather than the other?

pmoreno-rodriguez commented 10 months ago

Hello. For the next release, the Grav language variable will be set to base.html.twig, so it will be extended to all templates.

Fazarel commented 10 months ago

Just in case: you also need to modify /templates/partials/simplesearch_item.html.twig

As it stands, add :

{% set lang = grav.language.getActive ? : grav.config.site.default_lang %}

{% if config.plugins["translate-date"].enabled %}
    {% set datestamp = (page.header.publish_date) ? (page.header.publish_date|td(null, "Y-m-d")) : (page.date|td(null, "Y-m-d")) %}
{% elseif config.plugins["twig-extensions"].enabled %}
    {% set datestamp = (page.header.publish_date) ? (page.header.publish_date|localizeddate('medium', 'none', lang)) : (page.date|localizeddate('medium', 'none', lang)) %}
{% else %}
    {% set datestamp = (page.header.publish_date) ? (page.header.publish_date|date(system.pages.dateformat.short)) : (page.date|date(system.pages.dateformat.short)) %}
{% endif %}

And change <span class="search-date">{{ page.date|date(config.system.pages.dateformat.short) }}</span> to <span class="search-date">{{ datestamp }}</span>

pmoreno-rodriguez commented 10 months ago

Thanks @Fazarel . I'm checking all files of template searching code like you suggest.

pmoreno-rodriguez commented 10 months ago

Fixed in version 2.0.0