PHP code example of uran1980 / yii2-translate-panel
1. Go to this page and download the library: Download uran1980/yii2-translate-panel 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/ */
uran1980 / yii2-translate-panel example snippets
return [
...
'components' => [
...
'urlManager' => [
'class' => yii\web\UrlManager::className(),
'enablePrettyUrl' => true,
'showScriptName' => false, // false - means that index.php will not be part of the URLs
],
'i18n' => [
'class' => uran1980\yii\modules\i18n\components\I18N::className(),
'languages' => ['en', 'de', 'fr', 'it', 'es', 'pt', 'ru'],
// Or, if you manage languages in database
//'languages' => function() {
// /* /!\ Make sure the result is a mere list of language codes, and the
// * one used in views is the first one */
// return \namespace\of\your\LanguageClass::find()->where(['active' => true'])->orderBy('default' => SORT_DESC])->select('code')->column();
//},
'format' => 'db',
'sourcePath' => [
__DIR__ . '/../../frontend',
__DIR__ . '/../../backend',
__DIR__ . '/../../common',
],
'messagePath' => __DIR__ . '/../../messages',
// Whether database messages are to be used instead of view ones.
// Enables editing messages in locale specified by
// Yii::$app->sourceLanguage
// Can be set per translation category too
//'forceTranslation' => true,
'translations' => [
'*' => [
'class' => yii\i18n\DbMessageSource::className(),
'enableCaching' => true,
'cachingDuration' => 60 * 60 * 2, // cache on 2 hours
// Whether database messages are to be used instead of view
// ones. Enables editing messages in view code locale.
// Can be set globally too.
//'forceTranslation' => true,
],
],
],
...
],
...
];
return [
...
'modules' => [
...
'i18n' => [
'class' => uran1980\yii\modules\i18n\Module::className(),
'controllerMap' => [
'default' => uran1980\yii\modules\i18n\controllers\DefaultController::className(),
],
// example for set access control to module (if 'allow' => true,
'roles' => ['translator'],
]
],
],
],
...
],
...
]