Jump to content

translating strings in template files


eutervogel
 Share

Recommended Posts

Hi, 
 

when I try to do that in my template:
 

echo "<h2>" . __("Keine Uploads vorhanden") . "</h2>";

I'm running into an error:  Fatal Error: Uncaught Error: Call to undefined function __()

So I tried to do it this way:
 

echo "<h2>" . $this->_("Keine Uploads vorhanden") . "</h2>";

That doesn't produce an error but the translation is not shown.

I used the first version in other websites before and never had an issue;

PW-Version: 3.0.148

What could be wrong here?

Link to comment
Share on other sites

It's hard to tell without getting more informations.

The second call will only work inside a class. The first one should work. 

Where did you place your template file?
Did you add the ProcessWire namespace to your template file?
Could you provide a little more code?

Link to comment
Share on other sites

1 hour ago, eutervogel said:

Thanks guys adding the namespace did it.

But I looked into my other websites a there __() works pretty fine without namespace declaration.

How is that possible?

You probably have disabled "Auto file compiler"?

2046145362_Bildschirmfoto2020-02-22um18_01_33.thumb.png.03eec2f60faafe9098313654281631b8.png

Link to comment
Share on other sites

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