hibbitts-design / grav-theme-quark-open-publishing

A customized version of the Quark theme for open publishing and blogging. Includes Git Sync and 'chromeless' content display for seamless embedding.
http://demo.hibbittsdesign.org/grav-open-publishing-quark/
MIT License
21 stars 12 forks source link

Add a setting for date translations #37

Closed LeMoussel closed 4 years ago

LeMoussel commented 4 years ago

By default, dates are not translated in Grav, which is a concern for internationalization.

One way to get dates localized would be to use the Twig extensions plugin that will localize dates : https://github.com/Perlkonig/grav-plugin-twig-extensions. The filter localizeddate('long', 'short', html_lang) does the job to get a localized datetime format.

I setup a test site with a date.html.twig:

<span class="blog-date">
    <time class="dt-published" datetime="{{ page.date|date("c") }}">
        <!-- => older <i class="fa fa-calendar"></i> {{ page.date|date(system.pages.dateformat.short) }} -->
        <i class="fa fa-calendar"></i> {{ page.date|localizeddate('long', 'short', html_lang) }}
    </time>
</span>

For french I Got this: image

This could be integrated by default in this theme

paulhibbitts commented 4 years ago

Thanks for the issue @LeMoussel . I would rather not add a new dependency of that plugin for the theme, might there be another way to support multi-language date display? In the meantime it's great to see you were able to get a solution going for the issue yourself!

paulhibbitts commented 4 years ago

I am closing this for now, hope your custom Twig works well for you!