Hello,

I'm coding a site in php, and i want to add another language/

I used poedit to do po file

I used the _e() func, e.g _e('hello world')

but when i tried to run the site in the localhost, i get an error.

but when i changed the func, i used th _() Func, it's work fine.


What's the problem ?

Thank you

Tito

I don't understand. Which error you get? Can you post a simplified code example?

Hello,

for example
this code

<?php _e('hello world') ?>

doesn't work, and i get this error.

undefined function _e().

when i change it to this code:

<?php echo _('hello world') ?>

it working, and I get the translation

This works for me:

<?php
function _e($w) # define function
{
	return 'hello ' .$w;
}

echo _e('world');
?>

Now: are you loading your _e() function? is this _e() a po function? Are you using php.ini extension directive to load it? bye

Hello,

I want to translate "hello world" in another language by po file and the _e() is a po function

It's not clear to me. PHP is noticing you that _e is not defined, my question are:

1. where is located _e() function? in which file?
2. how do you include it to your script?

This <?php _e('hello world') ?> by itself can't work.

the e() function is in the *.po file.

this is the code to excute it
$locale = "ar_SA";
if (isSet($_GET["locale"])) $locale = $_GET["locale"];
putenv("LC_ALL=$locale");
setlocale(LC_ALL, $locale);
$domain='sanapix';
bindtextdomain($domain, "./languages");
textdomain($domain);
?>

and yes, it's wordpress thing, but also it's working in another apps

I can't help you.

Member Avatar for diafol

the e() function is in the *.po file.

Really? I though that was just plain text.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.