[Solved] Can't always get the language with $_GET['glang']
Nov 28, 2012 6:39 am by makane
Nov 28, 2012 6:39 am by makane
Hi,
At the bottom of every page on my site (http://taulia.com) I'm calling a JavaScript function with the current language, but quite often, even when the site is displaying German, the language is blank. It is almost always blank if you are on any page on the site and click the logo to return to the home page.
The code at the bottom of each page looks like this:
<script type="text/javascript">fPageLoaded('<?php echo $_GET['glang']; ?>');</script>
And I have these lines in my .htaccess file:
# gtranslate config
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 [R=301,L]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ [R=301,L]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2&glang=$1 [L,QSA]
RewriteRule ^([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1&glang=$1 [L,QSA]
Any idea how I can always know what language is displaying?
Thanks.
Re: Can't always get the language with $_GET['glang']
Nov 28, 2012 5:23 pm by Yana
Nov 28, 2012 5:23 pm by Yana
Hi,
joomla holds the language in the session of variable glang. You will be able to get the current language with $_GET['glang']
Re: Can't always get the language with $_GET['glang']
Nov 28, 2012 5:47 pm by makane
Nov 28, 2012 5:47 pm by makane
Hi Yana,
Sometimes that variable is blank even when the page is in German. Do you know why that might be?
If you go to http://www.taulia.com/de/about and look at the bottom of the page source you will see this: <script type="text/javascript">fPageLoaded('de');</script>
If you then click on the Taulia logo in the upper left to return to the homepage, the page is still in German but at the bottom of the source you see this: <script type="text/javascript">fPageLoaded('');</script>
The variable <?php echo $_GET['glang']; ?> is not being filled in.
Do you know why that might be?
Thanks
Re: Can't always get the language with $_GET['glang']
Nov 29, 2012 3:34 pm by Edvard
Nov 29, 2012 3:34 pm by Edvard
Hi,
You are using the plugin which holds the variable in session. You need to use JSession::get('glang');
Re: Can't always get the language with $_GET['glang']
Nov 29, 2012 6:00 pm by makane
Nov 29, 2012 6:00 pm by makane
Thank you Yana! That did the trick!
SIMILAR TOPICS
Large numbers of crawl errors with double language code | Jan 24, 2019 1:43 am | Replies: 1 | Post by: natastna2 |
Translate website to any specific language, on page load | Jan 19, 2019 6:49 am | Replies: 1 | Post by: Leaon7756 |
Graphic translation for every language is missing | Dec 19, 2018 7:54 am | Replies: 1 | Post by: Daryl Dixon |
How to remove mobile Language Select Button transparency | Dec 5, 2018 10:06 pm | Replies: 10 | Post by: JeffTR |
Change language automatically | Nov 26, 2018 9:29 pm | Replies: 3 | Post by: Antilb |