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

Localization: Date format in header should be locale dependent #5059

Closed
vaclavstepan opened this issue Aug 26, 2021 · 3 comments · Fixed by #5071
Closed

Localization: Date format in header should be locale dependent #5059

vaclavstepan opened this issue Aug 26, 2021 · 3 comments · Fixed by #5071
Labels
Milestone

Comments

@vaclavstepan
Copy link
Contributor

Describe the bug
Currently, in event header, the date is formatted using the format_event_date macro.
This macro relies on English locale custom for formatting the event date, which may not be OK for non-English languages.

To Reproduce
Steps to reproduce the behavior:

  1. Go to main page of an event.
  2. Switch to a different language
  3. See the date format in the event header stay the same, e.g. 1-13 listopada for Polish.

Expected behavior
The date format should reflect the language, e.g. probably be set by a translation template.
For Czech it would be 12.–14. září (for example).

Additional context
The macro in question is in modules/events/templates/display/conference/_util.html

@ThiefMaster
Copy link
Member

So what we have there is this:

    {% if start_dt.date() == end_dt.date() %}
        {{ start_dt | format_date('long') }}
    {% elif start_dt.year == end_dt.year and start_dt.month == end_dt.month %}
        {{ start_dt.day }}-{{ end_dt.day }} {{ start_dt | format_date('MMMM yyyy') }}
    {% else %}
        {% trans start=start_dt|format_date('long'), end=end_dt|format_date('long') -%}
            {{ start }} to {{ end }}
        {%- endtrans %}
    {% endif %}

I guess the MMMM yyyy should be made translatable - everything else seems to be OK since it's using locale-dependent translation? Or would you need {{ start_dt.day }}-{{ end_dt.day }} to be translatabel as well in order to add the . after the days?

@vaclavstepan
Copy link
Contributor Author

Yes, format_date('long') is fine, only the line with start_dt.day and end_dt.day does not work well.
The
{{ start_dt.day }}-{{ end_dt.day }} {{ start_dt | format_date('MMMM yyyy') }}

has trouble that it's not using the localized form for the days - in Czech it would be 1.–2. month year, so the dots are needed.
In Czech it would work if one would take the day part from a long format, add dash, then long format for the end date.
I'm not fully sure if this is generally true/enough.

@vaclavstepan
Copy link
Contributor Author

vaclavstepan commented Sep 1, 2021

Similarly there are hardcoded/non-localized date formats in two files in indico/legacy/pdfinterface/latex_templates, the abstract.tex and first_page.tex. Probably all the strftime uses are possibly a trouble.

@ThiefMaster ThiefMaster added this to the v3 milestone Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants