\Aura\IntlTranslatorLocator

A ServiceLocator implementation for loading and retaining translator objects.

Summary

Methods
Properties
Constants
__construct()
setLocale()
getLocale()
getFactory()
getPackages()
getFormatters()
get()
No public properties found
No constants found
No protected methods found
$registry
$locale
$factory
$packages
$formatters
N/A
No private methods found
No private properties found
N/A

Properties

$registry

$registry : array

A registry to retain translator objects.

Type

array

$locale

$locale : string

The current locale code.

Type

string

Methods

__construct()

__construct(\Aura\Intl\PackageLocator  $packages, \Aura\Intl\FormatterLocator  $formatters, \Aura\Intl\TranslatorFactory  $factory, string  $locale) 

Constructor.

Parameters

\Aura\Intl\PackageLocator $packages

The package locator.

\Aura\Intl\FormatterLocator $formatters

The formatter locator.

\Aura\Intl\TranslatorFactory $factory

A translator factory to create translator objects for the locale and package.

string $locale

The default locale code to use.

setLocale()

setLocale(string  $locale) : void

Sets the default locale code.

Parameters

string $locale

The new locale code.

getLocale()

getLocale() : string

Returns the default locale code.

Returns

string

get()

get(string  $name, string  $locale = null) : \Aura\Intl\TranslatorInterface

Gets a translator from the registry by package for a locale.

Parameters

string $name

The translator package to retrieve.

string $locale

The locale to use; if empty, uses the default locale.

Returns

\Aura\Intl\TranslatorInterface

A translator object.