lajax / yii2-translate-manager

Translation Manager
MIT License
227 stars 90 forks source link

Not having access to the .js file containing the translations. #10

Closed AndreSilva1993 closed 9 years ago

AndreSilva1993 commented 9 years ago

Good morning. Currently I'm using your translate manager in order to make the whole translation process a whole lot easier. It works beautifully but I have a single question. Just like your README said, I created a GlobalController so that every single one would extend this one. This Global is used to register the javascript files needed to support muli-language support on client-side.

class Controller extends \yii\web\Controller {

    /**
     * Method used to register JavaScript in order to translate them.
     */
    public function init() {
        Language::registerAssets();
        parent::init();
    }

}

My question is how am I supposed to register the javascript file containing the translations? When I use the above controller, the only javascript files registered are the following:

md5.js
lajax.js

I'm registering the one containing the translations like this:

this->registerJsFile('/yii2shop/frontend/TranslateJS/translate/' . \Yii::$app->language . '.js');

Am I doing something wrong or is this the way to register the file? In the README it says that the assetsmanager serves the Javascript files necessary files. The files mentioned are those two I mentioned above or is the one containing the translations included too?

Best Regards, André Silva

lajax commented 9 years ago

Hi!

The problem is probably that the path of the language file is wrong or missing.

'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).

You have to change the value of the tmpDir, be aware it has to point to a writeable directory, and all the applications should be able to reach it.

examples:

advanced version:

'tmpDir' => '@backend/runtime',

or

'tmpDir' => '@frontend/runtime',

Best regards, Lajax