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

wrong month format in caption of gantt diagram #1380

Closed
pashutkin opened this issue Apr 3, 2023 · 2 comments
Closed

wrong month format in caption of gantt diagram #1380

pashutkin opened this issue Apr 3, 2023 · 2 comments
Assignees
Labels
bug Something isn't working p:wip Work in progress. Be patient :-)

Comments

@pashutkin
Copy link

pashutkin commented Apr 3, 2023

Description
Wrong month formatting is used for table captions of gantt diagram. Some languages/locales use different word for standalone month name and month as a part of date string.
English word "January" is used for both standalone month name (January'70) and part of date string (The 1st of January 1970).
But Ukrainian, Czech, Greek, Croatian, Russian, Polish, Finnish, Catalan languages have different words. For example, in Greek: "Ιανουάριος 1970" as standalone month and "1 Ιανουαρίου 1970" as a part of date string.

The problem is in Month.java: TextStyle.FULL_STANDALONE and TextStyle.FULL can't be used interchangeably. Specifically it might not be decided on longest criteria.
I would consider to use two separate methods for standalone and partial usage of month name.

To Reproduce
Steps to reproduce the behavior:

@startgantt
language en
project starts on 1970-01-01
[test] lasts 15 days
@endgantt
@startgantt
language el
project starts on 1970-01-01
[test] lasts 15 days
@endgantt
@startgantt
language fi
project starts on 1970-01-01
[test] lasts 15 days
@endgantt
@startgantt
language ru
project starts on 1970-01-01
[test] lasts 15 days
@endgantt

Expected behavior
Correspondingly, captions have to be:
en: January 1970 — correct
el: Ιανουάριος 1970 instead of Ιανουαρίου 1970
fi: Tammikuu 1970 instead of Tammikuuta 1970
ru: Январь 1970 instead of Января 1970

Screenshots
image

Additional context
To illustrate the difference of month representation one may run following code in java:

        for (var language : java.util.List.of("en", "de", "uk","cs","el","hr","ru","pl","fi","ca")) {
            var locale = java.util.Locale.forLanguageTag(language);
            String month = new java.text.SimpleDateFormat("LLLL yyyy", locale).format(new java.util.Date(0));
            String date = java.text.SimpleDateFormat.getDateInstance(java.text.DateFormat.LONG, locale).format(new java.util.Date(0));
            String fullStandaloneName = java.time.Month.JANUARY.getDisplayName(java.time.format.TextStyle.FULL_STANDALONE, locale);
            String fullName = java.time.Month.JANUARY.getDisplayName(java.time.format.TextStyle.FULL, locale);
            int comparison = fullStandaloneName.length() - fullName.length();
            System.out.printf("""
                    Locale "%1$s" / %2$s
                        FULL_STANDALONE = "%3$s", usage: "%4$s"
                        FULL = "%5$s", usage: "%6$s"
                        FULL_STANDALONE.length() - FULL.length() = %7$d
                    %n""", locale, locale.getDisplayName(), fullStandaloneName, month, fullName, date, comparison);
        }
@github-actions github-actions bot added the triage label Apr 3, 2023
arnaudroques added a commit that referenced this issue Apr 10, 2023
@arnaudroques arnaudroques self-assigned this Apr 10, 2023
@arnaudroques arnaudroques added bug Something isn't working p:wip Work in progress. Be patient :-) and removed triage labels Apr 10, 2023
@arnaudroques
Copy link
Contributor

Thanks for the report and for the detailed explanations, it really helps!

The difference between FULL_STANDALONE and FULL was not clear to us :-)

Still, we are not sure to have fixed the issue in last commit.

Is this better better this way ?

return javaTimeMonth.getDisplayName(TextStyle.FULL_STANDALONE, locale);

@pashutkin
Copy link
Author

Yes. Makes sense. At least as long as the method longName is used only for rendering month name without 'day' part.

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p:wip Work in progress. Be patient :-)
Projects
None yet
Development

No branches or pull requests

2 participants