\Translate\ServiceTranslationManager

This is the factory class for TranslationManager service. The purpose of the factory is to instantiate the service and pass it dependencies (inject dependencies).

Summary

Methods
Properties
Constants
__construct()
setDirectories()
getLocalesWithTranslations()
getPoFiles()
getAllTranslations()
getTranslationArray()
updateTranslation()
getAllLocales()
checkLocaleIsEnabled()
getTextDomain()
getUrl()
getLocale()
No public properties found
No constants found
checkForPoFiles()
readTranslation()
getMoFile()
$directories
$languages
$languageManager
N/A
No private methods found
No private properties found
N/A

Properties

$directories

$directories : array

Array of directories where PO files are stored

Type

array

$languages

$languages : array

Array of languages that are used in application

Type

array

$languageManager

$languageManager : \Translate\Service\Translate\Service\LanguageManager

Language Manager that handles logic surrounding the site languages

Type

\Translate\Service\Translate\Service\LanguageManager

Methods

__construct()

__construct(\Translate\Service\Translate\Service\LanguageManager  $languageManager) 

instantiate class and inject array of languages and array of directories that contain the language flag images

Parameters

\Translate\Service\Translate\Service\LanguageManager $languageManager

setDirectories()

setDirectories(array  $directories) 

Set up the directories array where the PO files are saved

Parameters

array $directories

getLocalesWithTranslations()

getLocalesWithTranslations() : array

Get locales that have corresponding PO files

Returns

array

getPoFiles()

getPoFiles(string|boolean  $locale = false) : array

Get array containing the (absolute) file paths of all PO files

Parameters

string|boolean $locale

Returns

array

getAllTranslations()

getAllTranslations(string  $type, string  $locale) : array

Get array of all translations for a particular locale

Parameters

string $type

untranslated or all

string $locale

the locale for which translations are requested

Returns

array —

array containing the translations

getTranslationArray()

getTranslationArray(string  $type, string  $locale, integer  $idx, integer  $index) : array

Get an array of parameters showing which PO file contains the translated message

Parameters

string $type

all or untranslated

string $locale

the language locale

integer $idx
integer $index

Returns

array

updateTranslation()

updateTranslation(\Translate\Service\arrray  $data) 

Update PO and sync MO file that contains present translation

Parameters

\Translate\Service\arrray $data

getAllLocales()

getAllLocales() : array

Get array of available languages

Returns

array —

of available languages

checkLocaleIsEnabled()

checkLocaleIsEnabled(string  $locale) : boolean

Check whether the passed locale is enabled within the system

Parameters

string $locale

Returns

boolean

getTextDomain()

getTextDomain() : string

Get the text domain = alias of the present controller

Returns

string —

alias of given controller

getUrl()

getUrl(string  $locale = null) : string

Get the URL that is given by the url params

Parameters

string $locale

Returns

string

getLocale()

getLocale() : string

Get the present locale as indicated by the URL params

Returns

string

checkForPoFiles()

checkForPoFiles(string  $file, string  $filepath, string  $locale = false) : array

Check whether a po file exists for a particular locale

Parameters

string $file
string $filepath
string $locale

Returns

array

readTranslation()

readTranslation(string  $filepath, array  $translations, string  $type, integer  $idx) : array

Read the translation for particular language locale and add the $traanslations array

Parameters

string $filepath
array $translations
string $type
integer $idx

Returns

array

getMoFile()

getMoFile(string  $poFile) : string

Get file path to mo file

Parameters

string $poFile

Returns

string