title: OctoberCMS Translate plugin redirect with hash
body: <p>I am using OctoberCMS Translate plugin (<a href="https://octobercms.com/plugin/rainlab-translate" rel="nofollow noreferrer">https://octobercms.com/plugin/rainlab-translate</a>) and its working as per my expectations.</p>
  
  <p>However, I have one custom requirement in which I am generating hash in url (i.e. <a href="http://localhost/ibis/whats-on/details#2020-sydney-international-whitewater-event" rel="nofollow noreferrer">http://localhost/ibis/whats-on/details#2020-sydney-international-whitewater-event</a> - <strong>#2020-sydney-international-whitewater-event</strong>).</p>
  
  <p>Now the thing is, when I am supposed to redirect using below code, </p>
  
  <pre><code> {% for code, name in locales %}
    &lt;a class="dropdown-item" href="#" data-request="onSwitchLocale" data-request-data="locale: '{{ code }}'"&gt;
        {{ name |upper }}
    &lt;/a&gt;
  </code></pre>
  
  <p>I am able to redirect, however, my url looses its hash tag and it becomes something like <strong><a href="http://localhost/ibis/fr/whats-on/details" rel="nofollow noreferrer">http://localhost/ibis/fr/whats-on/details</a></strong> (<strong>fr</strong> is my selected french language). </p>
  
  <p>Here below  is my overwrite code in my layout's code tab to <code>onSwitchLocale</code> method which is  provided by <strong>Translate plugin</strong>.</p>
  
  <pre><code>use RainLab\Translate\Models\Locale as LocaleModel;
  use RainLab\Translate\Classes\Translator;
  use October\Rain\Router\Router as RainRouter;
  
  
  function onSwitchLocale()
  {
      $this-&gt;translator = Translator::instance();
      $locale = post('locale');
  
      if (!$locale = post('locale')) {
              return;
      }
      $this-&gt;translator-&gt;setLocale($locale);
  
      $pageUrl = $this-&gt;translator-&gt;withPreservedQueryString($this-&gt;translator-&gt;makeLocaleUrlFromPage($locale), $locale);
      if ($this-&gt;property('forceUrl')) {
          return Redirect::to($this-&gt;translator-&gt;getPathInLocale($pageUrl, $locale));
      }
  
      return Redirect::to($pageUrl);
  }
  </code></pre>
  
  <p>As you can see I am trying to accomplish url redirect with hash, but I am getting error here saying </p>
  
  <blockquote>
    <p>Call to undefined method RainLab\Translate\Classes\Translator::withPreservedQueryString()</p>
  </blockquote>
  
  <p>And unable to proceed this request. I researched further and found <code>withPreservedQueryString</code> has protected method and I tried various ways to execute this method but unable to do so. </p>
  
  <p>So first I need to accomplish this and second I want to append that <code>hash</code> tag in my url. </p>
  
  <p>Can someone guide me from here on how can I achieve this ? </p>
  
  <p>Thanks </p>