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<!--:-->');
…
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:In your case I think you want to use:
This is assuming that you are using it within your plugin. If you’re using it in a page template you’d use: