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

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

List all facebook locale

  • Property svn:eol-style set to LF
File size: 3.9 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    $locale = $file;
34    $languages['strict_list'][] = $locale;
35
36    $code_lang = substr($locale, 0, 2);
37    // Compose a locale
38    $locale = $code_lang.'_'.strtoupper($code_lang);
39    $languages['extented_list'][] = $locale;
40  }
41}
42closedir($dir);
43
44$languages['extented_list'] = array_merge($languages['strict_list'], $languages['extented_list']);
45
46/*foreach (array_unique($languages['extented_list']) as $locale)
47{
48  echo '<br />'.$locale.'<br />'.'-------'.'<br />';
49  $locale_connect = 'http://connect.facebook.net/'.$locale.'/all.js';
50  echo $locale_connect.'<br />';
51
52  $content = @file_get_contents($locale_connect);
53  if ($content !== false and ! preg_match('/is not a valid locale/', $content))
54  {
55    echo 'ok'.'<br />';
56    $languages['ok'][] = $locale;
57  }
58  else
59  {
60    echo 'ko'.'<br />';
61    $languages['ko'][] = $locale;
62  }
63}
64
65@asort($languages['ok']);
66@asort($languages['ko']);
67
68echo '<br />'.'<br />'.'Languages defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
69var_export($languages['ok']);
70
71echo '<br />'.'<br />'.'Languages not defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
72var_export($languages['ko']);
73
74echo '<br />'.'<br />'.'Facebook Locales'.'<br />'.'-----------------------------'.'<br />';
75echo @file_get_contents('http://www.facebook.com/translations/FacebookLocales.xml');
76*/
77$dom = DomDocument::load('http://www.facebook.com/translations/FacebookLocales.xml');
78
79$domrepresentation = $dom->getElementsByTagName("representation");
80
81foreach ($domrepresentation as $representations)
82{
83  $languages['fb'][] = $representations->nodeValue;
84} 
85@sort($languages['fb']);
86
87echo '<br />'.'<br />'.'Languages defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
88var_export($languages['fb']);
89
90echo '<br />'.'<br />'.'Languages not defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
91var_export(array_values(array_diff($languages['strict_list'],$languages['fb'])));
92
93echo '<br />'.'<br />'.'Extented languages not defined on Facebook'.'<br />'.'-----------------------------'.'<br />';
94var_export(array_values(array_diff($languages['extented_list'],$languages['fb'])));
95
96?>
Note: See TracBrowser for help on using the repository browser.