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

date format and translate #8

Open
ocean123 opened this issue Mar 16, 2016 · 33 comments
Open

date format and translate #8

ocean123 opened this issue Mar 16, 2016 · 33 comments
Labels

Comments

@ocean123
Copy link

Hi,

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

best regards

@flaviocopes
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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

@ocean123
Copy link
Author

?? strange.

schermafbeelding 2016-03-16 om 11 55 37

@ocean123
Copy link
Author

see syndes.nl

@flaviocopes
Copy link
Contributor

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

@ocean123
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

Archive version 1.4.0.

@ocean123
Copy link
Author

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

@flaviocopes
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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

schermafbeelding 2016-03-16 om 14 44 05

@flaviocopes
Copy link
Contributor

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
Copy link
Author

thanks a lot 👍

@Duke3D
Copy link

Duke3D commented Apr 26, 2017

@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
Copy link

Duke3D commented Apr 26, 2017

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

@eisenherzz
Copy link

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
Copy link

zaszlo commented Sep 4, 2018

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

@n3tman
Copy link

n3tman commented Mar 19, 2019

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 There should be field for MONTHS_OF_THE_YEAR where to add translated month text.  #2 (comment)
  2. Fix from documentation using Twig Extensions plugin:
<span class="archive_date">{{ month|localizeddate('none', 'none', 'ru', 'Europe/Moscow', 'LLLL y')|capitalize }}</span>```

@dragonandy
Copy link

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
Copy link
Member

rhukster commented May 9, 2019

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
Copy link

n3tman commented Jul 29, 2019

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
Copy link

spin0us commented Aug 28, 2019

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

@01Kuzma
Copy link

01Kuzma commented Jan 30, 2021

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
Copy link

eisenherzz commented Jan 31, 2021 via email

@01Kuzma
Copy link

01Kuzma commented Feb 1, 2021

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

@wblondel
Copy link

wblondel commented Mar 13, 2021

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
Copy link

powerriegel commented Oct 24, 2021

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
Copy link

Same issue here in Germany.

@Sogl
Copy link

Sogl commented Jul 13, 2022

Still an issue after 6 years...

@pboguslawski
Copy link

pboguslawski commented Dec 6, 2023

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests