Skip to content

Added a fallback Twig extension when PHP's intl is not available #335

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

Closed
wants to merge 2 commits into from
Closed

Added a fallback Twig extension when PHP's intl is not available #335

wants to merge 2 commits into from

Conversation

javiereguiluz
Copy link
Member

This fixes #329.

@javiereguiluz
Copy link
Member Author

@mtsanford @tcicit @wouterj could you please try the changes proposed in this pull request to see if it solves your problems with Windows + Intl? Thanks!

@tcicit
Copy link

tcicit commented May 12, 2016

I can not find the file. In the demo app, there are only the following file: "\symfony_demo\src\AppBundle\Twig\AppExtension.php".

@bocharsky-bw
Copy link
Contributor

bocharsky-bw commented May 12, 2016

@tcicit You should checkout on fix_329 branch of the https://github.com/javiereguiluz/symfony-demo Javier's forked repo.

@javiereguiluz
Copy link
Member Author

@tcicit if you don't want to mess with Git, you can recreate these changes in your own computer. It's just a matter of creating 2 files and modifying 2 other files. See: https://github.com/symfony/symfony-demo/pull/335/files

@mtsanford
Copy link

mtsanford commented May 12, 2016

I'm actually on a Mac that does not have intl installed. The fix_329 branch seems to work correctly home page renders with comment:

<!-- Page rendered on May 12, 2016 10:26:35 am America/Los_Angeles -->

The "Published At" field for new post shows as "2016-05-12T10:28:37-07:00", but I assume that's the way it's supposed to show.

@wouterj
Copy link
Member

wouterj commented May 12, 2016

While this is probably works fine (didn't test it yet), I think the implementation is very complex (especially for a demo app for beginners):

  • Using PHP config to register the service
  • A full-blown polyfill for intl date formatter

What about creating a render_date() function? This would allow us to get rid of both problems, makes the implementation quite a lot simpler (as it's just intl_enabled ? IntlDateFormatter::create(...)->format(new \DateTime()) : date(...);) and also shows how readable you can make your templates by adding some very tiny functions and filters.

@javiereguiluz
Copy link
Member Author

Closed in favor of #344.

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 this pull request may close these issues.

Don't use localizeddate to avoid Intl errors
5 participants