source: extensions/FacebookPlug/Plugin/tools/check_language.php @ 8435

Last change on this file since 8435 was 8435, checked in by rub, 13 years ago

Fix language set/detect on Facebook connect

  • Property svn:eol-style set to LF
File size: 2.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | FacebookPlug - a Piwigo Plugin                                        |
4// | Copyright (C) 2010-2011 Ruben ARNAUD - rub@piwigo.org                 |
5// +-----------------------------------------------------------------------+
6// | This program is free software; you can redistribute it and/or modify  |
7// | it under the terms of the GNU General Public License as published by  |
8// | the Free Software Foundation                                          |
9// |                                                                       |
10// | This program is distributed in the hope that it will be useful, but   |
11// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
12// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
13// | General Public License for more details.                              |
14// |                                                                       |
15// | You should have received a copy of the GNU General Public License     |
16// | along with this program; if not, write to the Free Software           |
17// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
18// | USA.                                                                  |
19// +-----------------------------------------------------------------------+
20
21echo '$_SERVER["HTTP_ACCEPT_LANGUAGE"] = '.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'<br />';
22
23$language_path = dirname(dirname(dirname(dirname(__FILE__)))).'/language';
24$dir = opendir($language_path);
25
26echo 'Language path = '.$language_path.'<br />'.'<br />';
27
28while ($file = readdir($dir))
29{
30  $path = $language_path.'/'.$file;
31  if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt'))
32  {
33    echo '<br />'.$file.'<br />'.'-------'.'<br />';
34    $file_connect = 'http://connect.facebook.net/'.$file.'/all.js';
35    echo $file_connect.'<br />';
36
37    $content = @file_get_contents($file_connect);
38    if ($content !== false and ! preg_match('/is not a valid locale/', $content))
39    {
40      echo 'ok'.'<br />';
41      $languages['ok'][] = $file;
42    }
43    else
44    {
45      echo 'ko'.'<br />';
46      $languages['ko'][] = $file;
47    }
48  }
49}
50closedir($dir);
51@asort($languages['ok']);
52@asort($languages['ko']);
53
54echo '<br />'.'<br />'.'Languages defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
55var_export($languages['ok']);
56
57echo '<br />'.'<br />'.'Languages not defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
58var_export($languages['ko']);
59
60?>
Note: See TracBrowser for help on using the repository browser.