kirby-date-methods icon indicating copy to clipboard operation
kirby-date-methods copied to clipboard

"tt(): Argument #4 ($locale) must be of type ?string, array given, called in /site/plugins/kirby-date-methods/index.php on line 317"

Open tobimori opened this issue 1 year ago • 4 comments
trafficstars

I'm running a multi-language setup and this snippet:

CleanShot 2024-02-13 at 17 51 30@2x

always returns an array for me, which results in the error.

My language file looks like this:

<?php

return [
	'code' => 'en',
	'default' => true,
	'direction' => 'ltr',
	'locale' => [
		'LC_ALL' => 'en_US'
	],
	'name' => 'English',
	'translations' => [],
	'url' => '/'
];

Although I tried the following and it didn't work as well:

<?php

return [
	'code' => 'en',
	'default' => true,
	'direction' => 'ltr',
	'locale' => 'en_US',
	'name' => 'English',
	'translations' => [],
	'url' => '/'
];

tobimori avatar Feb 13 '24 16:02 tobimori

Thanks for the report! You are on Kirby 4, I guess?

nilshoerrmann avatar Feb 14 '24 08:02 nilshoerrmann

We have to adjust our code to also handle full locale arrays. But you say setting a locale as string didn't work either – that's a bit strange because I know this to be working. Are you getting the same error or something else?

nilshoerrmann avatar Feb 14 '24 08:02 nilshoerrmann

same error

tobimori avatar Feb 14 '24 09:02 tobimori

Would you mind checking, if this change fixes your issue (adding LC_ALL to the locale method call):

if (kirby()->language()) {
	$locale = kirby()
		->language()
		->locale(LC_ALL);
} else {
	$locale = option('locale');
}

nilshoerrmann avatar Feb 14 '24 10:02 nilshoerrmann