Jump to content

Fast language change


cikcak

Recommended Posts

Im trying to make a language bar in BackOffice header:

 

 <a class="change_lang" {if $lang_iso=="lt"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=4">LT</a>
                            <a class="change_lang" {if $lang_iso=="lv"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=5">LV</a>
                            <a class="change_lang" {if $lang_iso=="en"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=1">EN</a>
                            <a class="change_lang" {if $lang_iso=="ru"}style="text-decoration:underline;"{/if} href="{$thisIndex}&change_lang=6">RU</a>
                     




                        {literal}
                        <script>
                            $(document).ready(function() {
                                $(".change_lang").each(function() {
                                    link = $(this);
                                    langName = link.html();
                                    langId = link.attr("href")[link.attr("href").length-1];
                                    link.attr("href", "index.php{/literal}{foreach $smarty.get as $param=>$val}{if $param == "controller"}?{else}&{/if}{$param}={$val}{/foreach}{literal}&change_lang="+langId);
                                    //console.log(langName +" - "+ link.attr("href"));
                                });
                            });
                        </script>
                        {/literal}

So the result i got:

 

index.php?controller=AdminDashboard&token=da0f5260320099995def107b377622b4&controllerUri=AdminDashboard&change_lang=4&change_lang=5

 

And it doesnt work.. 

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...