| 1 |
<?php |
<?php |
| 2 |
|
/** |
| 3 |
|
* @package Mambo |
| 4 |
|
* @subpackage Languages |
| 5 |
|
* @author Mambo Foundation Inc see README.php |
| 6 |
|
* @copyright (C) 2000 - 2009 Mambo Foundation Inc. |
| 7 |
|
* See COPYRIGHT.php for copyright notices and details. |
| 8 |
|
* @license GNU/GPL Version 2, see LICENSE.php |
| 9 |
|
* |
| 10 |
|
* Redistributions of files must retain the above copyright notice. |
| 11 |
|
* |
| 12 |
|
* Mambo is free software; you can redistribute it and/or |
| 13 |
|
* modify it under the terms of the GNU General Public License |
| 14 |
|
* as published by the Free Software Foundation; version 2 of the License. |
| 15 |
|
*/ |
| 16 |
|
|
| 17 |
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.' ); |
| 18 |
class saveAction extends Action |
class saveAction extends Action |
| 19 |
{ |
{ |
| 26 |
$lang .= strlen($iso3166) == 2 ? '_'.$iso3166 : ''; |
$lang .= strlen($iso3166) == 2 ? '_'.$iso3166 : ''; |
| 27 |
$root = mamboCore::get('rootPath'); |
$root = mamboCore::get('rootPath'); |
| 28 |
$langfile = $root.'/language/'.$lang.'.xml'; |
$langfile = $root.'/language/'.$lang.'.xml'; |
| 29 |
|
$act = mosGetParam($_POST,'act'); |
| 30 |
|
|
| 31 |
switch ($_POST['act']) |
switch ($act) |
| 32 |
{ |
{ |
| 33 |
case 'language': |
case 'language': |
| 34 |
if (file_exists($langfile)) { |
if (file_exists($langfile)) { |
| 54 |
$default = $locales['locales'][$iso639]; |
$default = $locales['locales'][$iso639]; |
| 55 |
$lang = $iso639; |
$lang = $iso639; |
| 56 |
$lang .= strlen($iso3166) == 2 ? '_'.$iso3166 : ''; |
$lang .= strlen($iso3166) == 2 ? '_'.$iso3166 : ''; |
| 57 |
|
$pluralform = mosGetParam($_POST,'plural_form'); |
| 58 |
|
|
| 59 |
$language =& new mamboLanguage($lang); |
$language =& new mamboLanguage($lang); |
| 60 |
foreach ($default as $k => $v) { |
foreach ($default as $k => $v) { |
| 61 |
if (in_array($k, array_keys(get_class_vars(get_class($language))))) { |
if (in_array($k, array_keys(get_class_vars(get_class($language))))) { |
| 76 |
$language->author = 'Mambo Foundation Inc.'; |
$language->author = 'Mambo Foundation Inc.'; |
| 77 |
$language->authorurl = 'http://www.mambo-foundation.org'; |
$language->authorurl = 'http://www.mambo-foundation.org'; |
| 78 |
$language->authoremail = 'translation@mambo-foundation.org'; |
$language->authoremail = 'translation@mambo-foundation.org'; |
| 79 |
$language->copyright = '(C) 2005 - 2006 Mambo Foundation Inc.'; |
$language->copyright = 'Refer to copyright.php'; |
| 80 |
$language->license = 'http://www.gnu.org/copyleft/gpl.html GNU/GPL'; |
$language->license = 'http://www.opensource.org/licenses/gpl-2.0.php GNU/GPL'; |
| 81 |
$language->setPlurals($_POST['plural_form']); |
$language->setPlurals($pluralform ); |
| 82 |
|
|
| 83 |
$textdomain = rtrim($language->path, '\/'); |
$textdomain = rtrim($language->path, '\/'); |
| 84 |
$dir = $textdomain.'/'.$language->name; |
$dir = $textdomain.'/'.$language->name; |
| 107 |
|
|
| 108 |
function updatelanguage($lang) |
function updatelanguage($lang) |
| 109 |
{ |
{ |
| 110 |
|
$pluralform = mosGetParam($_POST,'plural_form'); |
| 111 |
|
|
| 112 |
$language =& new mamboLanguage($lang); |
$language =& new mamboLanguage($lang); |
| 113 |
$language->load(); |
$language->load(); |
| 116 |
$language->$k = $v; |
$language->$k = $v; |
| 117 |
} |
} |
| 118 |
} |
} |
| 119 |
$language->setPlurals($_POST['plural_form']); |
$language->setPlurals($pluralform); |
| 120 |
$language->save(); |
$language->save(); |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
function updatecatalog($compile = true, $add_to_dict = true) |
function updatecatalog($compile = true, $add_to_dict = true) |
| 124 |
{ |
{ |
| 125 |
|
|
| 126 |
$domain = $_POST['domain']; |
$domain = mosGetParam($_POST,'domain'); |
| 127 |
$textdomain = $_POST['textdomain']; |
$textdomain = mosGetParam($_POST,'textdomain'); |
| 128 |
$lang = $_POST['lang']; |
$lang = mosGetParam($_POST,'lang'); |
| 129 |
|
$comments = mosGetParam($_POST,'comments'); |
| 130 |
|
$headers = mosGetParam($_POST,'headers'); |
| 131 |
|
|
| 132 |
$catalog = new PHPGettext_catalog($domain, $textdomain); |
$catalog = new PHPGettext_catalog($domain, $textdomain); |
| 133 |
$catalog->setproperty('mode', 'po'); |
$catalog->setproperty('mode', 'po'); |
| 134 |
$catalog->setproperty('lang', $lang); |
$catalog->setproperty('lang', $lang); |
| 135 |
$catalog->load(); |
$catalog->load(); |
| 136 |
|
|
| 137 |
$catalog->setComments($_POST['comments']); |
$catalog->setComments($comments); |
| 138 |
$catalog->setHeaders($_POST['headers']); |
$catalog->setHeaders($headers); |
| 139 |
|
$plural_forms = $catalog->headers['Plural-Forms']; |
| 140 |
|
preg_match('/nplurals[\s]*[=]{1}[\s]*([\d]+);[\s]*plural[\s]*[=]{1}[\s]*(.*);/', $plural_forms, $matches); |
| 141 |
|
$is_plural = $matches[1] > 1; |
| 142 |
foreach ($_POST as $key => $value) { |
foreach ($_POST as $key => $value) { |
| 143 |
if (preg_match('/^([a-z]+[_]?[a-z]+?)[_]?([0-9]+)?_([0-9]+)$/', $key, $matches)) { |
if (preg_match('/^([a-z]+[_]?[a-z]+?)[_]?([0-9]+)?_([0-9]+)$/', $key, $matches)) { |
| 144 |
switch ($matches[1]) |
switch ($matches[1]) |
| 146 |
case 'msgid': |
case 'msgid': |
| 147 |
if (get_magic_quotes_gpc() == 1){ |
if (get_magic_quotes_gpc() == 1){ |
| 148 |
$value = stripslashes($value); |
$value = stripslashes($value); |
| 149 |
$value = htmlentities($value); |
//$value = htmlentities($value); |
| 150 |
} |
} |
| 151 |
$messages[$matches[3]]['msgid'] = $value; |
$messages[$matches[3]]['msgid'] = $value; |
| 152 |
break; |
break; |
| 153 |
case 'msgid_plural': |
case 'msgid_plural': |
| 154 |
|
if ($is_plural){ |
| 155 |
$messages[$matches[3]]['msgid_plural'] = $value; |
$messages[$matches[3]]['msgid_plural'] = $value; |
| 156 |
|
} |
| 157 |
break; |
break; |
| 158 |
case 'msgstr': |
case 'msgstr': |
| 159 |
if (!empty($messages[$matches[3]]['msgid_plural'])) { |
if (!empty($messages[$matches[3]]['msgid_plural'])) { |
| 177 |
foreach ($messages as $index => $arr) { |
foreach ($messages as $index => $arr) { |
| 178 |
if (strcmp($catalog->strings[$index]->msgid, $arr['msgid']) == 0) { |
if (strcmp($catalog->strings[$index]->msgid, $arr['msgid']) == 0) { |
| 179 |
$catalog->strings[$index]->setmsgstr($arr['msgstr']); |
$catalog->strings[$index]->setmsgstr($arr['msgstr']); |
| 180 |
if ($arr['fuzzy']) { |
$catalog->strings[$index]->msgid_plural = isset($arr['msgid_plural'])?$arr['msgid_plural']:null;; |
| 181 |
$catalog->strings[$index]->setfuzzy($arr['fuzzy']); |
$catalog->strings[$index]->setfuzzy($arr['fuzzy']); |
| 182 |
} |
} |
| 183 |
} |
} |
|
} |
|
| 184 |
$catalog->save(); |
$catalog->save(); |
| 185 |
|
|
| 186 |
$language = new mamboLanguage($lang); |
$language = new mamboLanguage($lang); |
| 187 |
$language->save(); |
$language->save(); |
| 188 |
|
|
| 189 |
$gettext_admin = new PHPGettextAdmin(); |
$configuration =& mamboCore::getMamboCore(); |
| 190 |
$gettext_admin->add_to_dict($domain, $textdomain, $lang, $language->charset); |
$gettext_admin = new PHPGettextAdmin($configuration->get('mosConfig_locale_use_gettext')); |
| 191 |
|
$gettext_admin->add_to_dict($domain, $textdomain, $lang, $language->charset, $language->plural_form['expression']); |
| 192 |
$catalog->load(); |
$catalog->load(); |
| 193 |
|
|
| 194 |
if ($compile) { |
if ($compile) { |