Menu

## LazyTranslator extends AbstractTranslator
in package

TranslatorWeakType.php : 15

### Table of Contents

#### Constants

REGION_CODE_LENGTH = 2

#### Properties

$aliases : array<string, string>
  List of locales aliases.
$directories : array<string|int, string>
  List of custom directories that contain translation files.
$initializing : bool
  Set to true while constructing.
$messages : array<string|int, mixed>
  List of custom localized messages.
$singletons : array<string|int, mixed>
  Translator singletons for each language.

#### Methods

__construct() : mixed
__debugInfo() : array<string|int, mixed>
  Show locale on var_dump().
__serialize() : array<string|int, mixed>
__unserialize() : void
addDirectory() : $this
  Add a directory to the list translation files are searched in.
get() : static
  Return a singleton instance of Translator.
getAvailableLocales() : array<string|int, mixed>
  Returns the list of internally available locales and already loaded custom locales.
getDirectories() : array<string|int, mixed>
  Returns the list of directories translation files are searched in.
getLocalesFiles() : array<string|int, mixed>
  Returns the list of files matching a given locale prefix (or all if empty).
getMessages() : array<string|int, mixed>
  Get messages of a locale, if none given, return all the languages.
removeDirectory() : $this
  Remove a directory from the list translation files are searched in.
resetMessages() : bool
  Reset messages of a locale (all locale if no locale passed).
setDirectories() : $this
  Set list of directories translation files are searched in.
setLocale() : void
  Set the current translator locale and indicate if the source locale file exists
setMessages() : $this
  Set messages of a locale and take file first if present.
setTranslations() : $this
  Set messages of the current locale and take file first if present.
trans() : string
  Returns the translation.
loadMessagesFromFile() : bool
  Init messages language from matching file in Lang directory.
translate() : string
compareChunkLists() : mixed
initialize() : void

### Constants

#### REGION_CODE_LENGTH

AbstractTranslator.php : 26
`public mixed REGION_CODE_LENGTH = 2`

### Properties

#### $aliases

AbstractTranslator.php : 59

List of locales aliases.

`protected array<string, string> $aliases = ['me' => 'sr_Latn_ME', 'scr' => 'sh']`

#### $directories

AbstractTranslator.php : 47

List of custom directories that contain translation files.

`protected array<string|int, string> $directories = []`

#### $initializing

AbstractTranslator.php : 52

Set to true while constructing.

`protected bool $initializing = false`

#### $messages

AbstractTranslator.php : 40

List of custom localized messages.

`protected array<string|int, mixed> $messages = []`

#### $singletons

AbstractTranslator.php : 33

Translator singletons for each language.

`protected static array<string|int, mixed> $singletons = []`

### Methods

#### __construct()

AbstractTranslator.php : 89
`public __construct(mixed $locale[, MessageFormatterInterface|null $formatter = null ][, mixed $cacheDir = null ][, mixed $debug = false ]) : mixed`

##### Parameters

$locale : mixed
$formatter : MessageFormatterInterface|null = null
$cacheDir : mixed = null
$debug : mixed = false

#### __debugInfo()

AbstractTranslator.php : 362

Show locale on var_dump().

`public __debugInfo() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### __serialize()

AbstractTranslator.php : 369
`public __serialize() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### __unserialize()

AbstractTranslator.php : 376
`public __unserialize(array<string|int, mixed> $data) : void`

##### Parameters

$data : array<string|int, mixed>

#### addDirectory()

AbstractTranslator.php : 123

Add a directory to the list translation files are searched in.

`public addDirectory(string $directory) : $this`

##### Parameters

$directory : string

  new directory

##### Return values

$this

#### get()

AbstractTranslator.php : 71

Return a singleton instance of Translator.

`public static get([string|null $locale = null ]) : static`

##### Parameters

$locale : string|null = null

  optional initial locale ("en" - english by default)

##### Return values

static

#### getAvailableLocales()

AbstractTranslator.php : 204

Returns the list of internally available locales and already loaded custom locales.

