Comments (9)
Yes, you're right, three filters require an environment: https://github.com/twigphp/intl-extra/blob/2.x/IntlExtension.php#L144 to be somehow injected into the filter.
I tried to solve it in 15 minutes, but without any output for now :-(
from oc-twigextensions-plugin.
Hi, I'm encountering the same issues and the exact same error messages. Our service provider says that the phpIntl extension is installed for my version of PHP.
Do you maybe know of a workaround?
from oc-twigextensions-plugin.
As I said above, the problem is passing Twig\Environment to these filters. So there is no problem with phpIntl installed on hosting/server.
The issue is still open, feel free to send a pull request with the fix.
from oc-twigextensions-plugin.
Hi @vojtasvoboda - thanks for clarifying, I didn't understand fully. I'm afraid that this is a bit above my level of expertise... I hope that maybe someone else is knowledgeable enough to provide a pull request...
from oc-twigextensions-plugin.
stumble on the same error...
I see that the plugin OFFLINE.Mall is succeeding to inject the twig env when it uses the currency formation function for the IntlExtension, but I cant make it work with this plugin.
Maybe that gives you a hint to fix this.
in the plugin.php, I tried this as per the Twig Format_date documentation https://twig.symfony.com/doc/3.x/filters/format_date.html
function register() {
$this->twig = new Environment(new TwigLoader, ['auto_reload' => true]);
$this->twig->addExtension(new IntlExtension());
}
and then adding the filter like this
$filters += [
'format_date' => function ($date, ?string $dateFormat = 'medium', string $pattern = '', $timezone = null, string $calendar = 'gregorian', string $locale = null) use ($twig): string {
$intlExtension = new IntlExtension();
return $intlExtension->formatDate($twig, $date, $dateFormat, $pattern, $timezone, $calendar, $locale);
}
];
from oc-twigextensions-plugin.
@chrisvidal Thanks for the hint about adding an extension directly to the Twig. It works brilliant :-) The new version is ready in the Market as version 2.0.4 🥳
@chocolata Please test, thanks.
from oc-twigextensions-plugin.
Just tested this out and it works perfectly. In my usecase I managed to output the localized month name of my application like this:
{{ '2024-06-01' | format_date('none','MMMM',locale=this.site.locale) }}
Thanks for your work! Much appreciated.
from oc-twigextensions-plugin.
excellent! thanks
however, when I install the plugin on a new installation, I have this error [2024-05-12 17:26:31] production.ERROR: Error: Class "IntlDateFormatter" not found in /var/www/valhiraoka.com/public_html/plugins/vojtasvoboda/twigextensions/Plugin.php:36
I tried to composer update
but it does not change anything.
from oc-twigextensions-plugin.
Related Issues (20)
- Translations sets days months and year with value 1 HOT 1
- base64_encode/decode (enhancement) HOT 1
- Having trouble with the Arabic language HOT 6
- Custom plugin and custom lang.php file HOT 1
- ucfirst filter has wrong behavior.
- Plugin update error HOT 2
- Group By function? HOT 5
- Class 'Twig_Extensions_Extension_Text' not found with OctoberCMS v1.1.1 HOT 5
- Plugin prevents password retrieval HOT 1
- mode-js.js for October plugin - Twig Extensions (I think) HOT 1
- "Target class [twig.environment] does not exist" while running phpunit HOT 1
- Class "Twig_Extension_StringLoader" not found HOT 14
- New version won't update HOT 9
- october 3.x HOT 3
- Struggling to update to latest version HOT 7
- October CMS v3.1 - Upgrade Guide HOT 5
- Incompatible with October v3.0 HOT 4
- Class "IntlDateFormatter" not found HOT 9
- Unknown "truncate" filter. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oc-twigextensions-plugin.