Jump to content

Recommended Posts

Posted

I’m on PW 3.0.184 and PHP 7.3.3 and have an issue when I insert a \n into a translation string. The string shows up correctly in the language translator in the backend. However, if I translate the string and then echo it via template file, it won’t return the translated string but its default value. As soon as I remove the \n out of the translation string, the translated value is correctly returned. I used the example from the docs to test:

$out = __("It's time for you \nto get to the party.");  // good 

Can someone confirm this?
 

Posted

I cannot find any example with newline character in the docs? Do I oversee something?

I thought that escape characters are not supported by the translation. If I'm right, maybe it should be written explicitly in the docs too.

I think the right usage is or can be like this:

// use %s with sprintf()
$out = sprintf(__("It's time for you %sto get to the party."), "\n");

 

  • Like 1
Posted

OK, will try to use variables then to insert the newline character. But it’s definitely in the docs. See the attached screenshot.

Bildschirmfoto 2021-09-29 um 22.21.34.png

  • Like 1
Posted
1 hour ago, charger said:

But it’s definitely in the docs. See the attached screenshot.

Ok, I see. Then you should post an issue on github. 

Posted

Hey, @charger!

I just faced the same problem recently. You can make it work like you expect by using single quotes like this:

$out = __('It\'s time for you \nto get to the party.');

Though I would love to see it work with double quotes too)

  • Like 1
Posted

That I noticed too. But in my case I have to use double quotes as I also use variables within the string. Tried every combination I could think of ?

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
  • Recently Browsing   0 members

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