PHP code example of oorrwullie / yii2-babelfishfood

1. Go to this page and download the library: Download oorrwullie/yii2-babelfishfood 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/ */

    

oorrwullie / yii2-babelfishfood example snippets



'components' => [
    'babelfishfood' => [
	'class' => 'oorrwullie\babelfishfood\components\BFFComponent',
	'cookieName' => 'language',                     // Name of the cookie.
	'cookieDomain' => 'example.com',                // Domain of the cookie.
	'expireDays' => 64,                             // The expiration time of the cookie is 64 days.
	'callback' => function() {
	    if (!\Yii::$app->user->isGuest) {
		$user = \Yii::$app->user->identity;
		$user->language = \Yii::$app->language;
		$user->save();
	    }
	}
    ]
]

'language' => 'en',
'bootstrap' => ['babelfishfood'],

'i18n' => [
    'translations' => [
	'menu*' => [
	    'class' => 'yii\i18n\GettextMessageSource',
	    'useMoFile' => false,
	    'basePath' => '@common/messages',
	],
	'home*' => [
	    'class' => 'yii\i18n\GettextMessageSource',
	    'useMoFile' => false,
	    'basePath' => '@common/messages',
	],
	'base*' => [
	    'class' => 'yii\i18n\GettextMessageSource',
	    'useMoFile' => false,
	    'basePath' => '@common/messages',
	],
	'global*' => [
	    'class' => 'yii\i18n\GettextMessageSource',
	    'useMoFile' => false,
	    'basePath' => '@common/messages',
	],
    ],
],

'modules' => [
    'bff' => [
	'class' => 'oorrwullie\babelfishfood\BabelFishFood',
    ],
],

echo \Yii::t('app', 'This is a string to translate!');

<?= \oorrwullie\babelfishfood\BFF::widget(); 

<?= \oorrwullie\babelfishfood\BFF::widget([
    'upperCase' => FALSE,
    'label' => '<i class="fa fa-language"></i>',
]); 
json
php composer.phar 
bash
php yii migrate --migrationPath=@vendor/oorrwullie/yii2-babelfishfood/migrations