Jump to content

Translatable strings inside traits always showing the original language string [SOLVED]


Juergen
 Share

Recommended Posts

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

  • 2 weeks later...
  • Juergen changed the title to Translatable strings inside traits always showing the original language string [SOLVED]

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...