PHP code example of transactpro / phalcon-translate
1. Go to this page and download the library: Download transactpro/phalcon-translate library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
transactpro / phalcon-translate example snippets
$di->setShared('translate', function ($lang = false) use ($config, $di) {
$adapter = new \TransactPro\Translation\Translate(
TranslationModel::class,
$lang
);
// setting default language that will be used when _() called without language parameter
$adapter->setDefaultLanguage('en');
// if fallback language is set, it will look in that translation map for value
$adapter->setFallbackLanguage('de');
/*
* You can also provide them as options in third param array like:
* [
* 'default' => 'en',
* 'fallback' => 'de'
* ]
*/
return $adapter;
});