Index: /extensions/FacebookPlug/Plugin/include/header.inc.php
===================================================================
--- /extensions/FacebookPlug/Plugin/include/header.inc.php	(revision 8434)
+++ /extensions/FacebookPlug/Plugin/include/header.inc.php	(revision 8435)
@@ -24,4 +24,36 @@
 }
 
+function fbp_get_fb_language()
+{
+  global $user;
+
+  // Array compute by plugins/FacebookPlug/tools/check_language.php script
+  $valid_fb_languages = array ( 0 => 'ca_ES', 1 => 'cs_CZ', 2 => 'da_DK', 3 => 'de_DE', 4 => 'es_ES', 5 => 'fa_IR', 6 => 'fr_CA', 7 => 'fr_FR', 8 => 'he_IL', 9 => 'hr_HR', 10 => 'hu_HU', 11 => 'it_IT', 12 => 'ja_JP', 13 => 'ka_GE', 14 => 'lv_LV', 15 => 'mk_MK', 16 => 'nl_NL', 17 => 'pl_PL', 18 => 'pt_BR', 19 => 'pt_PT', 20 => 'ro_RO', 21 => 'ru_RU', 22 => 'sk_SK', 23 => 'sr_RS', 24 => 'sv_SE', 25 => 'tr_TR', 26 => 'vi_VN', 27 => 'zh_CN', );
+
+  // User language
+  $language = $user['language'];
+  if (! in_array($language, $valid_fb_languages))
+  {
+    $code_lang = substr($language, 0, 2);
+    // Compose a language
+    $language = $code_lang.'_'.strtoupper($code_lang);
+    if (! in_array($language, $valid_fb_languages))
+    {
+      // Search a language
+      foreach ($valid_fb_languages as $valid_fb_language)
+      {
+        if ($code_lang == substr($valid_fb_language, 0, 2))
+        {
+          return $valid_fb_language;
+        }
+      }
+      // default language
+      $language = 'en_US';
+    }
+  }
+
+  return $language;
+}
+
 function fbp_header($content, &$smarty)
 {
@@ -49,5 +81,5 @@
     $template->assign('FACEBOOK_APP_ID', (is_numeric($conf['fbp']['facebook_app_id']) ? $conf['fbp']['facebook_app_id'] : FACEBOOK_APP_ID));
     // define language
-    $template->assign('LANGUAGE', $user['language']);
+    $template->assign('FACEBOOK_LANGUAGE', fbp_get_fb_language());
     $template->assign('fbp', $conf['fbp']);
     //~ $template->smarty->register_modifier('boolean_to_string', 'boolean_to_string');
Index: /extensions/FacebookPlug/Plugin/tools/check_language.php
===================================================================
--- /extensions/FacebookPlug/Plugin/tools/check_language.php	(revision 8435)
+++ /extensions/FacebookPlug/Plugin/tools/check_language.php	(revision 8435)
@@ -0,0 +1,60 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | FacebookPlug - a Piwigo Plugin                                        |
+// | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org                 |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+echo '$_SERVER["HTTP_ACCEPT_LANGUAGE"] = '.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'<br />';
+
+$language_path = dirname(dirname(dirname(dirname(__FILE__)))).'/language';
+$dir = opendir($language_path);
+
+echo 'Language path = '.$language_path.'<br />'.'<br />';
+
+while ($file = readdir($dir))
+{
+  $path = $language_path.'/'.$file;
+  if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt'))
+  {
+    echo '<br />'.$file.'<br />'.'-------'.'<br />';
+    $file_connect = 'http://connect.facebook.net/'.$file.'/all.js';
+    echo $file_connect.'<br />';
+
+    $content = @file_get_contents($file_connect);
+    if ($content !== false and ! preg_match('/is not a valid locale/', $content))
+    {
+      echo 'ok'.'<br />';
+      $languages['ok'][] = $file;
+    }
+    else
+    {
+      echo 'ko'.'<br />';
+      $languages['ko'][] = $file;
+    }
+  }
+}
+closedir($dir);
+@asort($languages['ok']);
+@asort($languages['ko']);
+
+echo '<br />'.'<br />'.'Languages defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
+var_export($languages['ok']);
+
+echo '<br />'.'<br />'.'Languages not defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
+var_export($languages['ko']);
+
+?>
Index: /extensions/FacebookPlug/Plugin/tools/index.php
===================================================================
--- /extensions/FacebookPlug/Plugin/tools/index.php	(revision 8435)
+++ /extensions/FacebookPlug/Plugin/tools/index.php	(revision 8435)
@@ -0,0 +1,27 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | FacebookPlug - a Piwigo Plugin                                        |
+// | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org                 |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify  |
+// | it under the terms of the GNU General Public License as published by  |
+// | the Free Software Foundation                                          |
+// |                                                                       |
+// | This program is distributed in the hope that it will be useful, but   |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
+// | General Public License for more details.                              |
+// |                                                                       |
+// | You should have received a copy of the GNU General Public License     |
+// | along with this program; if not, write to the Free Software           |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA.                                                                  |
+// +-----------------------------------------------------------------------+
+
+// Recursive call
+$url = '../';
+header( 'Request-URI: '.$url );
+header( 'Content-Location: '.$url );
+header( 'Location: '.$url );
+exit();
+?>
Index: /extensions/FacebookPlug/Plugin/tpl/init.fb.tpl
===================================================================
--- /extensions/FacebookPlug/Plugin/tpl/init.fb.tpl	(revision 8434)
+++ /extensions/FacebookPlug/Plugin/tpl/init.fb.tpl	(revision 8435)
@@ -38,5 +38,5 @@
   (function() {ldelim}
     var e = document.createElement(script);
-    e.src = document.location.protocol + //connect.facebook.net/{$LANGUAGE}/all.js#appId={$FACEBOOK_APP_ID}&amp;xfbml=1;
+    e.src = document.location.protocol + //connect.facebook.net/{$FACEBOOK_LANGUAGE}/all.js#appId={$FACEBOOK_APP_ID}&amp;xfbml=1;
     e.async = true;
     document.getElementById(fb-root).appendChild(e);
@@ -45,5 +45,5 @@
 {else}
 <div id="fb-root"></div>
-<script src="http://connect.facebook.net/{$LANGUAGE}/all.js#appId={$FACEBOOK_APP_ID}&amp;xfbml=1"></script>
+<script src="http://connect.facebook.net/{$FACEBOOK_LANGUAGE}/all.js#appId={$FACEBOOK_APP_ID}&amp;xfbml=1"></script>
 <script>
   FB.init({ldelim}
