• I am working in
    /themes/my-template/index.php

    inside index.php I’m using ajax script from file
    /themes/my-template/ajax/my-ajax-script.php

    The problem is, that _e() translation is working everywhere BUT not in my-ajax-script.php

    Inside my-ajax-script.php i have added at the top:
    include_once(‘../../../../wp-blog-header.php’);

    Still doesn’t work. Thanks for help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter cugok

    (@cugok)

    I will provide more info:

    In index.php

    function getall() {
    		$.ajax({
    			type: "post",
    			url: "<?php bloginfo('template_url'); ?>/ajax/my-ajax-script.php",
    			success: function(data){ console.log(data) }
    ...

    In my-ajax-script.php:

    include_once('../../../../wp-blog-header.php');
    <?php _e('Translated text', 'mytemplate'); ?>

    _e(‘Translated text’ is copied from other php file where it’s working.

    Ajax is working but I’m getting not translated text.

    I have the exact same problem, adding the include to wp-blog-header.php usually works for ajax stuff, did you fix this?

    Thread Starter cugok

    (@cugok)

    I didn’t remember how I solve the problem. Probably I used qtranslate plugin I sent an additional data field called i.e. ‘lang’ and then using qtranslate I create a
    $string = “<!–:en–>english text<!–:–><!–:de–>german text<!–:–>”;
    and then use in ajax: qtrans_use($lang, $string);

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘_e() in ajax script doesn't translate text’ is closed to new replies.