Translations Supports was fixed and solve multiples bugs: 6137, 6474, 6476, 6513, 6560, 6597, 6599
This commit is contained in:
@@ -541,8 +541,11 @@ class dynaFormHandler
|
||||
{
|
||||
$array = false;
|
||||
$array['__nodeName__'] = $node->nodeName;
|
||||
if ($node->hasAttributes()){
|
||||
if( isset($attributes) ){
|
||||
$text = simplexml_import_dom($node);
|
||||
$array['__nodeText__'] = trim((string) $text);
|
||||
|
||||
if ($node->hasAttributes()) {
|
||||
if( isset($attributes) ) {
|
||||
foreach ($attributes as $attr) {
|
||||
if( $node->hasAttribute($attr) )
|
||||
$array[$attr] = $node->getAttribute($attr);
|
||||
@@ -559,10 +562,15 @@ class dynaFormHandler
|
||||
$return;
|
||||
else {
|
||||
foreach ($node->childNodes as $childNode) {
|
||||
if ($childNode->nodeType != XML_TEXT_NODE && $childNode->nodeType != XML_CDATA_SECTION_NODE)
|
||||
$childNode->normalize();
|
||||
//if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
||||
if ($childNode->nodeType == XML_ELEMENT_NODE) {
|
||||
$array[$childNode->nodeName][] = $this->getArray($childNode);
|
||||
else
|
||||
$array[$childNode->nodeName] = $childNode->nodeValue;
|
||||
} else if ($childNode->nodeType == XML_TEXT_NODE || $childNode->nodeType == XML_CDATA_SECTION_NODE) {
|
||||
//$array[$childNode->nodeName] = $childNode->textContent;
|
||||
$text = simplexml_import_dom($childNode->parentNode);
|
||||
$array['__nodeText__'] = trim((string) $text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,12 +101,14 @@ class languages {
|
||||
$oTranslation = new Translation();
|
||||
$countItems = 0;
|
||||
$countItemsSuccess = 0;
|
||||
$errorMsg = '';
|
||||
|
||||
while( $rowTranslation = $POFile->getTranslation() ) {
|
||||
|
||||
$countItems++;
|
||||
|
||||
if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
|
||||
throw new Exception('The .po file has not valid directives for Processmaker!');
|
||||
throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
|
||||
}
|
||||
|
||||
foreach($POFile->translatorComments as $a=>$aux){
|
||||
@@ -120,16 +122,17 @@ class languages {
|
||||
if ($var[0]=='JAVASCRIPT')
|
||||
$context = $aux;
|
||||
}
|
||||
if (preg_match('/^([a-zA-Z_-]+)\/([a-zA-Z_-]+\.xml\?)/', $aux, $match))
|
||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
|
||||
$identifier = $aux;
|
||||
else{
|
||||
if (preg_match('/^([a-zA-Z_-]+)\/([a-zA-Z_-]+\.xml$)/', $aux, $match))
|
||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
|
||||
$context = $aux;
|
||||
}
|
||||
}
|
||||
|
||||
$reference = $POFile->references[0];
|
||||
|
||||
// it is a Sql insert on TRANSLATIONS TAble
|
||||
if( $identifier == 'TRANSLATION') {
|
||||
if ($updateDB) {
|
||||
list($category, $id) = explode('/', $context);
|
||||
@@ -139,18 +142,29 @@ class languages {
|
||||
$LOCALE,
|
||||
trim(str_replace(chr(10), '', stripslashes($rowTranslation['msgstr'])))
|
||||
);
|
||||
if( $result['codError'] == 0 )
|
||||
if( $result['codError'] == 0 ) {
|
||||
$countItemsSuccess++;
|
||||
} else {
|
||||
$errorMsg .= $id .': ' . $result['message'] . "\n";
|
||||
}
|
||||
}
|
||||
} else if( $updateXml ){
|
||||
}
|
||||
// is a Xml update
|
||||
else if( $updateXml ) {
|
||||
|
||||
$xmlForm = $context;
|
||||
//erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
|
||||
preg_match('/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match);
|
||||
|
||||
|
||||
|
||||
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
||||
echo 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G::LoadSystem('dynaformhandler');
|
||||
$dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
|
||||
$fieldName = $match[2];
|
||||
@@ -158,7 +172,7 @@ class languages {
|
||||
$codes = explode('-', $reference);
|
||||
|
||||
if( sizeof($codes) == 2 ) { //is a normal node
|
||||
$dynaform->addChilds($fieldName, Array($LOCALE=>$rowTranslation['msgstr']));
|
||||
$dynaform->addChilds($fieldName, Array($LOCALE=>stripslashes($rowTranslation['msgstr'])));
|
||||
} else if( sizeof($codes) > 2 ) { //is a node child for a language node
|
||||
$name = $match[3] == "''" ? '' : $match[3];
|
||||
$childNode = Array(
|
||||
@@ -189,6 +203,7 @@ class languages {
|
||||
$results->recordsCountSuccess = $countItemsSuccess;
|
||||
$results->lang = $languageID;
|
||||
$results->headers = $POHeaders;
|
||||
$results->errMsg = $errorMsg;
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ class Translation extends BaseTranslation {
|
||||
$msg = '';
|
||||
$validationFailuresArray = $tr->getValidationFailures();
|
||||
foreach($validationFailuresArray as $objValidationFailure) {
|
||||
$msg .= $objValidationFailure->getMessage() . "<br/>";
|
||||
$msg .= $objValidationFailure->getMessage() . "\n";
|
||||
}
|
||||
return array ( 'codError' => -100, 'rowsAffected' => 0, 'message' => $msg );
|
||||
}
|
||||
|
||||
@@ -35,8 +35,15 @@ G::LoadSystem('i18n_po');
|
||||
//$timer = new Benchmark_Timer();
|
||||
//$timer->start();
|
||||
|
||||
//creating the .po file
|
||||
if (!defined('PM_VERSION')) {
|
||||
if (file_exists ( PATH_METHODS . 'login/version-pmos.php')) {
|
||||
include (PATH_METHODS . 'login/version-pmos.php');
|
||||
} else {
|
||||
define('PM_VERSION', 'Development Version');
|
||||
}
|
||||
}
|
||||
|
||||
//creating the .po file
|
||||
if( ! isset($_GET['LOCALE']) )
|
||||
throw new Exception('Language Target ID was not set!');
|
||||
|
||||
@@ -72,7 +79,7 @@ if( ! isset($langRecord['LAN_NAME']) )
|
||||
$sLanguage = $langRecord['LAN_NAME'];
|
||||
|
||||
//setting headers
|
||||
$poFile->addHeader('Project-Id-Version' , '1.8');
|
||||
$poFile->addHeader('Project-Id-Version' , 'ProcessMaker ' . PM_VERSION);
|
||||
$poFile->addHeader('POT-Creation-Date' , '');
|
||||
$poFile->addHeader('PO-Revision-Date' , date('Y-m-d H:i:s'));
|
||||
$poFile->addHeader('Last-Translator' , '');
|
||||
@@ -154,8 +161,8 @@ $aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
|
||||
$aXMLForms2 = glob(PATH_XMLFORM . '*/*/*.xml');
|
||||
$aXMLForms = array_merge($aXMLForms, $aXMLForms2);
|
||||
|
||||
$aEnglishLabel = array();
|
||||
$aOptions = array();
|
||||
$aEnglishLabel = array();
|
||||
$aOptions = array();
|
||||
$nodesNames = Array();
|
||||
|
||||
G::loadSystem('dynaformhandler');
|
||||
@@ -163,10 +170,7 @@ G::loadSystem('dynaformhandler');
|
||||
foreach ($aXMLForms as $xmlFormPath) {
|
||||
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
||||
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
||||
//$oForm = new Form( $sXmlForm, '', 'en');
|
||||
//echo $xmlFormPath;
|
||||
//echo '<br>';
|
||||
//echo '<br>';
|
||||
|
||||
$dynaForm = new dynaFormHandler($xmlFormPath);
|
||||
|
||||
$dynaNodes = $dynaForm->getFields();
|
||||
@@ -182,19 +186,13 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
continue; //just continue with the next node
|
||||
}
|
||||
|
||||
|
||||
// Getting the Base Origin Text
|
||||
if( ! is_array($arrayNode[$_BASE_LANG]) )
|
||||
$originNodeText = trim($arrayNode[$_BASE_LANG]);
|
||||
else {
|
||||
$langNode = $arrayNode[$_BASE_LANG][0];
|
||||
$originNodeText = getTextValue($langNode);
|
||||
$originNodeText = $langNode['__nodeText__'];
|
||||
}
|
||||
|
||||
/*if( strpos($xmlFormPath, 'patterns/patterns_GridParallelByEvaluationType.xml') !== false){
|
||||
g::pr($arrayNode);
|
||||
g::dump(getTextValue($langNode));
|
||||
}*/
|
||||
|
||||
// Getting the Base Target Text
|
||||
if( isset($arrayNode[$_TARGET_LANG]) ) {
|
||||
@@ -202,7 +200,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
$targetNodeText = trim($arrayNode[$_TARGET_LANG]);
|
||||
else {
|
||||
$langNode = $arrayNode[$_TARGET_LANG][0];
|
||||
$targetNodeText = getTextValue($langNode);
|
||||
$targetNodeText = $langNode['__nodeText__'];
|
||||
}
|
||||
} else {
|
||||
$targetNodeText = $originNodeText;
|
||||
@@ -210,11 +208,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
|
||||
$nodeName = $arrayNode['__nodeName__'];
|
||||
$nodeType = $arrayNode['type'];
|
||||
/*echo 'NODENAME:'. $nodeName . '<br>';
|
||||
echo 'ORIGIN text:'. $originNodeText.'<br>';
|
||||
echo 'TARGET text:'. $targetNodeText.'<br>';
|
||||
echo 'NODE TYPE'. $arrayNode['type'].'<br>';
|
||||
*/
|
||||
|
||||
$msgid = $originNodeText;
|
||||
|
||||
// if the nodeName already exists in the po file, we need to create other msgid
|
||||
@@ -224,13 +218,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
|
||||
$poFile->addTranslatorComment($xmlFormFile);
|
||||
$poFile->addReference($nodeType . ' - ' . $nodeName);
|
||||
$poFile->addTranslation($msgid, stripslashes($targetNodeText));
|
||||
|
||||
/*if( strpos($xmlFormPath, 'patterns/patterns_GridParallelByEvaluationType.xml') !== false){
|
||||
echo 'msgstr: ' .$msgid, stripslashes($targetNodeText);
|
||||
echo '<br>';
|
||||
}*/
|
||||
|
||||
$poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
|
||||
|
||||
$aMsgids[$msgid] = true;
|
||||
|
||||
@@ -250,12 +238,12 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
|
||||
$poFile->addTranslatorComment($xmlFormFile);
|
||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $originOptionNode);
|
||||
$poFile->addTranslation($msgid, stripslashes($originOptionNode));
|
||||
$poFile->addTranslation(stripslashes($msgid), stripslashes($originOptionNode));
|
||||
}
|
||||
} else {
|
||||
foreach( $originOptionNode as $optionNode ) {
|
||||
$optionName = $optionNode['name'];
|
||||
$originOptionValue = getTextValue($optionNode);
|
||||
$originOptionValue = $optionNode['__nodeText__'];
|
||||
|
||||
if( $targetOptionExists ){
|
||||
|
||||
@@ -266,17 +254,8 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
} else {
|
||||
$targetOptionValue = $originOptionValue;
|
||||
}
|
||||
|
||||
//$targetOptionValue = ($targetOptionValue != '') ? $targetOptionValue : "''";
|
||||
//$optionName = ($optionName != '') ? $optionName : "''";
|
||||
|
||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
||||
/*g::dump($xmlFormFile . '?' . $nodeName . '-'. $originOptionValue);
|
||||
g::dump($xmlFormFile);
|
||||
g::dump($nodeType . ' - ' . $nodeName . ' - ' . $originOptionValue);
|
||||
g::dump($msgid);
|
||||
g::dump($targetOptionValue);*/
|
||||
|
||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
||||
$poFile->addTranslatorComment($xmlFormFile);
|
||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
||||
@@ -287,9 +266,7 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
} //end foreach
|
||||
|
||||
}
|
||||
//die;
|
||||
//g::pr($aEnglishLabel); die;
|
||||
/*******************/
|
||||
|
||||
//
|
||||
//$timer->setMarker('end xml files processed');
|
||||
//$profiling = $timer->getProfiling();
|
||||
@@ -300,17 +277,10 @@ foreach ($aXMLForms as $xmlFormPath) {
|
||||
|
||||
G::streamFile($sPOFile, true);
|
||||
|
||||
function getTextValue($arrayNode){
|
||||
return isset($arrayNode['#text']) ? $arrayNode['#text']: (isset($arrayNode['#cdata-section']) ? $arrayNode['#cdata-section']: '');
|
||||
}
|
||||
|
||||
function getMatchDropdownOptionValue($name, $options){
|
||||
foreach($options as $option){
|
||||
//echo $name .'=='. $option['name'];
|
||||
//echo '----------------------------<br>';
|
||||
if($name == $option['name']){
|
||||
//echo '[[[[['.getTextValue($option).']]]]]';
|
||||
return getTextValue($option);
|
||||
return $option['__nodeText__'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -75,7 +75,13 @@ try {
|
||||
|
||||
$result->msg = G::LoadTranslation('IMPORT_LANGUAGE_SUCCESS') . "\n";
|
||||
$result->msg .= "PO File num. records: " . $importResults->recordsCount . "\n";
|
||||
$result->msg .= "Records registered successfully : " . $importResults->recordsCountSuccess . "\n";
|
||||
$result->msg .= "Success Records: " . $importResults->recordsCountSuccess . "\n";
|
||||
$result->msg .= "Failed Records: " . ($importResults->recordsCount-$importResults->recordsCountSuccess) . "\n";
|
||||
|
||||
if( $importResults->errMsg != '' ){
|
||||
$result->msg .= "Errors registered: \n" . $importResults->errMsg . "\n";
|
||||
}
|
||||
|
||||
//$result->msg = htmlentities($result->msg);
|
||||
$result->success = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user