lajax / yii2-translate-manager

Translation Manager
MIT License
227 stars 90 forks source link

scan root fix #12

Closed Konrad90 closed 9 years ago

Konrad90 commented 9 years ago

I actually wanted to fix windows by splitting at slashes and backslashes:

$directories = preg_split("/(\\\\|\\/)/", Yii::getAlias($this->module->root));

But why even go to parent directory?

lajax commented 9 years ago

I would have preferred to fix this error long ago, but since the optimizer deletes non-detected language elements (it would be quite problematic if translations would be lost just because I change some core components of the system), I decided to release the fix with version 2.0 only.

One good workaround in the current version is to set @web as 'root'.

The reason I stepped back to the parent directory is because in the case of the advanced version, there isn't a single alias that points to the 'root' of the whole project. In the case of the basic version, @app practically equals 'root'. In the case of the advanced version, @app (which is the default 'root' of the TranslateManager module) is only the 'root' of the current application. To make the whole project scannable in a single cycle, I stepped back to the parent directory.

In version 2.0 the 'root' will become 'roots' and will expect an array.

'roots' => [
    '@frontend',
    '@backend',
    '@common',
    '@vendor',
    '@app',
    // ...
]

Thank you for the fix.

Konrad90 commented 9 years ago

Okay, thanks for your clarification.

dantux commented 8 years ago

Hey lajax, does the "root" take only aliases? Can't I just give it a hard coded path? I am using a modified advanced Yii2 template with the structure like this:

/home/me/mywww/_appProtected
/home/me/mywww/public_html/app

So my protected folder is outside the public web folder.

I have an alias set up like this in /home/me/mywww/_appProtected/config/main.php Yii::setAlias('appPath', dirname(dirname(__DIR__))); which is confirmed to point to /home/me/mywww/_appProtected. If I could scan that directory, I would be happy; but if I set the 'root' to '@appPath' in common/config/main.php, it goes to the parent directory (/home/me/mywww/) where I have other projects. If I set it to '@frontend' (which is under /home/me/mywww/_appProtected/frontend), is not finding anything except a few items in the "language" and "arrray" categories. :( What am I doing wrong? And when is version 2 coming out? As you can see, I will need to scan two different locations for this app.