Get Joomla language locale for use with Facebook js/fbml etc. on multilingual sites


/ Published in: PHP
Save to your folder(s)

You can use this in Joomla extensions where you need to get the current language locale for example to use with Facebook Connect/Like plugins etc. in the "en_US" format. With facebooj JS, all you have to do is replace the default locale with the resulting variable something like this:

e.src = document.location.protocol +'//connect.facebook.net//all.js';


Copy this code and paste it in your HTML
  1. $lang =& JFactory::getLanguage();
  2. $locales = $lang->getLocale();
  3. $locale = str_replace('-','_',substr($locales[0],0,5)); //This will get you "en_US" etc.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.