Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript not being translated #148

Open
BjornNystrom opened this issue Dec 8, 2021 · 3 comments
Open

Javascript not being translated #148

BjornNystrom opened this issue Dec 8, 2021 · 3 comments

Comments

@BjornNystrom
Copy link

So I have an issue, and it appeared when i swapped over my application from the basic template to advanced, or somewhere along the line. translate manager finds my strings and they are stored in the database, however when presenting the messages they are not translated.

Now I am sure I am missing something in my configuration but I can not seem to find it...

If i place some console logs in the generated lajax.js in assets I can see that it receives the message but if i do a console.log on languageItems it tells me it is undefined. And I am not sure how to define this variable.

Anyone have any ideas?

PS! the php translations works a charm

@panrus
Copy link

panrus commented Dec 8, 2021

namespace common\controllers;

use lajax\translatemanager\helpers\Language;

// IMPORTANT: all Controllers must originate from this Controller!
class Controller extends \yii\web\Controller {

    public function init() {
        Language::registerAssets();
        parent::init();
    }
}

@BjornNystrom
Copy link
Author

Thanks for the reply I have a controller that all other controllers originate from that I've called BaseController and I have this script in that one, however I've used the full:
\lajax\translatemanager\helpers\Language::registerAssets();
since I have another class called Language used in this controller, could this be the problem? that I have 2 language classes here?

@BjornNystrom
Copy link
Author

I'm slightly thinking Where does the javascript bit get the language from, because we have done some modifications to the language select where we create cookies etc based on what user has in their settings or the browsers language etc, and while we do set Yii::$app->language; correctly, im thinking if the cookie is wrong for what is needed for JS or if there is something else we need to set in order for the javascript to know what language to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants