Translator

Winter translator class.

 class Winter\Storm\Translation\Translator
extends Illuminate\Translation\Translator

Extends

Constants

Constant Description
CORE_LOCALE
string "en"

Properties

protected $aliases : array

List of namespace aliases. ['aliased.namespace' => 'real.namespace']

protected $events : Illuminate\Contracts\Events\Dispatcher | Winter\Storm\Events\Dispatcher | null

The event dispatcher instance.

Methods

public get (string $key, array $replace = [], string | null $locale = null, boolean $fallback = true) : string | array | null

Get the translation for the given key.

Parameters
Property Description
$key
string
$replace
array
$locale
string | null
$fallback
boolean
Returns
string | array | null

public parseKey (string $key) : array

Parse a key into namespace, group, and item.

Parameters
Property Description
$key
string
Returns
array

public registerNamespaceAlias (string $namespace, string $alias) : void

Register a namespace alias.

Parameters
Property Description
$namespace
string

The namespace to register an alias for. Example: winter.blog

$alias
string

The alias to register. Example: rainlab.blog

Returns
void

public set (array | string $key, $value = null, $locale = null) : void

Set the language string value for a given key in a given locale.

If no locale is provided, the language string will be set for the default locale.

Parameters
Property Description
$key
array | string
$value
mixed
$locale
mixed
Returns
void

public setEventDispatcher (Illuminate\Contracts\Events\Dispatcher $events) : void

Set the event dispatcher instance.

Parameters
Property Description
$events
Illuminate\Contracts\Events\Dispatcher
Returns
void

public trans (string $key, array $replace = [], string $locale = null) : string | array | null

Get the translation for a given key.

Parameters
Property Description
$key
string
$replace
array
$locale
string
Returns
string | array | null

public transChoice (string $key, int | array | Countable $number, array $replace = [], string $locale = null) : string

Get a translation according to an integer value.

Parameters
Property Description
$key
string
$number
int | array | Countable
$replace
array
$locale
string
Returns
string

protected getValidationSpecific (string $key, array $replace, string $locale) : string | null

Check the system namespace by default for "validation" keys.

Parameters
Property Description
$key
string
$replace
array
$locale
string
Returns
string | null

protected localeArray (string | null $locale) : array

Get the array of locales to be checked.

Parameters
Property Description
$locale
string | null
Returns
array

protected localeForChoice ($locale)

Parameters
Property Description
$locale
mixed
Returns
mixed
Copyright © 2024 Winter CMS