Documentation

TimeDiffTranslator extends Translator
in package
implements TranslatorInterface

October translator class.

Interfaces, Classes and Traits

TranslatorInterface
TranslatorInterface.

Table of Contents

CORE_LOCALE  = 'en'
$events  : Dispatcher|Dispatcher
The event dispatcher instance.
$fallback  : string
The fallback locale used by the translator.
$keyParserCache  : array<string|int, mixed>
A cache of the parsed items.
$loaded  : array<string|int, mixed>
The array of loaded translation groups.
$loader  : Loader
The loader implementation.
$locale  : string
The default locale being used by the translator.
$macros  : array<string|int, mixed>
The registered string macros.
$parsed  : array<string|int, mixed>
A cache of the parsed items.
$selector  : MessageSelector
The message selector.
__call()  : mixed
Dynamically handle calls to the class.
__callStatic()  : mixed
Dynamically handle calls to the class.
__construct()  : void
Create a new translator instance.
addJsonPath()  : void
Add a new JSON path to the loader.
addLines()  : void
Add translation lines to the given locale.
addNamespace()  : void
Add a new namespace to the loader.
choice()  : string
Get a translation according to an integer value.
get()  : string|array<string|int, mixed>|null
Get the translation for the given key.
getFallback()  : string
Get the fallback locale being used.
getFromJson()  : string|array<string|int, mixed>|null
Get the translation for a given key from the JSON translation files.
getLoader()  : Loader
Get the language line loader implementation.
getLocale()  : string
Get the default locale being used.
getSelector()  : MessageSelector
Get the message selector instance.
has()  : bool
Determine if a translation exists.
hasForLocale()  : bool
Determine if a translation exists for a given locale.
hasMacro()  : bool
Checks if macro is registered.
load()  : void
Load the specified language group.
locale()  : string
Get the default locale being used.
macro()  : void
Register a custom macro.
mixin()  : void
Mix another object into the class.
parseKey()  : array<string|int, mixed>
Parse a key into namespace, group, and item.
setEventDispatcher()  : void
Set the event dispatcher instance.
setFallback()  : void
Set the fallback locale being used.
setLocale()  : void
Set the default locale.
setParsedKey()  : void
Set the parsed value of a key.
setSelector()  : void
Set the message selector instance.
trans()  : string
Translates the given message.
transChoice()  : string
Translates the given choice message by choosing a translation according to a number.
getLine()  : string|array<string|int, mixed>|null
Retrieve a language line out the loaded array.
getValidationSpecific()  : string
Check the system namespace by default for "validation" keys.
isLoaded()  : bool
Determine if the given group has been loaded.
keyParserParseBasicSegments()  : array<string|int, mixed>
Parse an array of basic segments.
keyParserParseSegments()  : array<string|int, mixed>
Parse an array of namespaced segments.
localeArray()  : array<string|int, mixed>
Get the array of locales to be checked.
localeForChoice()  : string
Get the proper locale for a choice operation.
makeReplacements()  : string
Make the place-holder replacements on a line.
parseBasicSegments()  : array<string|int, mixed>
Parse an array of basic segments.
parseLocale()  : array<string|int, mixed>
Get the array of locales to be checked.
parseNamespacedSegments()  : array<string|int, mixed>
Parse an array of namespaced segments.
sortReplacements()  : array<string|int, mixed>
Sort the replacements array.

Constants

Properties

$fallback

The fallback locale used by the translator.

protected string $fallback

$keyParserCache

A cache of the parsed items.

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

$loaded

The array of loaded translation groups.

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

$locale

The default locale being used by the translator.

protected string $locale

$macros

The registered string macros.

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

Methods

__call()

Dynamically handle calls to the class.

public __call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__callStatic()

Dynamically handle calls to the class.

public static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
$method : string
$parameters : array<string|int, mixed>
Tags
throws
BadMethodCallException
Return values
mixed

__construct()

Create a new translator instance.

public __construct(Loader $loader, string $locale) : void
Parameters
$loader : Loader
$locale : string
Return values
void

addJsonPath()

Add a new JSON path to the loader.

public addJsonPath(string $path) : void
Parameters
$path : string
Return values
void

addLines()

Add translation lines to the given locale.

public addLines(array<string|int, mixed> $lines, string $locale[, string $namespace = '*' ]) : void
Parameters
$lines : array<string|int, mixed>
$locale : string
$namespace : string = '*'
Return values
void

addNamespace()

Add a new namespace to the loader.

public addNamespace(string $namespace, string $hint) : void
Parameters
$namespace : string
$hint : string
Return values
void

choice()

Get a translation according to an integer value.

public choice(string $key, int|array<string|int, mixed>|Countable $number[, array<string|int, mixed> $replace = [] ][, string $locale = null ]) : string
Parameters
$key : string
$number : int|array<string|int, mixed>|Countable
$replace : array<string|int, mixed> = []
$locale : string = null
Return values
string

get()

Get the translation for the given key.

public get(string $key[, array<string|int, mixed> $replace = [] ][, string|null $locale = null ][, bool $fallback = true ]) : string|array<string|int, mixed>|null
Parameters
$key : string
$replace : array<string|int, mixed> = []
$locale : string|null = null
$fallback : bool = true
Return values
string|array<string|int, mixed>|null

getFallback()

Get the fallback locale being used.

public getFallback() : string
Return values
string

getFromJson()

Get the translation for a given key from the JSON translation files.

