Source for file mambolanguage.class.php
Documentation is available at mambolanguage.class.php
* Language Class for Mambo
* @copyright Refer to copyright.php
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author Mambo Foundation Inc see README.php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
var $days =
array('sun'=>
'','mon'=>
'','tue'=>
'','wed'=>
'','thu'=>
'','fri'=>
'','sat'=>
'');
var $months =
array('jan'=>
'','feb'=>
'','mar'=>
'','apr'=>
'','may'=>
'','jun'=>
'','jul'=>
'','aug'=>
'','sep'=>
'','oct'=>
'','nov'=>
'','dec'=>
'');
return isset
($this->$var) ?
$this->$var :
null;
function set($var, $value) {
if (isset
($this->$var)) $this->$var =
$value;
global $page_,$task,$mapcharset;
if( (($page_==
"addpage") &&
($task==
"save")) ||
($task==
"convert") ){
$langfiles =
glob($this->path .
"*.xml");
foreach($langfiles as $xml) {
if (substr($xml, 0, -
4) !=
'locales') {
$langs[$lobj->name] =
$lobj;
preg_match('/nplurals\s*=\s*(\d+)\s*;\s*plural\s*=\s*(.*)\s*;/', $exp, $plurals);
$this->plural_form =
array('nplurals' =>
$plurals[1], 'plural' =>
$plurals[2], 'expression' =>
$plurals[0]);
function getDate($format =
null, $timestamp =
null) {
function load($load_catalogs =
false) {
if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
if($encoding ==
"UTF-8" ||
$encoding ==
"US-ASCII" ||
$encoding ==
"ISO-8859-1") {
#if(function_exists('mb_convert_encoding')) {
$encoded_source =
$this->iconvert($mapcharset[$this->charset],"UTF-8",$source);
if($encoded_source !=
NULL) {
$source =
str_replace ( $m[0],'<?xml version="1.0" encoding="utf-8"?>', $encoded_source);
die(sprintf("XML error: %s at ".
$this->path .
$this->name.
".xml in line %d",
foreach($values as $key =>
$value) {
$this->title =
$value['value'];
$this->$tag =
$value['value'];
if ($value['type'] ==
'open') {
foreach ($value['attributes'] as $k =>
$v)
if (!empty($value['attributes']['expression'])) {
$this->days =
$value['attributes'];
$this->months =
$value['attributes'];
$file =
$value['attributes'];
$file['filename'] =
$value['value'];
function iconvert($fromcharset,$tocharset,$source,$useiconv=
FALSE)
return iconv($fromcharset,$tocharset,$source);
return $NewEncoding->Convert($source,$fromcharset,$tocharset,false);
foreach($attrs as $key=>
$v)
foreach($attrs as $key=>
$val)
$attrs[$key] =
$this->iconvert("utf-8",$encoding,$val,$useiconv);
foreach ($langfiles as $lf) {
$catalog->setproperty('lang', $this->name);
$file['filename'] =
"language/" .
$this->name .
'/' .
$lf;
$file['domain'] =
$domain;
$file['strings'] =
count($catalog->strings);
$file['filetype'] =
'po';
foreach ($catalog->strings as $msg) {
foreach ($msg->msgstr as $i) {
if (!is_array($msg->msgstr) &&
!empty($msg->msgstr) &&
!$msg->is_fuzzy) {
$nonfuzzy =
$file['strings'] -
$file['fuzzy'];
if (!$nonfuzzy) $nonfuzzy =
1;
$file['percent'] =
round($file['translated'] *
100 /
$nonfuzzy, 2);
$this->files[] =
array('filename'=>
"language/" .
$this->name .
'.xml','domain'=>
"",'strings'=>
"",'percent'=>
"",'translated'=>
0,'fuzzy'=>
0,'filetype'=>
'xml');
foreach ($langfiles as $lf) {
$this->files[] =
array('filename'=>
"language/" .
$this->name .
'/LC_MESSAGES/' .
$lf,'domain'=>
"",'strings'=>
"",'percent'=>
"",'translated'=>
0,'fuzzy'=>
0,'filetype'=>
'mo');
$this->files[] =
array('filename'=>
"language/glossary/" .
$this->name.
".".
$this->charset.
".po",'domain'=>
"",'strings'=>
"",'percent'=>
"",'translated'=>
0,'fuzzy'=>
0,'filetype'=>
'gl');
$array[] =
array('tag' =>
'mosinstall', 'type' =>
'open', 'level' =>
1, 'attributes' =>
array('version' =>
'4.6', 'type' =>
'language'));
$array[] =
array('tag' =>
'name', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->title);
$array[] =
array('tag' =>
'version', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->version);
$array[] =
array('tag' =>
'description', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->description);
$array[] =
array('tag' =>
'creationdate', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->creationdate);
$array[] =
array('tag' =>
'author', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->author);
$array[] =
array('tag' =>
'authorurl', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->authorurl);
$array[] =
array('tag' =>
'authoremail', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->authoremail);
$array[] =
array('tag' =>
'copyright', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->copyright);
$array[] =
array('tag' =>
'license', 'type' =>
'complete', 'level' =>
2, 'value' =>
$this->license);
$array[] =
array('tag' =>
'params', 'type' =>
'open', 'level' =>
2);
$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' =>
'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' =>
'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' =>
'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' =>
'plural_form', 'type' =>
'text', 'default' =>
htmlentities($this->plural_form['expression']), 'label' =>
'Plural Forms', 'description' =>
'Plural Forms expression'));
$array[] =
array('tag' =>
'params', 'type' =>
'close', 'level' =>
2);
$array[] =
array('tag' =>
'locale', 'type' =>
'open', 'level' =>
2, 'attributes' =>
array('name' =>
$this->name, 'title' =>
$this->title, 'territory' =>
$this->territory, 'locale' =>
$this->locale, 'text_direction' =>
$this->text_direction, 'iso639' =>
$this->iso639, 'iso3166_2' =>
$this->iso3166_2, 'iso3166_3' =>
$this->iso3166_3, 'charset' =>
$this->charset));
$array[] =
array('tag' =>
'date_format', 'type' =>
'complete', 'level' =>
3, 'value' =>
$this->date_format);
$array[] =
array('tag' =>
'codesets', 'type' =>
'open', 'level' =>
3);
foreach ($this->codesets as $charset) $array[] =
array('tag' =>
'charset', 'type' =>
'complete', 'level' =>
4, 'value' =>
$charset);
$array[] =
array('tag' =>
'codesets', 'type' =>
'close', 'level' =>
3);
foreach ($this->days as $name =>
$day) $days[$name] =
$day;
$array[] =
array('tag' =>
'days', 'type' =>
'complete', 'level' =>
3, 'attributes' =>
$days);
foreach ($this->months as $name =>
$month) $months[$name] =
$month;
$array[] =
array('tag' =>
'months', 'type' =>
'complete', 'level' =>
3, 'attributes' =>
$months);
$array[] =
array('tag' =>
'locale', 'type' =>
'close', 'level' =>
2);
$array[] =
array('tag' =>
'files', 'type' =>
'open', 'level' =>
2);
foreach ($this->files as $file) {
$array[] =
array('tag' =>
'filename', 'type' =>
'complete', 'level' =>
3, 'value' =>
$file['filename'], 'attributes' =>
array('domain' =>
$file['domain'] , 'strings' =>
$file['strings'] , 'translated' =>
$file['translated'] , 'fuzzy' =>
$file['fuzzy'] , 'percent' =>
$file['percent'], 'filetype' =>
$file['filetype']));
$array[] =
array('tag' =>
'files', 'type' =>
'close', 'level' =>
2);
$array[] =
array('tag' =>
'mosinstall', 'type' =>
'close', 'level' =>
1);
$xml =
"<?xml version=\"1.0\" encoding=\"$this->charset\"?>\n";
if ((!empty($array)) AND (is_array($array))) {
foreach ($array as $key =>
$value) {
switch ($value["type"]) {
if (isset
($value["attributes"])) {
foreach ($value["attributes"] as $k =>
$v) {
if (isset
($value["attributes"])) {
foreach ($value["attributes"] as $k =>
$v) {
$xml .= isset
($value['value']) ?
$value['value'] :
false;
$xmlfile =
"../language/locales.xml";
foreach($values as $key =>
$value) {
if ($value['type'] ==
'open') {
$iso639 =
$value['attributes']['iso639'];
$language[$iso639] =
$value['attributes']['title'];
$locale[$iso639] =
$value['attributes'];
$directions[$iso639] =
$value['attributes']['text_direction'];
$t['iso3166_2'] =
$value['attributes']['iso3166_2'];
$t['iso3166_3'] =
$value['attributes']['iso3166_3'];
$t['territory'] =
$value['value'];
$territories[$iso639][] =
$t;
$locale[$iso639]['codesets'][] =
$codesets[$iso639][] =
$value['value'];
$locale[$iso639]['dateformats'] =
$dateformats[$iso639] =
$value['value'];
$locale[$iso639]['days'] =
$value['attributes'];
$locale[$iso639]['months'] =
$value['attributes'];
if (!empty($value['attributes']['expression'])) {
$locale[$iso639]['plural_form'] =
$value['attributes'];
$plural_forms[$iso639] =
$value['attributes']['expression'];
$locales['locales'] =
$locale;
$locales['languages'] =
$language;
$locales['territories'] =
$territories;
$locales['codesets'] =
$codesets;
$locales['dateformats'] =
$dateformats;
$locales['directions'] =
$directions;
$locales['plural_forms'] =
$plural_forms;
Documentation generated on Mon, 05 May 2008 16:21:06 +0400 by phpDocumentor 1.4.0