\Translate\ServiceLanguageManager

Service that handles application languages and locales

Summary

Methods
Properties
Constants
__construct()
onDispatch()
getParams()
getLocale()
getRouteMatch()
getTextDomain()
getLanguagesArray()
getEnabledLanguages()
getAllLocales()
getEnabledLocales()
toggleLanguage()
No public properties found
No constants found
buildLanguageArray()
$routeMatch
$locales
$languages
$enabledLocales
$langauageArray
$localPath
$publicPath
N/A
No private methods found
No private properties found
N/A

Properties

$routeMatch

$routeMatch : \Zend\Router\Http\RouteMatch

Matched Route

Type

\Zend\Router\Http\RouteMatch

$locales

$locales : array

Array of all locales (as passed in configuration)

Type

array

$languages

$languages : array

Array of languages (keys are locales values are the languages)

Type

array

$enabledLocales

$enabledLocales : array

Array of locales (defined in config file)

Type

array

$langauageArray

$langauageArray : array

Associative array of languages with keys for enabled available & missing

Type

array

$localPath

$localPath : \Translate\Service\atring

Local (to server) path to flags folder

Type

\Translate\Service\atring

$publicPath

$publicPath : \Translate\Service\type

public path to flags folder

Type

\Translate\Service\type

Methods

__construct()

__construct(array  $languages) 

Instantiate LanguageManager object and inject $entityManager

Parameters

array $languages

onDispatch()

onDispatch(\Zend\Mvc\MvcEvent  $event) 

on dispatch listener hook that sets the route that is matched

Parameters

\Zend\Mvc\MvcEvent $event

getParams()

getParams() : array

get array of all parameters that were passed to the application

Returns

array

getLocale()

getLocale() : string

Get the present locale

Returns

string

getRouteMatch()

getRouteMatch() : \Zend\Router\Http\RouteMatch

Get the matched route that was passed when listener was called

Returns

\Zend\Router\Http\RouteMatch

getTextDomain()

getTextDomain() : string

Get the present controller (alias for text_domain)

Returns

string

getLanguagesArray()

getLanguagesArray() : array

Get array of languages with keys corresponding to: enabled (languages that are available to the end user) available (languages that have a flag and can be made available to the end user) missing (languages that are defined in the config files but there is no flag available)

Returns

array

getEnabledLanguages()

getEnabledLanguages() : array

Get array of language locales that are enabled for the end user

Returns

array

getAllLocales()

getAllLocales() : array

Get array of all locales that are defined in configuration files

Returns

array

getEnabledLocales()

getEnabledLocales() : array

Get array of locales that are enabled for the end user

Returns

array

toggleLanguage()

toggleLanguage(string  $locale, string  $changeType) : boolean

Enable or disable given language

Parameters

string $locale

the locale to be enabled or disabled

string $changeType

enable|disable language

Throws

\Exception

when the change key does not meed the criteria

Returns

boolean

buildLanguageArray()

buildLanguageArray(string  $locale, string  $language) 

Function that builds the array for getLanguagesArray placing each language in its appropriate category

Parameters

string $locale
string $language