public getFromJson(string $key[, array<string|int, mixed> $replace = [] ][, string $locale = null ]) : string|array<string|int, mixed>|null
Parameters
$key : string
$replace : array<string|int, mixed> = []
$locale : string = null
Return values
string|array<string|int, mixed>|null

getLoader()

Get the language line loader implementation.

public getLoader() : Loader
Return values
Loader

getLocale()

Get the default locale being used.

public getLocale() : string
Return values
string

has()

Determine if a translation exists.

public has(string $key[, string|null $locale = null ][, bool $fallback = true ]) : bool
Parameters
$key : string
$locale : string|null = null
$fallback : bool = true
Return values
bool

hasForLocale()

Determine if a translation exists for a given locale.

public hasForLocale(string $key[, string|null $locale = null ]) : bool
Parameters
$key : string
$locale : string|null = null
Return values
bool

hasMacro()

Checks if macro is registered.

public static hasMacro(string $name) : bool
Parameters
$name : string
Return values
bool

load()

Load the specified language group.

public load(string $namespace, string $group, string $locale) : void
Parameters
$namespace : string
$group : string
$locale : string
Return values
void

locale()

Get the default locale being used.

public locale() : string
Return values
string

macro()

Register a custom macro.

public static macro(string $name, object|callable $macro) : void
Parameters
$name : string
$macro : object|callable
Return values
void

mixin()

Mix another object into the class.

public static mixin(object $mixin) : void
Parameters
$mixin : object
Return values
void

parseKey()

Parse a key into namespace, group, and item.

public parseKey(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

setEventDispatcher()

Set the event dispatcher instance.

public setEventDispatcher(Dispatcher $events) : void
Parameters
$events : Dispatcher
Return values
void

setFallback()

Set the fallback locale being used.

public setFallback(string $fallback) : void
Parameters
$fallback : string
Return values
void

setLocale()

Set the default locale.

public setLocale(string $locale) : void
Parameters
$locale : string
Return values
void

setParsedKey()

Set the parsed value of a key.

public setParsedKey(string $key, array<string|int, mixed> $parsed) : void
Parameters
$key : string
$parsed : array<string|int, mixed>
Return values
void

trans()

Translates the given message.

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

The message id (may also be an object that can be cast to string)

$parameters : array<string|int, mixed> = []

An array of parameters for the message

$domain : mixed = 'messages'

The domain for the message or null to use the default

$locale : mixed = null

The locale or null to use the default

Return values
string

The translated string

transChoice()

Translates the given choice message by choosing a translation according to a number.

public transChoice(mixed $id, mixed $number[, array<string|int, mixed> $parameters = [] ][, mixed $domain = 'messages' ][, mixed $locale = null ]) : string
Parameters
$id : mixed

The message id (may also be an object that can be cast to string)

$number : mixed

The number to use to find the index of the message

$parameters : array<string|int, mixed> = []

An array of parameters for the message

$domain : mixed = 'messages'

The domain for the message or null to use the default

$locale : mixed = null

The locale or null to use the default

Return values
string

The translated string

getLine()

Retrieve a language line out the loaded array.

protected getLine(string $namespace, string $group, string $locale, string $item, array<string|int, mixed> $replace) : string|array<string|int, mixed>|null
Parameters
$namespace : string
$group : string
$locale : string
$item : string
$replace : array<string|int, mixed>
Return values
string|array<string|int, mixed>|null

getValidationSpecific()

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

protected getValidationSpecific(string $key, array<string|int, mixed> $replace, string $locale) : string
Parameters
$key : string
$replace : array<string|int, mixed>
$locale : string
Return values
string

isLoaded()

Determine if the given group has been loaded.

protected isLoaded(string $namespace, string $group, string $locale) : bool
Parameters
$namespace : string
$group : string
$locale : string
Return values
bool

keyParserParseBasicSegments()

Parse an array of basic segments.

protected keyParserParseBasicSegments(array<string|int, mixed> $segments) : array<string|int, mixed>
Parameters
$segments : array<string|int, mixed>
Return values
array<string|int, mixed>

keyParserParseSegments()

Parse an array of namespaced segments.

protected keyParserParseSegments(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

localeArray()

Get the array of locales to be checked.

protected localeArray(string|null $locale) : array<string|int, mixed>
Parameters
$locale : string|null
Return values
array<string|int, mixed>

localeForChoice()

Get the proper locale for a choice operation.

protected localeForChoice(string|null $locale) : string
Parameters
$locale : string|null
Return values
string

makeReplacements()

Make the place-holder replacements on a line.

protected makeReplacements(string $line, array<string|int, mixed> $replace) : string
Parameters
$line : string
$replace : array<string|int, mixed>
Return values
string

parseBasicSegments()

Parse an array of basic segments.

protected parseBasicSegments(array<string|int, mixed> $segments) : array<string|int, mixed>
Parameters
$segments : array<string|int, mixed>
Return values
array<string|int, mixed>

parseLocale()

Get the array of locales to be checked.

protected parseLocale(string|null $locale, bool $fallback) : array<string|int, mixed>
Parameters
$locale : string|null
$fallback : bool
Return values
array<string|int, mixed>

parseNamespacedSegments()

Parse an array of namespaced segments.

protected parseNamespacedSegments(string $key) : array<string|int, mixed>
Parameters
$key : string
Return values
array<string|int, mixed>

sortReplacements()

Sort the replacements array.

protected sortReplacements(array<string|int, mixed> $replace) : array<string|int, mixed>
Parameters
$replace : array<string|int, mixed>
Return values
array<string|int, mixed>

Search results