Toggle button for language selection in header.

Toggle button for language selection in header.

by Fatema Siddiqua -
Number of replies: 1

Hi all,

I am using Moodle 2.6.4 and essential theme 2.6.10. I have to create a toggle button for two language packs installed in my moodle for english and hindi languages. 

I tried with this code in header.php:

<?php

$lang=$CFG->lang;

if ($lang=='en') {echo '<a id="hindi" class="hindi" href="mymoodle/?lang=hi" target="_parent"><img src="mypath/hindi.gif" /></a>';} else if ($lang =='hi'){

echo '<a id="english" class="english" href="mymoodle/?lang=en" target="_parent" ><img src="mypath/english.gif" /></a>';} 

How do i get the current language so that button changed accordingly?

Please help me to solve this issue...

Thanks & Regards...

Average of ratings: -
In reply to Fatema Siddiqua

Re: Toggle button for language selection in header.

by Torsten Händler -

Hey

 hope you still need a solution.


do not  

$lang=$CFG->lang;     

change it to

$lang=current_language();


there is a moodle function for it.

hope this will help