| 2 |
/** |
/** |
| 3 |
* Language Class for Mambo |
* Language Class for Mambo |
| 4 |
* @package Mambo |
* @package Mambo |
|
* @copyright (C) 2006 - 2007 Mambo Foundation Inc. |
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
|
| 5 |
* @author Mambo Foundation Inc see README.php |
* @author Mambo Foundation Inc see README.php |
| 6 |
|
* @copyright Mambo Foundation Inc. |
| 7 |
|
* See COPYRIGHT.php for copyright notices and details. |
| 8 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 9 |
|
* Mambo is free software; you can redistribute it and/or |
| 10 |
|
* modify it under the terms of the GNU General Public License |
| 11 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 12 |
*/ |
*/ |
| 13 |
|
|
| 14 |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
| 32 |
var $iso3166_3 = ''; |
var $iso3166_3 = ''; |
| 33 |
var $locale = ''; |
var $locale = ''; |
| 34 |
var $charset = ''; |
var $charset = ''; |
|
var $wincodepage = ''; |
|
| 35 |
var $codesets = array(); |
var $codesets = array(); |
| 36 |
var $plural_form = array(); |
var $plural_form = array(); |
| 37 |
var $days = array('sun'=>'','mon'=>'','tue'=>'','wed'=>'','thu'=>'','fri'=>'','sat'=>''); |
var $days = array('sun'=>'','mon'=>'','tue'=>'','wed'=>'','thu'=>'','fri'=>'','sat'=>''); |
| 58 |
if (isset($this->$var)) $this->$var = $value; |
if (isset($this->$var)) $this->$var = $value; |
| 59 |
} |
} |
| 60 |
function save() { |
function save() { |
| 61 |
global $page_,$task; |
global $page_,$task,$mapcharset; |
| 62 |
$this->updateFiles(); |
$this->updateFiles(); |
| 63 |
$xml = $this->toXML(); |
$xml = $this->toXML(); |
| 64 |
if( (($page_=="addpage") && ($task=="save")) || ($task=="convert") ){ |
if( (($page_=="addpage") && ($task=="save")) || ($task=="convert") ){ |
| 65 |
if (strtolower($this->charset) != 'utf-8') { |
if (strtolower($this->charset) != 'utf-8') { |
| 66 |
if(trim($this->wincodepage)!="") |
$xml = $this->iconvert("utf-8",$mapcharset[$this->charset],$xml); |
|
$xml = $this->iconvert("utf-8",$this->wincodepage,$xml); |
|
|
else |
|
|
$xml = $this->iconvert("utf-8",$this->charset,$xml,TRUE); |
|
| 67 |
} |
} |
| 68 |
} |
} |
| 69 |
/**/ |
/**/ |
| 102 |
} |
} |
| 103 |
|
|
| 104 |
function load($load_catalogs = false) { |
function load($load_catalogs = false) { |
| 105 |
|
global $mapcharset; |
| 106 |
if (is_readable($this->path . $this->name . ".xml")) { |
if (is_readable($this->path . $this->name . ".xml")) { |
| 107 |
$source = file_get_contents($this->path . $this->name . ".xml"); |
$source = file_get_contents($this->path . $this->name . ".xml"); |
| 108 |
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) { |
| 112 |
} |
} |
| 113 |
|
|
| 114 |
if($encoding == "UTF-8" || $encoding == "US-ASCII" || $encoding == "ISO-8859-1") { |
if($encoding == "UTF-8" || $encoding == "US-ASCII" || $encoding == "ISO-8859-1") { |
| 115 |
$parser = xml_parser_create($encoding); |
$parser = xml_parser_create(); |
| 116 |
} else { |
} else { |
| 117 |
|
|
| 118 |
#if(function_exists('mb_convert_encoding')) { |
#if(function_exists('mb_convert_encoding')) { |
| 119 |
if(trim($this->wincodepage)!="") |
if(trim($this->charset)!="") |
| 120 |
$encoded_source = $this->iconvert($this->wincodepage,"UTF-8",$source); |
$encoded_source = $this->iconvert($mapcharset[$this->charset],"UTF-8",$source); |
| 121 |
else |
else |
| 122 |
$encoded_source = $this->iconvert($encoding,"UTF-8",$source,TRUE); |
$encoded_source = $this->iconvert($mapcharset[strtolower($encoding)],"UTF-8",$source); |
| 123 |
# } |
# } |
| 124 |
|
|
| 125 |
if($encoded_source != NULL) { |
if($encoded_source != NULL) { |
| 126 |
$source = str_replace ( $m[0],'<?xml version="1.0" encoding="utf-8"?>', $encoded_source); |
$source = str_replace ( $m[0],'<?xml version="1.0" encoding="utf-8"?>', $encoded_source); |
| 127 |
} |
} |
| 128 |
|
|
| 129 |
$parser = xml_parser_create("UTF-8"); |
$parser = xml_parser_create(); |
| 130 |
} |
} |
| 131 |
|
|
| 132 |
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); |
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); |
| 174 |
case 'charset': |
case 'charset': |
| 175 |
$this->codesets[] = $value['value']; |
$this->codesets[] = $value['value']; |
| 176 |
break; |
break; |
|
case 'wincodepage': |
|
|
$this->wincodepage = $value['value']; |
|
|
break; |
|
| 177 |
case 'days': |
case 'days': |
| 178 |
$this->days = $value['attributes']; |
$this->days = $value['attributes']; |
| 179 |
break; |
break; |
| 195 |
if(strtolower($encoding)!="utf-8") |
if(strtolower($encoding)!="utf-8") |
| 196 |
{ |
{ |
| 197 |
$attrs = get_object_vars($this); |
$attrs = get_object_vars($this); |
| 198 |
if(trim($this->wincodepage)!="") |
$this->arrayEncoding($attrs,$mapcharset[$this->charset]); |
|
{ |
|
|
$this->arrayEncoding($attrs,$this->wincodepage); |
|
|
$this->bindAttributes($attrs); |
|
|
|
|
|
}else{ |
|
|
$this->arrayEncoding($attrs,$encoding,TRUE); |
|
| 199 |
$this->bindAttributes($attrs); |
$this->bindAttributes($attrs); |
| 200 |
} |
} |
| 201 |
} |
} |
|
} |
|
| 202 |
return true; |
return true; |
| 203 |
} |
} |
| 204 |
return false; |
return false; |
| 289 |
$this->files[] = $file; |
$this->files[] = $file; |
| 290 |
} |
} |
| 291 |
$this->files[] = array('filename'=>"language/" . $this->name . '.xml','domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'xml'); |
$this->files[] = array('filename'=>"language/" . $this->name . '.xml','domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'xml'); |
| 292 |
$this->files[] = array('filename'=>"language/" . $this->name . '/LC_MESSAGES/' . $this->name.".mo",'domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'mo'); |
$langfiles = mosReadDirectory($dir.'LC_MESSAGES/', '.mo$'); |
| 293 |
|
set_time_limit(60); |
| 294 |
|
|
| 295 |
|
foreach ($langfiles as $lf) { |
| 296 |
|
$this->files[] = array('filename'=>"language/" . $this->name . '/LC_MESSAGES/' . $lf,'domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'mo'); |
| 297 |
|
} |
| 298 |
|
if(file_exists($this->path.'/glossary/'. $this->name.".".$this->charset.".po")) |
| 299 |
$this->files[] = array('filename'=>"language/glossary/" . $this->name.".".$this->charset.".po",'domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'gl'); |
$this->files[] = array('filename'=>"language/glossary/" . $this->name.".".$this->charset.".po",'domain'=>"",'strings'=>"",'percent'=>"",'translated'=>0,'fuzzy'=>0,'filetype'=>'gl'); |
| 300 |
} |
} |
| 301 |
|
|
| 313 |
$array[] = array('tag' => 'params', 'type' => 'open', 'level' => 2); |
$array[] = array('tag' => 'params', 'type' => 'open', 'level' => 2); |
| 314 |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'locale', 'type' => 'text', 'default' => $this->locale, 'label' => 'Locale String', 'description' => 'Locale string for setlocale() (eg. en, english)')); |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'locale', 'type' => 'text', 'default' => $this->locale, 'label' => 'Locale String', 'description' => 'Locale string for setlocale() (eg. en, english)')); |
| 315 |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'charset', 'type' => 'text', 'default' => $this->charset, 'label' => 'Character Set', 'description' => 'Character set for this language.')); |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'charset', 'type' => 'text', 'default' => $this->charset, 'label' => 'Character Set', 'description' => 'Character set for this language.')); |
| 316 |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'text_direction', 'type' => 'text', 'default' => $this->text_direction, 'label' => 'Text Direction', 'description' => 'left-to-right or light-to-left')); |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'text_direction', 'type' => 'text', 'default' => $this->text_direction, 'label' => 'Text Direction', 'description' => 'left-to-right or right-to-left')); |
| 317 |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'date_format', 'type' => 'text', 'default' => $this->date_format, 'label' => 'Date Format', 'description' => 'Date format for strftime() (eg. %A, %d %B %Y)')); |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'date_format', 'type' => 'text', 'default' => $this->date_format, 'label' => 'Date Format', 'description' => 'Date format for strftime() (eg. %A, %d %B %Y)')); |
| 318 |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'plural_form', 'type' => 'text', 'default' => htmlentities($this->plural_form['expression']), 'label' => 'Plural Forms', 'description' => 'Plural Forms expression')); |
$array[] = array('tag' => 'param', 'type' => 'complete', 'level' => 3, 'attributes' => array('name' => 'plural_form', 'type' => 'text', 'default' => htmlentities($this->plural_form['expression']), 'label' => 'Plural Forms', 'description' => 'Plural Forms expression')); |
| 319 |
$array[] = array('tag' => 'params', 'type' => 'close', 'level' => 2); |
$array[] = array('tag' => 'params', 'type' => 'close', 'level' => 2); |
| 323 |
$array[] = array('tag' => 'codesets', 'type' => 'open', 'level' => 3); |
$array[] = array('tag' => 'codesets', 'type' => 'open', 'level' => 3); |
| 324 |
foreach ($this->codesets as $charset) $array[] = array('tag' => 'charset', 'type' => 'complete', 'level' => 4, 'value' => $charset); |
foreach ($this->codesets as $charset) $array[] = array('tag' => 'charset', 'type' => 'complete', 'level' => 4, 'value' => $charset); |
| 325 |
$array[] = array('tag' => 'codesets', 'type' => 'close', 'level' => 3); |
$array[] = array('tag' => 'codesets', 'type' => 'close', 'level' => 3); |
|
$array[] = array('tag' => 'wincodepage', 'type' => 'complete', 'level' => 3,'value'=>$this->wincodepage); |
|
| 326 |
foreach ($this->days as $name => $day) $days[$name] = $day; |
foreach ($this->days as $name => $day) $days[$name] = $day; |
| 327 |
$array[] = array('tag' => 'days', 'type' => 'complete', 'level' => 3, 'attributes' => $days); |
$array[] = array('tag' => 'days', 'type' => 'complete', 'level' => 3, 'attributes' => $days); |
| 328 |
foreach ($this->months as $name => $month) $months[$name] = $month; |
foreach ($this->months as $name => $month) $months[$name] = $month; |
| 403 |
case 'date_format': |
case 'date_format': |
| 404 |
$locale[$iso639]['dateformats'] = $dateformats[$iso639] = $value['value']; |
$locale[$iso639]['dateformats'] = $dateformats[$iso639] = $value['value']; |
| 405 |
break; |
break; |
|
case 'wincodepage': |
|
|
$locale[$iso639]['wincodepage'] = $value['value']; |
|
|
break; |
|
| 406 |
case 'days': |
case 'days': |
| 407 |
$locale[$iso639]['days'] = $value['attributes']; |
$locale[$iso639]['days'] = $value['attributes']; |
| 408 |
break; |
break; |
| 430 |
|
|
| 431 |
function getSystemLocale(){ |
function getSystemLocale(){ |
| 432 |
if (substr(strtoupper(PHP_OS), 0, 3) == 'WIN'){ |
if (substr(strtoupper(PHP_OS), 0, 3) == 'WIN'){ |
| 433 |
return strtolower($this->title).'_'.strtolower($this->iso3166_3); |
return strtolower($this->title).($this->iso3166_3?'_'.strtolower($this->iso3166_3):''); |
| 434 |
} else { |
} else { |
| 435 |
return $this->locale; |
return $this->locale; |
| 436 |
} |
} |