title: PHP inside jQuery for Wordpress translation with WPML
body: <p>Is it possible to implement in jQuery the wordpress function ( <code>_e</code> ) to translate string with WPML ?
  I want to put some text in some div with jQuery and be able to translate this string with WPML.</p>
  
  <pre><code>$('#MyDiv').html(&lt;?php _e('Text to translate', 'woocommerce'); ?&gt;);
  </code></pre>
  
  <p>It doesn t work, is there any way to do it ??
  Thanks in advance</p>
  
  <p><strong>[ANSWER]</strong></p>
  
  <p>@Mukesh Ram, Thanks for your answer but I did not understand pretty well, by the way I have this code ;</p>
  
  <pre><code>$(function() { 
   var left = 35,
       $engraved = $('#MyDiv');
  
   $engraved.closest('li').append('&lt;span id="engraved_counter"&gt;&lt;/span&gt;'); 
   $('#engraved_counter').html("&lt;?php __('Text to translate', 'woocommerce'); ?&gt; &lt;strong&gt;" + left + "&lt;/strong&gt;");
  
    $engraved.keyup(function () {
      left = 35 - $(this).val().length;
  
      if(left &lt; 0){
        $('#engraved_counter').addClass("overlimit");
        left = 0;
      }if(left &gt;= 0){
        $('#engraved_counter').removeClass("overlimit");
      }   
  
     $('#engraved_counter').html("&lt;?php __('Text to translate', 'woocommerce'); ?&gt; &lt;strong&gt;" + left + "&lt;/strong&gt;");
    });
  });
  </code></pre>
  
  <p>Can you tel me please how could I implement the code wich you gived to me ?</p>
  
  <pre><code>$translation_array = array( 'some_string' =&gt; __( 'Some string to translate' ), 'a_value' =&gt; '10' );
   wp_localize_script( 'some_handle', 'object_name', $translation_array );
  </code></pre>
  
  <p>Thank you for your lightening.</p>
  
  <p><strong>[RESOLVED]</strong></p>
  
  <p>Just put in the order the code into your child function.php as mentionned : </p>
  
  <pre><code>function add_scripts_to_head() {
      wp_enqueue_script( 'custom-js', 'www.mysite.com/js/custom.js' );
  
      $translation_array = array( 
      'remain_text' =&gt; __( 'Maximum number of characters : ', 'woocommerce' ) 
      );
      wp_localize_script( 'custom-js', 'count_text', $translation_array );
  
  }
  add_action( 'wp_enqueue_scripts', 'add_scripts_to_head' );
  </code></pre>
  
  <p>And call it to the <strong>js</strong> file like this :</p>
  
  <pre><code>$('#MyDiv').html(count_text.remain_text);
  </code></pre>
  
  <p>Thanks !</p>