WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using the newest WordPress 3.3.1 and newest qTranslate 2.5.27. I have made some an AJAX script which returns a value and message in the current language.

Here I get my first problem, I solve it by sending in AJAX lang from qtrans_getLanguage() and using messages with qtrans_use($lang, '<!--:pl-->PL message<!--:--><!--:de-->DE message<!--:-->');

I have an wp_option in DB: 'example' = '<!--:pl-->polish text<!--:--><!--:de-->deutschland text<!--:-->' and when using get_option('example') I am always getting Polish text.

I was trying to setlocale in PHP but without any positive result.

get_option() is working correctly in any php WordPress file or template, but not in my AJAX...

EDIT: In template:

$.post('<?php echo get_bloginfo( 'template_url' ); ?>/sendmail.php', {
message: input_message,
lang: input_lang

In sendmail.php:

'destination_email' is set to '<!--:pl-->x@x.pl<!--:--><!--:de-->x@x.de<!--:-->'

$mail = _e(get_option('destination_email'));

Always getting Polish email... even

'setlocale(LC_ALL, 'de_DE')'

Now I'm using hardcode email

$mail = qtrans_use($lang, '<!--:pl-->x@x.pl<!--:--><!--:de-->x@x.de<!--:-->');


share|improve this question
Can you please post actual code, so we can better follow what's going on? – Chip Bennett Jan 25 '12 at 15:20

I'm guessing that you are using language tags around 'polish textdeutschland text' i.e. <!--:pl-->polish text<!--:--><!--:de-->deutschland text<!--:--> but that they got ignored when you posted your answer.

I'm pretty sure what you need to be doing is using the __() (which returns the translation for use in php code) and _e() (echo's direct to screen) wordpress functions. If you look at the qTranslate support forum FAQ #14, he uses the example:

<?php _e("<!--:en-->english text<!--:--><!--:de-->german text<!--:-->"); ?> 

In your case I think you want to use:

<?php __(get_option('example')); ?>

This is assuming that you are using it within your plugin. If you're using it in a page template you'd use:

<?php _e(get_option('example')); ?>
share|improve this answer
I've edited my question. I'm not sure that you understand me. Thanks for the answer. – Mateusz Jan 26 '12 at 13:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.