Hi,
I’m working on a multilingual site. I use the IntlDateFormatter class to show dates in those languages.
config.php:
return [
'languages' => true,
'date.handler' => 'intl'
]
language file (nl.php):
return [
'code' => 'nl',
'default' => true,
'direction' => 'ltr',
'locale' => [
'LC_ALL' => 'nl_NL'
]
snippet ():
foreach ($structure->filter(fn($entry) => $entry->playdate()->toDate() > time())->sortBy('playdate', 'asc') as $entry):
...
<span class="date"><?= $entry->playdate()->toDate('EEEE d MMMM – H:mm') ?></span>
Locally all works fine. But after uploading to the staging server I get the “Class “IntlDateFormatter” not found” error.
Looks like IntlDateFormatter::formatObject() should not be called statically it should be a server problem but in the Direct Admin PHP option page the “intl” option is checked…
For good measure: I’m currently working in a staging subdomain which is PHP 8.2, but the live site is still running on PHP 7.4, so I deal with the PHP version in the .htaccess
file.
Can I insert some date definition in the htaccess file to force intl? Or do I need to create a fallback like Problem translating month names - #5 by rasteiner?
According to the docs it should not be complicated
The question is if the intl
extension is really enabled, I would check phpinfo() rather than relying on the admin console.
Good catch. When checking this is what’s stated in the phpinfo under Configure Command:
... '--disable-intl' ...
Does this mean it’s indeed disabled?
Not sure, but if it is installed, it should appear in the list below
I forgot to scroll down but searching on “intl” only gave me this one hit…
There’s a “date” section which says
date/time support enabled
Timezone Database internal
Default timezone Europe/Amsterdam
...
date.default_latitude 31.7667 31.7667
date.default_longitude 35.2333 35.2333
date.sunrise_zenith 90.833333 90.833333
date.sunset_zenith 90.833333 90.833333
date.timezone Europe/Amsterdam Europe/Amsterdam
… but that’s about it.
Tomorrow I’ll call those srever guys for help. Thanks @pixelijn
Short follow-up to conclude and maybe helpful for others. On the shared hosting platform there can be one domain and multiple subdomains. Changing the PHP version is forced upon the domain and all subdomains. Using different PHP versions can be done by an instruction on the .htaccess
file of certain subdomain. But all the options set on the main PHP version of the domain don’t trickle down. So intl
wasn’t set on the PHP version in the subdomain.
Solution was to include a PHP version in the .htaccess
file of the domain and bump the overall PHP version with needed settings.