summaryrefslogtreecommitdiff
path: root/maintenance/languages.inc
blob: e318259deabf93bbc5ce91142de9476a999fe151 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
 * Library to grab data from languages files
 *
 * WORK IN PROGRESS. There is some bugs when including the same
 * file multiple time :(((
 */
require_once('commandLine.inc');

class languages {
	/** Contain the list of languages available */
	var $list = array();
	/** some messages for the current lang */
	var $messages = array();

	function languages() {
		$this->clear();
		$this->loadList();
	}

	function clear() {
		$this->list = array();
		$this->messages = array();
	}

	function loadList() {
		global $IP;
		$this->list = array();

		// available language files
		$dir = opendir("$IP/languages");
		while ($file = readdir($dir)) {
			if (preg_match("/Language([^.]*?)\.php$/", $file, $m)) {
				$this->list[] = $m[1];
			}
		}
		sort($this->list);

		// Cleanup file list
		foreach($this->list as $key => $lang) {
			if ($lang == 'Utf8' || $lang == '' || $lang == 'Converter')
				unset($this->list[$key]);
		}
	}

	function getList() { return $this->list; }
}
?>