getgrav / grav-plugin-archives

Grav Archives Plugin
https://getgrav.org
MIT License
8 stars 12 forks source link

date format and translate #8

Open ocean123 opened 8 years ago

ocean123 commented 8 years ago

Hi,

how can I translate the months? its now in English, we want it in the local language

best regards

flaviocopes commented 8 years ago

Installed on a Grav with the language enabled (e.g. in system.yaml:

languages:
  supported:
    - it
  include_default_lang: false
  translations: true
  translations_fallback: true

the months will be translated, IF the months translation is available in Grav. You don't mention which language you want. Check your language file in https://github.com/getgrav/grav/tree/develop/system/languages contains MONTHS_OF_THE_YEAR translation

ocean123 commented 8 years ago
languages:
  supported:
    - nl
  include_default_lang: false
  translations: true
  translations_fallback: true
  session_store_active: false
  http_accept_language: true
  override_locale: false

And still english text

flaviocopes commented 8 years ago

I can see screen shot 2016-03-16 at 11 54 00

ocean123 commented 8 years ago

?? strange.

schermafbeelding 2016-03-16 om 11 55 37

ocean123 commented 8 years ago

see syndes.nl

flaviocopes commented 8 years ago

Post your plugin configuration, user/config/plugins/archives.yaml so I can try with your settings.

ocean123 commented 8 years ago
enabled: true
built_in_css: true
date_display_format: 'D, m M Y'
show_count: true
limit: 12
order:
  by: title
  dir: desc
filter_combinator: or
filters:
  category:
    - blog
    - portfolio
    - review
ocean123 commented 8 years ago

But the posts are also not translate. Oct ==> Okt I thinks its more getgrav issue then a achive issue

schermafbeelding 2016-03-16 om 13 22 38
flaviocopes commented 8 years ago

Are you using the latest release of this plugin? The plugin latest release is currently supposed to print a list with format <Monthname> <Year>, correctly translated.

Because of a bug I just noticed, it will just use that format, and not use the format set in the plugin options, was a recent PR side-effect which I'm going to fix.

As for the blog post date, that's another thing. That's handled by the theme, which might not be using the translation functionality. Which theme is that?

ocean123 commented 8 years ago

Archive version 1.4.0.

ocean123 commented 8 years ago

About the theme and the date. Its happening in Gravstrap-theme but also in Antimatter All plugins and Grav are up-to-date.

flaviocopes commented 8 years ago

Yes Antimatter is not translating the date currently. Am trying to look how the dates can be translated automatically based on the language.

The date format of the Archives plugin should be like this: http://gravstrap.diblas.net/my-gravtastic-blog Am out of ideas why it's in that format and not translated.

ocean123 commented 8 years ago

schermafbeelding 2016-03-16 om 14 42 42 I deletet the config file for achive. Now the format is fine. Just the translation is still not okey

ocean123 commented 8 years ago

After just opening the plugin. Click on save without changing any thing I get this

schermafbeelding 2016-03-16 om 14 44 05

flaviocopes commented 8 years ago

So, this is an issue caused by the blog-injector plugin, installed in the Gravstrap skeleton.

I checked it because it was too strange.

That plugin overrides this Archives plugin output (and other plugins output too) in https://github.com/giansi/grav-plugin-blog/blob/master/templates/blog/bootstrap/blog_theme.html.twig#L160-L178, thus causing a bit of an issue here, because the output is different, causing this confusion.

Meanwhile I added a PR to Grav to allow translating dates automatically, so even in this case the date should be automatically translated based on the locale.

ocean123 commented 8 years ago

thanks a lot :+1:

Duke3D commented 7 years ago

@flaviocopes I have encountered the same issue as above using the Sora Article template. Saving the plugin's settings in Admin with no change except limit: 24 caused each date to list separately instead of being collected into months. An uninstall and reinstall of the plugin did not restore grouping by month. This template does not have/use a "blog injector" plugin, Other places to look? All latest updates applied. What is changed by simply saving the plugin settings?

Duke3D commented 7 years ago

Issue is fixed by pull request #7 that fixes blueprints.yaml submitted February, a year ago. Please commit!

eisenherzz commented 7 years ago

Unfortunately a late report. I think since GRAV 1.3 update the translation is broken. Up to then it worked perfectly for the months. I could not find what changed that could be the reason for this.

zaszlo commented 6 years ago

As a summary, for now until it gets fixed what is the solution to get the translation working in the archives section?

n3tman commented 5 years ago

This issue is still reproduced on Grav v1.5.8 with Archives v1.5.1 and without BlogInjector installed.

I found two solutions:

  1. Fix from another issue https://github.com/getgrav/grav-plugin-archives/issues/2#issuecomment-168723925
  2. Fix from documentation using Twig Extensions plugin:

<span class="archive_date">{{ month|localizeddate('none', 'none', 'ru', 'Europe/Moscow', 'LLLL y')|capitalize }}</span>```
dragonandy commented 5 years ago

the latest version of grav is not working with the MONTHS_OF_THE_YEAR tanslation I checked the translations located in grav/system/languages/[lang].yaml and they are presented there I don't want to change the twig template like the solution above because it will break when grav do an upgrade Needs help

rhukster commented 5 years ago

It's true this plugin is not using the Grav translation strings, as it's just using PHP date format strings, and those translations are going to be powered by the php_intl extension.

Please make sure you have this installed.

n3tman commented 5 years ago

If you, like me, updated Grav from 1.5 to 1.6 and saw this: 2019-07-29_123205 All you need to do is open your theme's Twig file: user/themes/<Theme>/templates/partials/archives.html.twig

And replace MONTHS_OF_THE_YEAR with GRAV.MONTHS_OF_THE_YEAR. Then everything works again: 2019-07-29_123432 Found this in the updated documentation (thanks for keeping it up-to-date!)

spin0us commented 5 years ago

Any working solution for Grav v1.6.15 and Archives v1.6.0 ?

01Kuzma commented 3 years ago

Almost 5 years passed since opened issue! Any workaround? {{ month|date(config.plugins.archives.date_display_format) }} returns English date format. {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(post.date|date('n') - 1) }} {{ post.date|date('d') }} doesn't use GRAV.MONTHS_OF_THE_YEAR

eisenherzz commented 3 years ago

What works for me, as a workaround is: {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(month|date('n') -1) }} {{ month|date('Y') }}

If you see no difference (like me while testing) make sure there is no archives.html.twig in user/themes/yourtheme/templates/partials/ respectively alter it there.

01Kuzma commented 3 years ago

@eisenherzz there is another solution, which forum member suggested yesterday: https://discourse.getgrav.org/t/archives-translating-the-date/9435/6

wblondel commented 3 years ago

What works for me, as a workaround is: {{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(month|date('n') -1) }} {{ month|date('Y') }} If you see no difference (like me while testing) make sure there is no archives.html.twig in user/themes/yourtheme/templates/partials/ respectively alter it there.

Thank you! That's the only solution that works for me. Grav v1.7.7

powerriegel commented 3 years ago

I'm a new user and this bug does not just affect archives but all dates in the front-end. I don't really want to twerk something in code. This often leads to problems later on when the bug if officially fixed.

I'm using Grav 1.7.23 and Antimatter (all other themes have the same bug)

Language is set to German, everywhere. Page itself is German, same with admin-panel.

Screenshot 2021-10-24 at 12-16-15 Blog -> should be OKT in German.

So could cou please keep me updated when this will be fixed by a Grav developer? I really wonder that this bug is open since 5 years.

dannykorpan commented 2 years ago

Same issue here in Germany.

Sogl commented 2 years ago

Still an issue after 6 years...

pboguslawski commented 11 months ago

Another dirty workaround that works for us in Quark theme is to force date_display_format = Y-m (would be easier with #37) and modify archives.html.twig like below:

-       <a href="{{ base_url }}/{{ config.plugins.archives.taxonomy_names.month }}{{ config.system.param_sep }}{{ month|date('M_Y')|lower|e('url') }}">
+       <a href="{{ base_url }}/{{ config.plugins.archives.taxonomy_names.month }}{{ config.system.param_sep }}{{ month|date(config.plugins.archives.taxonomy_values.month)|lower|e('url') }}">
         {% if archives_show_count %}
         <span class="label label-rounded label-primary">{{ items|length }}</span>
         {% endif %}
-          <span class="archive_date">{{ month|date(config.plugins.archives.date_display_format) }} </span>
+          <span class="archive_date">{{ 'GRAV.MONTHS_OF_THE_YEAR'|ta(month|date('n') - 1) }} {{ month|date('Y') }}</span>