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

DateTimeRangeValidator not usable caused by DateFormat validation or incorrect translation format type #3323

Open
andigehle opened this issue Feb 23, 2024 · 0 comments

Comments

@andigehle
Copy link

andigehle commented Feb 23, 2024

When using the DateTimeRangeValidator and submitting a form with such an date which is invalid, the following error messages are used: (See the placeholder definition in lower case "datetime")

<source>The given date must be between {0,datetime,datetime} and {1,datetime,datetime}</source>
</trans-unit>
<trans-unit id="1324315107" xml:space="preserve">
<source>The given date must be after {0,datetime,datetime}</source>
</trans-unit>
<trans-unit id="1324315115" xml:space="preserve">
<source>The given date must be before {0,datetime,datetime}</source>

The translation string like {1, datetime, datetime} goes through the DateTimeFormatter and validates by DateReader::validateFormatType

public static function validateFormatType(string $formatType): void

The validation here checks hard on camelcase value "dateTime" and so the translation placeholder "datetime" throws an error to be not a valid format.

Exception: Provided formatType, "datetime", is not one of allowed values.
Trace:
Neos\Flow\I18n\Cldr\Reader\DatesReader_Original::validateFormatType("datetime")
Neos\Flow\I18n\Formatter\DatetimeFormatter_Original::format(DateTime, Neos\Flow\I18n\Locale, array|1|)
Neos\Flow\I18n\FormatResolver_Original::resolvePlaceholders("The given date must be after {0,datetime,datetime}", array|1|, Neos\Flow\I18n\Locale)

Possible solution:

  • Change the placeholder string in all translation files for DateTimeRange from "datetime" to "dateTime"
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

No branches or pull requests

1 participant