Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Intl] AddDateIntervalFormatter#39912
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
0169445 to5189d2dCompareUh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Translation/Formatter/DateIntervalFormatter.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
ro0NL commentedJan 21, 2021
there's an interesting ICU concept: listPattern relative/duration time formats ideally we'd implement this at the ICU message format level 😁 but that's far fetched. overall, having a generic localized interval formatter in the Intl component seems more useful. |
fancyweb commentedJan 21, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I agree and we could use it in the Validator component too for#33401 |
2888345 to7f6cbbaCompareb43f917 to0ed15bdComparesrc/Symfony/Component/Intl/Tests/DateIntervalFormatter/DateIntervalFormatterTest.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
1c09134 to894cc36CompareYaFou commentedJun 26, 2021
Ready for review |
| useTwig\Extension\AbstractExtension; | ||
| useTwig\TwigFilter; | ||
| class IntlExtensionextends AbstractExtension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What about doing this inhttps://github.com/twigphp/intl-extra/blob/2.x/IntlExtension.php instead?
Currently it may conflict withhttps://github.com/twigphp/twig-extra-bundle/blob/2.x/Resources/config/intl.php.
nicolas-grekasOct 18, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think@HeahDude's idea is a good one. Can you please remove that code from this PR and move it to twig instead?
sstok commentedJul 4, 2021
FYIhttps://carbon.nesbot.com/docs/#api-interval provides a fully localized version of DateInterval with |
DateIntervalFormatterOskarStark commentedAug 4, 2021
Open to finish this PR@YaFou ? |
YaFou commentedAug 4, 2021
For me, it is finished. I saw comments which suggest to add ICU but I don't think we have to add something to big to Symfony core. |
nicolas-grekas left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I'm mixed here: I get the value, but what about i18n? Is the language designed to be an implementation detail or should the interface allow declaring it?
In the end, my question ends up as: shouldn't we delegate this to a 3rd party lib, eg Carbon?
| useTwig\Extension\AbstractExtension; | ||
| useTwig\TwigFilter; | ||
| class IntlExtensionextends AbstractExtension |
nicolas-grekasOct 18, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think@HeahDude's idea is a good one. Can you please remove that code from this PR and move it to twig instead?
| ->tag('container.service_subscriber', ['id' =>'translator']) | ||
| ->tag('kernel.cache_warmer') | ||
| ->set('translation.formatter.date_interval', DateIntervalFormatter::class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't get the need for this service
| returnstaticfunction (ContainerConfigurator$container) { | ||
| $container->services() | ||
| ->set('intl.date_interval_formatter', DateIntervalFormatter::class) | ||
| ->alias(DateIntervalFormatterInterface::class,'intl.date_interval_formatter') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
alias should be unindented by one
| 'kernel.reset', | ||
| ]); | ||
| if (class_exists(DateIntervalFormatterInterface::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
interface_exists, since it's not a class but an interface
| 5.4 | ||
| --- | ||
| * Add`DateIntervalFormatter` to humanize a`DateInterval` or a difference between two`DateTimeInterface` objects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
missing space at start of line
| /** | ||
| * @param \DateInterval|string $interval | ||
| */ | ||
| publicfunctionformatInterval($interval,int$precision =0):string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
what is $precision supposed to mean? reading the interface should provide a clue
fabpot commentedOct 30, 2021
Having something like this in core without i18n is a no-go for me. As soon as we will merge it, people will start asking for it and they will be right. |
Uh oh!
There was an error while loading.Please reload this page.
You can set a precision. The precision cuts the formatted content to a given number of elements: