Jump to content

Newline character breaks translation


charger
 Share

Recommended Posts

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?
 

Link to comment
Share on other sites

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