Properties

$directories

$directories : array

Array of PO/MO file directories

Type

array

$textDomainKey

$textDomainKey : string

Present text domain key = controller alias

Type

string

$translators

$translators : array

Type

array — of Gettext\Translations

$translationFileExists

$translationFileExists : boolean

Flag to show whether translation file exists

Type

boolean

$poFile

$poFile : string

Present PO location file

Type

string — the location of (present) PO file

$moFile

$moFile : string

Type

string — the location of (present) MO file

Methods

__construct()

__construct(array  $filePatterns) 

Instantiate TranslationSaver object injecting file patters

Parameters

array $filePatterns

setTranslationManager()

setTranslationManager(\Translate\Service\TranslationManager  $translationManager) 

Set the translation manager

Parameters

\Translate\Service\TranslationManager $translationManager

Throws

\Exception

if global

getPoFileLocation()

getPoFileLocation(string  $textDomainKey, string  $locale) : string

Get file location of PO file for specific text domain (controller alias) and locale

Parameters

string $textDomainKey
string $locale

Returns

string

createNewPoFile()

createNewPoFile(string  $location, string  $locale) 

Create PO file when missing

Parameters

string $location
string $locale

getTranslator()

getTranslator(string  $textDomainKey, string  $locale) : \Translate\Service\Gettext\Translations|false

Get the Gettext\Translations object

Parameters

string $textDomainKey
string $locale

Returns

\Translate\Service\Gettext\Translations|false

saveMissingTranslation()

saveMissingTranslation(string  $message, string  $locale, string  $translation) 

Save translation for particular message if missing

Parameters

string $message
string $locale
string $translation

messageAlreadyExists()

messageAlreadyExists(string  $message, \Gettext\Translations  $translator) : boolean

Check whether message already exists in translator

Parameters

string $message
\Gettext\Translations $translator

Returns

boolean —

whether message already exists in the translator

updateMoFile()

updateMoFile(\Gettext\Translations  $translator) 

Update MO file based on corresponding PO file

Parameters

\Gettext\Translations $translator

rationaliseFilePattern()

rationaliseFilePattern(array  $pattern) 

Transform controller patterns into location array Controller alias as key and directory as value

Parameters

array $pattern