lajax / yii2-translate-manager

Translation Manager
MIT License
227 stars 90 forks source link

translate/scan #48

Closed Lawiet closed 8 years ago

Lawiet commented 8 years ago

Good day,

I try ./yii translate/scan

and

Scanning translations... PHP Notice 'yii\base\ErrorException' with message 'Trying to get property of non-object'

in /var/www/html/yii/vendor/lajax/yii2-translate-manager/services/Scanner.php:68

Stack trace:

0 /var/www/html/yii/vendor/lajax/yii2-translate-manager/services/Scanner.php(68): yii\base\ErrorHandler->handleError(8, 'Trying to get p...', '/var/www/html/g...', 68, Array)

1 /var/www/html/yii/vendor/lajax/yii2-translate-manager/commands/TranslatemanagerController.php(37): lajax\translatemanager\services\Scanner->run()

2 [internal function]: lajax\translatemanager\commands\TranslatemanagerController->actionScan()

3 /var/www/html/yii/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)

4 /var/www/html/yii/vendor/yiisoft/yii2/base/Controller.php(151): yii\base\InlineAction->runWithParams(Array)

5 /var/www/html/yii/vendor/yiisoft/yii2/console/Controller.php(91): yii\base\Controller->runAction('scan', Array)

6 /var/www/html/yii/vendor/yiisoft/yii2/base/Module.php(455): yii\console\Controller->runAction('scan', Array)

7 /var/www/html/yii/vendor/yiisoft/yii2/console/Application.php(167): yii\base\Module->runAction('translate/scan', Array)

8 /var/www/html/yii/vendor/yiisoft/yii2/console/Application.php(143): yii\console\Application->runAction('translate/scan', Array)

9 /var/www/html/yii/vendor/yiisoft/yii2/base/Application.php(375): yii\console\Application->handleRequest(Object(yii\console\Request))

10 /var/www/html/yii/yii(19): yii\base\Application->run()

11 {main}

moltam commented 8 years ago

Is your Translate Manager module configured properly in the console app? You should configure the module in the common config, so the scanner can use it.

Lawiet commented 8 years ago

this my web.php

$config = 'log','translatemanager','gii','debug', 'bootstrap' => ['log','translatemanager','gii','debug'], 'layout' => 'main', 'language' => 'es', 'sourceLanguage' => 'es', 'controllerMap' => [ 'translate' => \lajax\translatemanager\commands\TranslatemanagerController::className(), ],

moltam commented 8 years ago

The module declaration is probably missing. Add this to your config in config/console.php:

'modules' => [
    'translatemanager' => [
        'class' => 'lajax\translatemanager\Module',
    ],
],
moltam commented 8 years ago

Sorry, I mean config/console.php config file (if you are using basic app). (I edited the prev. comment)

moltam commented 8 years ago

Also you should have the same configuration for web and console. I am not very familiar with the basic app, but I think you should create a separate module config file for the extension, then require in each config file.

Create console/translatemanager.php:

return [
    'class' => 'lajax\translatemanager\Module',
    // additional config ...
];

In the web.php and console.php:

'modules' => [
    'translatemanager' => require(__DIR__ . '/translatemanager.php'),
],
Lawiet commented 8 years ago

Ok, very thanks.

console.php

return [ 'id' => 'basic-console', 'basePath' => dirname(DIR), 'bootstrap' => ['log', 'gii'], 'controllerNamespace' => 'app\commands', 'modules' => [ 'gii' => 'yii\gii\Module', 'translatemanager' => [ 'class' => 'lajax\translatemanager\Module', ], ], 'controllerMap' => [ 'translate' => \lajax\translatemanager\commands\TranslatemanagerController::className(), ],

and web.php

$config = 'log','translatemanager','gii','debug', 'bootstrap' => ['log','translatemanager','gii','debug'], 'layout' => 'main', 'language' => 'es', 'sourceLanguage' => 'es', 'controllerMap' => [ 'translate' => \lajax\translatemanager\commands\TranslatemanagerController::className(), ],

....

'modules' => [
    /* ********************** SOLO PARA EDICION SEGUN LA IP ********************** */
    'debug' => [
        'class' => 'yii\debug\Module',
        'allowedIPs' => $allowedIPs,
    ],
    'gii' => [
        'class' => 'yii\gii\Module',
        'allowedIPs' => $allowedIPs,
    ],
    'translatemanager' => [
        'class' => 'lajax\translatemanager\Module',
        'root' => '@app',               // The root directory of the project scan.
        'layout' => 'language',