Translator
in package
Basic english only 'translator' for diffForHumans()
Table of Contents
Properties
- $strings : array<string|int, mixed>
- Translation strings.
Methods
- exists() : bool
- Check if a translation key exists.
- plural() : string
- Get a plural message.
- singular() : string
- Get a singular message.
Properties
$strings
Translation strings.
public
static array<string|int, mixed>
$strings
= ['year' => '1 year', 'year_plural' => '{count} years', 'month' => '1 month', 'month_plural' => '{count} months', 'week' => '1 week', 'week_plural' => '{count} weeks', 'day' => '1 day', 'day_plural' => '{count} days', 'hour' => '1 hour', 'hour_plural' => '{count} hours', 'minute' => '1 minute', 'minute_plural' => '{count} minutes', 'second' => '1 second', 'second_plural' => '{count} seconds', 'ago' => '{time} ago', 'from_now' => '{time} from now', 'after' => '{time} after', 'before' => '{time} before']
Methods
exists()
Check if a translation key exists.
public
exists(string $key) : bool
Parameters
- $key : string
-
The key to check.
Return values
bool —Whether or not the key exists.
plural()
Get a plural message.
public
plural(string $key, int $count[, array<string|int, mixed> $vars = [] ]) : string
Parameters
- $key : string
-
The key to use.
- $count : int
-
The number of items in the translation.
- $vars : array<string|int, mixed> = []
-
Additional context variables.
Return values
string —The translated message or ''.
singular()
Get a singular message.
public
singular(string $key[, array<string|int, mixed> $vars = [] ]) : string
Parameters
- $key : string
-
The key to use.
- $vars : array<string|int, mixed> = []
-
Additional context variables.
Return values
string —The translated message or ''.