The yii2-base application is not supported due to some unresolved dependencies. It will still work however with the following configuration settings:
$params = require(__DIR__ . '/params.php');
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log', 'translatemanager'],
'language' => 'en-US',
'components' => [
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\DbMessageSource',
'db' => 'db',
'sourceLanguage' => 'en-US', // Developer language
'sourceMessageTable' => 'language_source',
'messageTable' => 'language_translate',
'cachingDuration' => 86400,
'enableCaching' => true,
],
],
],
'translatemanager' => [
'class' => 'lajax\translatemanager\Component',
],
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
// 'rules' => [
// // your rules go here
// ],
// ...
],
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'sadasd76as87d6as87d6as7',
],
'cache' => [
'class' => 'yii\caching\FileCache',
],
'user' => [
'identityClass' => 'app\models\User',
'enableAutoLogin' => true,
],
'errorHandler' => [
'errorAction' => 'site/error',
],
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
'useFileTransport' => true,
],
'log' => [
'traceLevel' => YII_DEBUG ? 3 : 0,
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'db' => require(__DIR__ . '/db.php'),
],
'params' => $params,
'modules' => [
'translatemanager' => [
'class' => 'lajax\translatemanager\Module',
'root' => '@webroot', // The root directory of the project scan.
'layout' => null, // Name of the used layout. If using own layout use ‘null’.
'allowedIPs' => ['127.0.0.1'], // IP addresses from which the translation interface is accessible.
// 'roles' => ['@'], // For setting access levels to the translating interface.
'tmpDir' => '@runtime', // Writable directory for the client-side temporary language files.
// IMPORTANT: must be identical for all applications (the AssetsManager serves the JavaScript files containing language elements from this directory).
'ignoredCategories' => ['yii'], // these categories won’t be included in the language database.
'ignoredItems' => ['config'], // these files will not be processed.
'tables' => [ // Properties of individual tables
[
'connection' => 'db', // connection identifier
'table' => 'language', // table name
'columns' => ['name', 'name_ascii'] //names of multilingual fields
]
]
],
],
];
if (YII_ENV_DEV) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii\debug\Module';
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = 'yii\gii\Module';
}
return $config;
Because of the url ovverriding you will have to create a .htaccess file in the web directory.
web/.htaccess
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
I turned off the module’s layout so you can turn on the meu in the site’s own layout.
views/layouts/main.php
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => 'Home', 'url' => ['/site/index']],
['label' => 'About', 'url' => ['/site/about']],
['label' => 'Contact', 'url' => ['/site/contact']],
['label' => Yii::t('language', 'Language'), 'items' => [ // watch your privileges <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/smile.gif' class='bbc_emoticon' alt=':)' />
['label' => Yii::t('language', 'Languages'), 'url' => ['/translatemanager/language/list']],
['label' => Yii::t('language', 'Scan'), 'url' => ['/translatemanager/language/scan']],
['label' => Yii::t('language', 'Optimize'), 'url' => ['/translatemanager/language/optimizer']],
]],
Yii::$app->user->isGuest ?
['label' => 'Login', 'url' => ['/site/login']] :
['label' => 'Logout (' . Yii::$app->user->identity->username . ')',
'url' => ['/site/logout'],
'linkOptions' => ['data-method' => 'post']],
],
]);
The dependencies of the yii2-base application will also be resolved soon.
Best regards,
lajax