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 localization issue with .Date.Format #273

Open
MirMiz opened this issue Apr 23, 2023 · 1 comment · Fixed by #274
Open

Date localization issue with .Date.Format #273

MirMiz opened this issue Apr 23, 2023 · 1 comment · Fixed by #274

Comments

@MirMiz
Copy link
Contributor

MirMiz commented Apr 23, 2023

Describe the bug
Date localization with .Date.Format doesn't translate e.g. names of Weekdays or Months in diffrent languages well. E.g. if you're trying to use a german datetime format, die Weekdays and Monthnames will stay in english, when using {{ .Date.Format .Site.Params.dateFormat }}

Reproduction steps
set in config.yml

  • languageCode: de
  • defaultContentLanguage: de
  • dateFormat: Mon, 02.01.2006 15:04:05
  • shortDateFormat: 02.01. 15:04
    look at die date of an incident in web view -> english names.

Solution
Use {{ dateFormat .Site.Params.dateFormat .Params.date }} instead.
dateFormat is an alias for time.Format (note: time)
it handles timeformats and translations correctly.

  • layouts/issues/issue.html uses .Date.Format in line 15. in line 55 & 74 dateFormat is used.
    -> Change line 15 to {{ dateFormat .Site.Params.dateFormat .Params.date }}
  • layouts/issues/single.html -> change line 24 to {{ dateFormat .Site.Params.dateFormat .Lastmod }}
@MirMiz
Copy link
Contributor Author

MirMiz commented Apr 23, 2023

Additionally:
relative-time on the main page didn't respected the selected dateformat, but defaulted on UTC.
The Title-Attribute (hover) now displays time in the chosen dateformat. an additional Attribut data-date contains the UTC-Format for calculating the relative times using JavaScript. this way the hover shows the date in the selected format

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

Successfully merging a pull request may close this issue.

1 participant