title: qTranslate slug, get url of post in other language in Ajax call
body: <p>I'm making a bilingual Wordpress site. I want to load posts via AJAX and have a link to the same post, but in the other language. I'm using qTranslate slug and usually I rely on the global $qtranslate_slug variable like so:</p>
  
  <pre><code>$qtranslate_slug-&gt;get_current_url($targetLang);
  </code></pre>
  
  <p>This works fine if you are on post page, but it doesn't work in an ajax loaded post. </p>
  
  <p>In my AJAX call, I'm setting the post object this way:</p>
  
  <pre><code>$post = get_post($postId);
  setup_postdata($post);
  </code></pre>
  
  <p>I get all the data from the post, I'm just not sure what function to call to set the $qtranslate_slug object. In the ajax call, $qtranslate_slug->current_url is an empty array.</p>
  
  <p><strong><em>UPDATE 1</em></strong></p>
  
  <p>This is probably not the right way, but I called wp() in my ajax call and it set the $qTranslate_slug object. HOWEVER, the links are "ugly" i.e. <a href="http://example.com/fr/?id=68" rel="nofollow">http://example.com/fr/?id=68</a> 
  How can i get the pretty url?</p>
  
  <p><strong><em>UPDATE 2</em></strong>
  in functions.php, i have the following function:</p>
  
  <pre><code>function t($fr, $en){
      switch(qtrans_getLanguage()){
          case "fr":
              return $fr;
          default:
              return $en;
      }
  }
  </code></pre>
  
  <p>Here's my ajax code:</p>
  
  <pre><code>&lt;?php
  global $qtranslate_slug;
  if(isset($_GET["id"])){
      $siteRoot = dirname(__FILE__) . "/../../../../";
      require_once $siteRoot . "wp-load.php";
      wp();
      $post = get_post($_GET["id"]);
      setup_postdata($post);
  
      // generate post html. I didn't include it here, because it has nothing to do with the problem.
      ?&gt;
      &lt;script&gt;
          var alternateUrl = "&lt;?php echo $qtranslate_slug-&gt;get_current_url(t('en', 'fr')); ?&gt;";
      &lt;/script&gt;
  
  &lt;?php } ?&gt;
  </code></pre>
  
  <p><strong><em>UPDATE 3</em></strong></p>
  
  <p>qTranslate gives you a url in the style of: <a href="http://example.com/fr/?id=68" rel="nofollow">http://example.com/fr/?id=68</a>
  If the "id" is changed to "p", the url will be converted to a pretty url when you visit the page. However, I would still like to know how to get the pretty version to be displayed in the link.</p>