Juergen Posted December 3, 2021 Share Posted December 3, 2021 Hello community, I am struggeling with a problem that translatable strings inside a trait will not display the correct language translation. I use the trait inside a class and include it inside the class like this <?php namespace MyNameSpace; use function ProcessWire\_; class myClass { use activation; public function myMethod() { return $this->function test(); } ] Only to mention : I use a custom namespace. The trait looks like this <?php namespace MyNameSpace; trait activation { public function test() { return $this->_('My text'); } } The problem is that "My text" will not be translated to the other languages independent of the which $user->language is set. Maybe someone has a solution for this problem and could post it here. Link to comment Share on other sites More sharing options...
Juergen Posted December 14, 2021 Author Share Posted December 14, 2021 Silly mistake!!! Trait is not a class, so using $this was not a good idea ? // use __('myString'); // and not $this->_('myString'); // inside traits Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now