`public getAvailableLocales([string $prefix = '' ]) : array<string|int, mixed>`

(It will ignore custom translator dynamic loading.)

##### Parameters

$prefix : string = ''

  prefix required to filter result

##### Return values

array<string|int, mixed>

#### getDirectories()

AbstractTranslator.php : 97

Returns the list of directories translation files are searched in.

`public getDirectories() : array<string|int, mixed>`

##### Return values

array<string|int, mixed>

#### getLocalesFiles()

AbstractTranslator.php : 181

Returns the list of files matching a given locale prefix (or all if empty).

`public getLocalesFiles([string $prefix = '' ]) : array<string|int, mixed>`

##### Parameters

$prefix : string = ''

  prefix required to filter result

##### Return values

array<string|int, mixed>

#### getMessages()

AbstractTranslator.php : 291

Get messages of a locale, if none given, return all the languages.

`public getMessages([string|null $locale = null ]) : array<string|int, mixed>`

##### Parameters

$locale : string|null = null

##### Return values

array<string|int, mixed>

#### removeDirectory()

AbstractTranslator.php : 137

Remove a directory from the list translation files are searched in.

`public removeDirectory(string $directory) : $this`

##### Parameters

$directory : string

  directory path

##### Return values

$this

#### resetMessages()

AbstractTranslator.php : 152

Reset messages of a locale (all locale if no locale passed).

`public resetMessages([string|null $locale = null ]) : bool`

Remove custom messages and reload initial messages from matching file in Lang directory.

##### Parameters

$locale : string|null = null

##### Return values

bool

#### setDirectories()

AbstractTranslator.php : 109

Set list of directories translation files are searched in.

`public setDirectories(array<string|int, mixed> $directories) : $this`

##### Parameters

$directories : array<string|int, mixed>

  new directories list

##### Return values

$this

#### setLocale()

AbstractTranslator.php : 301

Set the current translator locale and indicate if the source locale file exists

`public setLocale(string $locale) : void`

##### Parameters

$locale : string

  locale ex. en

#### setMessages()

AbstractTranslator.php : 263

Set messages of a locale and take file first if present.

`public setMessages(string $locale, array<string|int, mixed> $messages) : $this`

##### Parameters

$locale : string
$messages : array<string|int, mixed>

##### Return values

$this

#### setTranslations()

AbstractTranslator.php : 282

Set messages of the current locale and take file first if present.

`public setTranslations(array<string|int, mixed> $messages) : $this`

##### Parameters

$messages : array<string|int, mixed>

##### Return values

$this

#### trans()

TranslatorWeakType.php : 27

Returns the translation.

`public trans(string|null $id[, array<string|int, mixed> $parameters = [] ][, string|null $domain = null ][, string|null $locale = null ]) : string`

##### Parameters

$id : string|null
$parameters : array<string|int, mixed> = []
$domain : string|null = null
$locale : string|null = null

##### Return values

string

#### loadMessagesFromFile()

AbstractTranslator.php : 250

Init messages language from matching file in Lang directory.

`protected loadMessagesFromFile(string $locale) : bool`

##### Parameters

$locale : string

##### Return values

bool

#### translate()

AbstractTranslator.php : 214
`protected translate(string|null $id[, array<string|int, mixed> $parameters = [] ][, string|null $domain = null ][, string|null $locale = null ]) : string`

##### Parameters

$id : string|null
$parameters : array<string|int, mixed> = []
$domain : string|null = null
$locale : string|null = null

##### Return values

string

#### compareChunkLists()

AbstractTranslator.php : 391
`private static compareChunkLists(mixed $referenceChunks, mixed $chunks) : mixed`

##### Parameters

$referenceChunks : mixed
$chunks : mixed

#### initialize()

AbstractTranslator.php : 381
`private initialize(mixed $locale[, MessageFormatterInterface|null $formatter = null ][, mixed $cacheDir = null ][, mixed $debug = false ]) : void`

##### Parameters

$locale : mixed
$formatter : MessageFormatterInterface|null = null
$cacheDir : mixed = null
$debug : mixed = false

## Search results