Error without translation array
dragonfire1119 opened this issue · 3 comments
dragonfire1119 commented
Error is:
Argument 1 passed to Mtownsend\ReadTime\ReadTime::setTranslation() must be of the type array, string given
Using it like
read_time([
'content' => $post->content,
])
Tried without array as well
read_time($post->content)
Success when used with
read_time([
'content' => $post->content,
'translation' => [
'reads_left_to_right' => true,
'min' => 'min',
'minute' => 'minute',
'sec' => 'sec',
'second' => 'second',
'read' => 'read'
]
])
mtownsend5512 commented
Hm, I assume you're using Laravel. Did you publish the language files?
php artisan vendor:publish --provider="Mtownsend\ReadTime\Providers\ReadTimeServiceProvider" --tag="read-time-language-files"
When the class is instantiated with Laravel, the ReadTimeServiceProvider attempts to retrieve the language if none is passed.
$translation = isset($data['translation']) ? $data['translation'] : __('read-time');
dragonfire1119 commented
@mtownsend5512 Thanks for the reply! That was the problem. I didn't see that in the README when I was looking to install. Must of skipped over it.
mtownsend5512 commented
Glad you got it sorted :)