mtownsend5512/read-time

Error without translation array

dragonfire1119 opened this issue · 3 comments

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'
	] 
])

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');

@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.

Glad you got it sorted :)