Translate Service
Configurations
Translate Configurations
TRANSLATE_LOCALE=en_CA.UTF-8,fr_CA.UTF-8
TRANSLATE_DEFAULT_DOMAIN=messages
TRANSLATE_CATEGORY=5
TRANSLATE_DEFAULT_PATH=./resources/translations/
Translate Service Provider
PROVIDER_TRANSLATE=\Zemit\Provider\Translate\ServiceProvider
Translate Configurations Object
<?php
new Config([
'providers' => [
\Zemit\Provider\Translate\ServiceProvider::class => Env::get('PROVIDER_TRANSLATE', \Zemit\Provider\Translate\ServiceProvider::class),
],
'translate' => [
'locale' => explode(',', Env::get('TRANSLATE_LOCALE', 'en_CA.UTF-8')),
'defaultDomain' => Env::get('TRANSLATE_DEFAULT_DOMAIN', 'messages'),
'category' => Env::get('TRANSLATE_CATEGORY', defined('LC_MESSAGES')? LC_MESSAGES : 5),
'directory' => Env::get('TRANSLATE_DEFAULT_PATH', RESOURCES_PATH . 'translations'),
],
]);
Translate Service (translate
)
Translate Service Provider
Translate Service Provider (translate
): \Zemit\Provider\Translate\ServiceProvider
<?php
// Retrieving the service from an Injectable
$translate = $this->translate;
// Retrieving the service from the DI
$translate = $this->di->get('translate');
// Retrieving the service from the getDI()
$translate = $this->getDI()->get('translate');
// Retrieving the service from anywhere
$translate = Di::getDefault()->get('translate');