0

<?php _e( 'text', 'textdomain'); ?> is used to translate text in themes and plugins. But what if i have a php function that defines text as a variable:

$textoutput = 'blablabla';

In another document the variable is echoed:

echo $textoutput;

How to translate the 'blablabla' text? $textoutput = _e( 'blablabla', 'textdomain'); doesnt work.

Thank you.

Narendrasingh Sisodia
21.4k6 gold badges51 silver badges54 bronze badges
asked Jun 1, 2015 at 12:41

1 Answer 1

4

_e( 'blablabla', 'textdomain'); is used for echoing to the browser, not for assignment to a variable.

If you wish to assign it to a variable you need to use a different function which is $variable = __( 'blablabla', 'textdomain')

that means these code lines of code do the same thing

_e( 'blablabla', 'textdomain');
echo __( 'blablabla', 'textdomain');
$variable = __( 'blablabla', 'textdomain');
echo $variable;

More information on wordpress i18n can be found in the documentation

answered Jun 1, 2015 at 12:53
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.