Skip to content

Commit

Permalink
Removed LANG_DIR configuration item
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroenrnl committed Oct 20, 2012
1 parent fcd07dd commit f687afc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion php/config.inc.php
Expand Up @@ -45,7 +45,8 @@
// Deprecated: Modify through admin -> config in web interface.
//define('ZOPH_TITLE', "Zoph");

define('LANG_DIR', "lang"); // where language files are stored
// deprecated
//define('LANG_DIR', "lang"); // where language files are stored

# Use this language when neither user or browser specify a language
define('DEFAULT_LANG', 'en');
Expand Down
16 changes: 9 additions & 7 deletions php/translation.inc.php
Expand Up @@ -22,7 +22,7 @@
*/

/**
* This class contains a set of translations read from a file in the LANG_DIR
* This class contains a set of translations read from a file in the self::LANG_DIR
* directory.
* These files have the following format
* # Zoph Language File - <language name>
Expand All @@ -44,14 +44,16 @@ class language {
public static $base="en";
public static $base_name="English";

const LANG_DIR="lang";

/**
* @param string iso ISO definition of the language, usually 2 letters or
* two letters dash two letters, for example nl en-ca.
* This is also the name of the file it will try to read.
*/
function __construct($iso) {
$this->name=$iso;
$this->filename=LANG_DIR. "/" . $iso;
$this->filename=self::LANG_DIR. "/" . $iso;
$this->iso=strtolower($iso);
}

Expand Down Expand Up @@ -141,11 +143,11 @@ function translate($string, $error = true) {
*/
public static function get_all() {
$langs=array();
if(is_dir(LANG_DIR) && is_readable(LANG_DIR)) {
$handle=opendir(LANG_DIR);
if(is_dir(self::LANG_DIR) && is_readable(self::LANG_DIR)) {
$handle=opendir(self::LANG_DIR);
while ($filename = trim(readdir($handle))) {
if(!is_dir(LANG_DIR . "/" . $filename)) {
if(is_readable(strtolower(LANG_DIR . "/" . $filename))) {
if(!is_dir(self::LANG_DIR . "/" . $filename)) {
if(is_readable(strtolower(self::LANG_DIR . "/" . $filename))) {
# making filename lowercase, so we won't include
# any capitalized filenames... Zoph will not able
# to find them back later...
Expand Down Expand Up @@ -180,7 +182,7 @@ public static function get_all() {
* @return string null|iso
*/
public static function exists($iso) {
$file=LANG_DIR . '/' . $iso;
$file=self::LANG_DIR . '/' . $iso;
if (file_exists($file) && is_file($file)) {
return $iso;
} else {
Expand Down

0 comments on commit f687afc

Please sign in to comment.