BUG 9648 Duplicate identifier in english po SOLVED
- The msgid don't validate correctly the empty string - Add validation to prevent msgid values duplicated
This commit is contained in:
@@ -42,8 +42,8 @@ require_once 'classes/model/Translation.php';
|
|||||||
* @package workflow.engine.classes.model
|
* @package workflow.engine.classes.model
|
||||||
*/
|
*/
|
||||||
class Language extends BaseLanguage {
|
class Language extends BaseLanguage {
|
||||||
|
|
||||||
function load($sLanUid)
|
function load($sLanUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$oRow = LanguagePeer::retrieveByPK($sLanUid);
|
$oRow = LanguagePeer::retrieveByPK($sLanUid);
|
||||||
@@ -62,7 +62,7 @@ class Language extends BaseLanguage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($aFields)
|
function update($aFields)
|
||||||
{
|
{
|
||||||
$oConnection = Propel::getConnection(LanguagePeer::DATABASE_NAME);
|
$oConnection = Propel::getConnection(LanguagePeer::DATABASE_NAME);
|
||||||
try {
|
try {
|
||||||
@@ -92,18 +92,18 @@ class Language extends BaseLanguage {
|
|||||||
$oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
|
$oCriteria->addSelectColumn(LanguagePeer::LAN_NAME);
|
||||||
$oCriteria->add(LanguagePeer::LAN_ENABLED , '1');
|
$oCriteria->add(LanguagePeer::LAN_ENABLED , '1');
|
||||||
$oCriteria->addDescendingOrderByColumn(LanguagePeer::LAN_WEIGHT);
|
$oCriteria->addDescendingOrderByColumn(LanguagePeer::LAN_WEIGHT);
|
||||||
|
|
||||||
$oDataset = ContentPeer::doSelectRS($oCriteria);
|
$oDataset = ContentPeer::doSelectRS($oCriteria);
|
||||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
$oContent = new Content();
|
$oContent = new Content();
|
||||||
$rows = Array();
|
$rows = Array();
|
||||||
while ($oDataset->next())
|
while ($oDataset->next())
|
||||||
array_push($rows, $oDataset->getRow());
|
array_push($rows, $oDataset->getRow());
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
function findById($LAN_ID)
|
function findById($LAN_ID)
|
||||||
{
|
{
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
@@ -114,7 +114,7 @@ class Language extends BaseLanguage {
|
|||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
return $oDataset->getRow();
|
return $oDataset->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
function findByLanName($LAN_NAME)
|
function findByLanName($LAN_NAME)
|
||||||
{
|
{
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
@@ -126,14 +126,14 @@ class Language extends BaseLanguage {
|
|||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
return $oDataset->getRow();
|
return $oDataset->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Import a language file
|
* Import a language file
|
||||||
*
|
*
|
||||||
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail>
|
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail>
|
||||||
* @param string $sLanguageFile
|
* @param string $sLanguageFile
|
||||||
* @param string $bXml
|
* @param string $bXml
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function import($sLanguageFile, $updateXml = true, $updateDB = true)
|
public function import($sLanguageFile, $updateXml = true, $updateDB = true)
|
||||||
{
|
{
|
||||||
@@ -142,16 +142,16 @@ class Language extends BaseLanguage {
|
|||||||
$POFile = new i18n_PO($sLanguageFile);
|
$POFile = new i18n_PO($sLanguageFile);
|
||||||
$POFile->readInit();
|
$POFile->readInit();
|
||||||
$POHeaders = $POFile->getHeaders();
|
$POHeaders = $POFile->getHeaders();
|
||||||
|
|
||||||
/*getting the PO Language definition*/
|
/*getting the PO Language definition*/
|
||||||
$langName = $POHeaders['X-Poedit-Language'];
|
$langName = $POHeaders['X-Poedit-Language'];
|
||||||
//find the lang id
|
//find the lang id
|
||||||
$language = new Language();
|
$language = new Language();
|
||||||
$langRecord = $language->findByLanName($langName);
|
$langRecord = $language->findByLanName($langName);
|
||||||
|
|
||||||
if( ! isset($langRecord['LAN_ID']) ) //if the language doesn't exist abort
|
if( ! isset($langRecord['LAN_ID']) ) //if the language doesn't exist abort
|
||||||
throw new Exception('The .po file has a invalid X-Poedit-Language definition!');
|
throw new Exception('The .po file has a invalid X-Poedit-Language definition!');
|
||||||
|
|
||||||
$languageID = $langRecord['LAN_ID'];
|
$languageID = $langRecord['LAN_ID'];
|
||||||
|
|
||||||
/*getting the PO Language definition*/
|
/*getting the PO Language definition*/
|
||||||
@@ -169,21 +169,21 @@ class Language extends BaseLanguage {
|
|||||||
} else {
|
} else {
|
||||||
$LOCALE = $languageID;
|
$LOCALE = $languageID;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oTranslation = new Translation();
|
$oTranslation = new Translation();
|
||||||
$countItems = 0;
|
$countItems = 0;
|
||||||
$countItemsSuccess = 0;
|
$countItemsSuccess = 0;
|
||||||
$errorMsg = '';
|
$errorMsg = '';
|
||||||
|
|
||||||
while( $rowTranslation = $POFile->getTranslation() ) {
|
while( $rowTranslation = $POFile->getTranslation() ) {
|
||||||
|
|
||||||
$countItems++;
|
$countItems++;
|
||||||
|
|
||||||
if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
|
if ( ! isset($POFile->translatorComments[0]) || ! isset($POFile->translatorComments[1]) || ! isset($POFile->references[0]) ) {
|
||||||
throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
|
throw new Exception('The .po file doesn\'t have valid directives for Processmaker!');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($POFile->translatorComments as $a=>$aux){
|
foreach($POFile->translatorComments as $a=>$aux){
|
||||||
$aux = trim($aux);
|
$aux = trim($aux);
|
||||||
if ( $aux == 'TRANSLATION')
|
if ( $aux == 'TRANSLATION')
|
||||||
$identifier = $aux;
|
$identifier = $aux;
|
||||||
@@ -194,16 +194,16 @@ class Language extends BaseLanguage {
|
|||||||
if ($var[0]=='JAVASCRIPT')
|
if ($var[0]=='JAVASCRIPT')
|
||||||
$context = $aux;
|
$context = $aux;
|
||||||
}
|
}
|
||||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
|
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match))
|
||||||
$identifier = $aux;
|
$identifier = $aux;
|
||||||
else{
|
else{
|
||||||
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
|
if (preg_match('/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match))
|
||||||
$context = $aux;
|
$context = $aux;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$reference = $POFile->references[0];
|
$reference = $POFile->references[0];
|
||||||
|
|
||||||
// it is a Sql insert on TRANSLATIONS TAble
|
// it is a Sql insert on TRANSLATIONS TAble
|
||||||
if( $identifier == 'TRANSLATION') {
|
if( $identifier == 'TRANSLATION') {
|
||||||
if ($updateDB) {
|
if ($updateDB) {
|
||||||
@@ -220,32 +220,32 @@ class Language extends BaseLanguage {
|
|||||||
$errorMsg .= $id .': ' . $result['message'] . "\n";
|
$errorMsg .= $id .': ' . $result['message'] . "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// is a Xml update
|
// is a Xml update
|
||||||
else if( $updateXml ) {
|
else if( $updateXml ) {
|
||||||
|
|
||||||
$xmlForm = $context;
|
$xmlForm = $context;
|
||||||
//erik: expresion to prevent and hable correctly dropdown values like -1, -2 etc.
|
//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);
|
preg_match('/^([\w_]+)\s-\s([\w_]+)\s*-*\s*([\w\W]*)$/', $reference, $match);
|
||||||
|
|
||||||
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
if( ! file_exists(PATH_XMLFORM . $xmlForm) ) {
|
||||||
$errorMsg .= 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm . "\n";
|
$errorMsg .= 'file doesn\'t exist: ' . PATH_XMLFORM . $xmlForm . "\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($match) < 4) {
|
if (count($match) < 4) {
|
||||||
$near = isset($rowTranslation['msgid']) ? $rowTranslation['msgid'] :
|
$near = isset($rowTranslation['msgid']) ? $rowTranslation['msgid'] :
|
||||||
(isset($rowTranslation['msgstr']) ? $rowTranslation['msgstr'] : '');
|
(isset($rowTranslation['msgstr']) ? $rowTranslation['msgstr'] : '');
|
||||||
$errorMsg .= "Invalid Translation reference: \"$reference\", near -> ".$near."\n";
|
$errorMsg .= "Invalid Translation reference: \"$reference\", near -> ".$near."\n";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
G::LoadSystem('dynaformhandler');
|
G::LoadSystem('dynaformhandler');
|
||||||
$dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
|
$dynaform = new dynaFormHandler(PATH_XMLFORM . $xmlForm);
|
||||||
$fieldName = $match[2];
|
$fieldName = $match[2];
|
||||||
|
|
||||||
$codes = explode('-', $reference);
|
$codes = explode('-', $reference);
|
||||||
|
|
||||||
if( sizeof($codes) == 2 ) { //is a normal node
|
if( sizeof($codes) == 2 ) { //is a normal node
|
||||||
$dynaform->addChilds($fieldName, Array($LOCALE=>stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr']))));
|
$dynaform->addChilds($fieldName, Array($LOCALE=>stripcslashes(str_replace(chr(10), '', $rowTranslation['msgstr']))));
|
||||||
} else if( sizeof($codes) > 2 ) { //is a node child for a language node
|
} else if( sizeof($codes) > 2 ) { //is a node child for a language node
|
||||||
@@ -259,18 +259,18 @@ class Language extends BaseLanguage {
|
|||||||
$countItemsSuccess++;
|
$countItemsSuccess++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$oLanguage = new Language();
|
$oLanguage = new Language();
|
||||||
$oLanguage->update(array('LAN_ID' => $languageID, 'LAN_ENABLED' => '1'));
|
$oLanguage->update(array('LAN_ID' => $languageID, 'LAN_ENABLED' => '1'));
|
||||||
|
|
||||||
$trn = new Translation();
|
$trn = new Translation();
|
||||||
$trn->generateFileTranslation($LOCALE);
|
$trn->generateFileTranslation($LOCALE);
|
||||||
$trn->addTranslationEnvironment($LOCALE, $POHeaders, $countItemsSuccess);
|
$trn->addTranslationEnvironment($LOCALE, $POHeaders, $countItemsSuccess);
|
||||||
|
|
||||||
$content = new Content();
|
$content = new Content();
|
||||||
$content->regenerateContent($languageID);
|
$content->regenerateContent($languageID);
|
||||||
|
|
||||||
//fill the results
|
//fill the results
|
||||||
$results = new stdClass();
|
$results = new stdClass();
|
||||||
$results->recordsCount = $countItems;
|
$results->recordsCount = $countItems;
|
||||||
@@ -278,7 +278,7 @@ class Language extends BaseLanguage {
|
|||||||
$results->lang = $languageID;
|
$results->lang = $languageID;
|
||||||
$results->headers = $POHeaders;
|
$results->headers = $POHeaders;
|
||||||
$results->errMsg = $errorMsg;
|
$results->errMsg = $errorMsg;
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
catch (Exception $oError) {
|
||||||
@@ -289,7 +289,7 @@ class Language extends BaseLanguage {
|
|||||||
//export
|
//export
|
||||||
function export()
|
function export()
|
||||||
{
|
{
|
||||||
//G::LoadThirdParty('pear', 'Benchmark/Timer');
|
//G::LoadThirdParty('pear', 'Benchmark/Timer');
|
||||||
G::LoadSystem('i18n_po');
|
G::LoadSystem('i18n_po');
|
||||||
G::LoadClass("system");
|
G::LoadClass("system");
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ class Language extends BaseLanguage {
|
|||||||
|
|
||||||
if( ! isset($langRecord['LAN_NAME']) )
|
if( ! isset($langRecord['LAN_NAME']) )
|
||||||
throw new Exception("Language Target ID \"{$LAN_ID}\" doesn't exist!");
|
throw new Exception("Language Target ID \"{$LAN_ID}\" doesn't exist!");
|
||||||
|
|
||||||
$sLanguage = $langRecord['LAN_NAME'];
|
$sLanguage = $langRecord['LAN_NAME'];
|
||||||
|
|
||||||
//setting headers
|
//setting headers
|
||||||
@@ -348,7 +348,7 @@ class Language extends BaseLanguage {
|
|||||||
//export translation
|
//export translation
|
||||||
|
|
||||||
$aLabels = array();
|
$aLabels = array();
|
||||||
$aMsgids = array();
|
$aMsgids = array('' => true);
|
||||||
|
|
||||||
// selecting all translations records of base language 'en' on TRANSLATIONS table
|
// selecting all translations records of base language 'en' on TRANSLATIONS table
|
||||||
$oCriteria = new Criteria('workflow');
|
$oCriteria = new Criteria('workflow');
|
||||||
@@ -369,7 +369,7 @@ class Language extends BaseLanguage {
|
|||||||
$c->add(TranslationPeer::TRN_LANG, $_GET['LOCALE']);
|
$c->add(TranslationPeer::TRN_LANG, $_GET['LOCALE']);
|
||||||
$ds = TranslationPeer::doSelectRS($c);
|
$ds = TranslationPeer::doSelectRS($c);
|
||||||
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
$ds->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
|
||||||
while ($ds->next()) {
|
while ($ds->next()) {
|
||||||
$row = $ds->getRow();
|
$row = $ds->getRow();
|
||||||
$targetLangRecords[$row['TRN_CATEGORY'].'/'.$row['TRN_ID']] = $row['TRN_VALUE'];
|
$targetLangRecords[$row['TRN_CATEGORY'].'/'.$row['TRN_ID']] = $row['TRN_VALUE'];
|
||||||
@@ -377,24 +377,24 @@ class Language extends BaseLanguage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get the respective translation for each english label
|
// get the respective translation for each english label
|
||||||
while ($oDataset->next()) {
|
while ($oDataset->next()) {
|
||||||
$aRow1 = $oDataset->getRow();
|
$aRow1 = $oDataset->getRow();
|
||||||
$trnCategory = trim($aRow1['TRN_CATEGORY']);
|
$trnCategory = trim($aRow1['TRN_CATEGORY']);
|
||||||
|
|
||||||
|
|
||||||
# Validation, validate that the TRN_CATEGORY contains valid characteres
|
# Validation, validate that the TRN_CATEGORY contains valid characteres
|
||||||
preg_match("/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult);
|
preg_match("/^[0-9a-zA-Z_-]+/", $trnCategory, $sTestResult);
|
||||||
|
|
||||||
// IF the translations id "TRN_ID" has invalid characteres or has not accepted categories
|
// IF the translations id "TRN_ID" has invalid characteres or has not accepted categories
|
||||||
if ($sTestResult[0] !== $trnCategory || ($trnCategory != 'LABEL' && $trnCategory != 'JAVASCRIPT')) {
|
if ($sTestResult[0] !== $trnCategory || ($trnCategory != 'LABEL' && $trnCategory != 'JAVASCRIPT')) {
|
||||||
$oTranslation = new Translation;
|
$oTranslation = new Translation;
|
||||||
$oTranslation->remove($aRow1['TRN_CATEGORY'], $aRow1['TRN_ID'], 'en'); //remove not accepted translations
|
$oTranslation->remove($aRow1['TRN_CATEGORY'], $aRow1['TRN_ID'], 'en'); //remove not accepted translations
|
||||||
continue; //jump to next iteration
|
continue; //jump to next iteration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// retrieve the translation for the target language
|
// retrieve the translation for the target language
|
||||||
if( $LAN_ID != 'en' ){ // only if it is different language than base language 'en'
|
if( $LAN_ID != 'en' ){ // only if it is different language than base language 'en'
|
||||||
@@ -408,10 +408,10 @@ class Language extends BaseLanguage {
|
|||||||
$msgstr = $aRow1['TRN_VALUE'];
|
$msgstr = $aRow1['TRN_VALUE'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$msgid = trim($aRow1['TRN_VALUE']);
|
$msgid = trim($aRow1['TRN_VALUE']);
|
||||||
$msgstr = trim($msgstr);
|
$msgstr = trim($msgstr);
|
||||||
|
|
||||||
if ( isset($aMsgids[$msgid]) ) {
|
if ( isset($aMsgids[$msgid]) ) {
|
||||||
$msgid = '[' . $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] . '] ' . $msgid;
|
$msgid = '[' . $aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID'] . '] ' . $msgid;
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ class Language extends BaseLanguage {
|
|||||||
$poFile->addTranslatorComment('TRANSLATION');
|
$poFile->addTranslatorComment('TRANSLATION');
|
||||||
$poFile->addTranslatorComment($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
|
$poFile->addTranslatorComment($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
|
||||||
$poFile->addReference($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
|
$poFile->addReference($aRow1['TRN_CATEGORY'] . '/' . $aRow1['TRN_ID']);
|
||||||
|
|
||||||
$poFile->addTranslation(stripcslashes($msgid), stripcslashes($msgstr));
|
$poFile->addTranslation(stripcslashes($msgid), stripcslashes($msgstr));
|
||||||
$aMsgids[$msgid] = true;
|
$aMsgids[$msgid] = true;
|
||||||
}
|
}
|
||||||
@@ -428,7 +428,7 @@ class Language extends BaseLanguage {
|
|||||||
|
|
||||||
//now find labels in xmlforms
|
//now find labels in xmlforms
|
||||||
/************/
|
/************/
|
||||||
$aExceptionFields = array('', 'javascript', 'hidden', 'phpvariable', 'private', 'toolbar', 'xmlmenu', 'toolbutton', 'cellmark', 'grid');
|
$aExceptionFields = array('', 'javascript', 'hidden', 'phpvariable', 'private', 'toolbar', 'xmlmenu', 'toolbutton', 'cellmark', 'grid', 'CheckboxTable');
|
||||||
|
|
||||||
//find all xml files into PATH_XMLFORM
|
//find all xml files into PATH_XMLFORM
|
||||||
$aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
|
$aXMLForms = glob(PATH_XMLFORM . '*/*.xml');
|
||||||
@@ -445,22 +445,22 @@ class Language extends BaseLanguage {
|
|||||||
foreach ($aXMLForms as $xmlFormPath) {
|
foreach ($aXMLForms as $xmlFormPath) {
|
||||||
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
$xmlFormFile = str_replace( chr(92), '/', $xmlFormPath);
|
||||||
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
$xmlFormFile = str_replace( PATH_XMLFORM, '', $xmlFormPath);
|
||||||
|
|
||||||
$dynaForm = new dynaFormHandler($xmlFormPath);
|
$dynaForm = new dynaFormHandler($xmlFormPath);
|
||||||
|
|
||||||
$dynaNodes = $dynaForm->getFields();
|
$dynaNodes = $dynaForm->getFields();
|
||||||
|
|
||||||
//get all fields of each xmlform
|
//get all fields of each xmlform
|
||||||
foreach ($dynaNodes as $oNode) {
|
foreach ($dynaNodes as $oNode) {
|
||||||
|
|
||||||
$sNodeName = $oNode->nodeName;
|
$sNodeName = $oNode->nodeName;
|
||||||
//$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
|
//$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
|
||||||
$arrayNode = $dynaForm->getArray($oNode);
|
$arrayNode = $dynaForm->getArray($oNode);
|
||||||
//if has not native language translation
|
//if has not native language translation
|
||||||
if( ! isset($arrayNode[$_BASE_LANG]) || ! isset($arrayNode['type']) || ( isset($arrayNode['type']) && in_array($arrayNode['type'], $aExceptionFields)) ){
|
if( ! isset($arrayNode[$_BASE_LANG]) || ! isset($arrayNode['type']) || ( isset($arrayNode['type']) && in_array($arrayNode['type'], $aExceptionFields)) ){
|
||||||
continue; //just continue with the next node
|
continue; //just continue with the next node
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting the Base Origin Text
|
// Getting the Base Origin Text
|
||||||
if( ! is_array($arrayNode[$_BASE_LANG]) )
|
if( ! is_array($arrayNode[$_BASE_LANG]) )
|
||||||
$originNodeText = trim($arrayNode[$_BASE_LANG]);
|
$originNodeText = trim($arrayNode[$_BASE_LANG]);
|
||||||
@@ -468,7 +468,7 @@ class Language extends BaseLanguage {
|
|||||||
$langNode = $arrayNode[$_BASE_LANG][0];
|
$langNode = $arrayNode[$_BASE_LANG][0];
|
||||||
$originNodeText = $langNode['__nodeText__'];
|
$originNodeText = $langNode['__nodeText__'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting the Base Target Text
|
// Getting the Base Target Text
|
||||||
if( isset($arrayNode[$_TARGET_LANG]) ) {
|
if( isset($arrayNode[$_TARGET_LANG]) ) {
|
||||||
if( ! is_array($arrayNode[$_TARGET_LANG]) )
|
if( ! is_array($arrayNode[$_TARGET_LANG]) )
|
||||||
@@ -480,34 +480,34 @@ class Language extends BaseLanguage {
|
|||||||
} else {
|
} else {
|
||||||
$targetNodeText = $originNodeText;
|
$targetNodeText = $originNodeText;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodeName = $arrayNode['__nodeName__'];
|
$nodeName = $arrayNode['__nodeName__'];
|
||||||
$nodeType = $arrayNode['type'];
|
$nodeType = $arrayNode['type'];
|
||||||
|
|
||||||
$msgid = $originNodeText;
|
$msgid = $originNodeText;
|
||||||
|
|
||||||
// if the nodeName already exists in the po file, we need to create other msgid
|
// if the nodeName already exists in the po file, we need to create other msgid
|
||||||
if( isset($aMsgids[$msgid]) )
|
if( isset($aMsgids[$msgid]) )
|
||||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText;
|
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '] ' . $originNodeText;
|
||||||
|
|
||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName);
|
||||||
$poFile->addTranslatorComment($xmlFormFile);
|
$poFile->addTranslatorComment($xmlFormFile);
|
||||||
$poFile->addReference($nodeType . ' - ' . $nodeName);
|
$poFile->addReference($nodeType . ' - ' . $nodeName);
|
||||||
$poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
|
$poFile->addTranslation(stripslashes($msgid), stripslashes($targetNodeText));
|
||||||
|
|
||||||
$aMsgids[$msgid] = true;
|
$aMsgids[$msgid] = true;
|
||||||
|
|
||||||
//if this node has options child nodes
|
//if this node has options child nodes
|
||||||
if( isset($arrayNode[$_BASE_LANG]) && isset($arrayNode[$_BASE_LANG][0]) && isset($arrayNode[$_BASE_LANG][0]['option']) ){
|
if( isset($arrayNode[$_BASE_LANG]) && isset($arrayNode[$_BASE_LANG][0]) && isset($arrayNode[$_BASE_LANG][0]['option']) ){
|
||||||
|
|
||||||
$originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options
|
$originOptionNode = $arrayNode[$_BASE_LANG][0]['option']; //get the options
|
||||||
|
|
||||||
$targetOptionExists = false;
|
$targetOptionExists = false;
|
||||||
if( isset($arrayNode[$_TARGET_LANG]) && isset($arrayNode[$_TARGET_LANG][0]) && isset($arrayNode[$_TARGET_LANG][0]['option']) ) {
|
if( isset($arrayNode[$_TARGET_LANG]) && isset($arrayNode[$_TARGET_LANG][0]) && isset($arrayNode[$_TARGET_LANG][0]['option']) ) {
|
||||||
$targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
|
$targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
|
||||||
$targetOptionExists = true;
|
$targetOptionExists = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_array($originOptionNode) ){
|
if ( ! is_array($originOptionNode) ){
|
||||||
if( is_string($originOptionNode) ){
|
if( is_string($originOptionNode) ){
|
||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $originOptionNode);
|
||||||
@@ -519,7 +519,7 @@ class Language extends BaseLanguage {
|
|||||||
foreach( $originOptionNode as $optionNode ) {
|
foreach( $originOptionNode as $optionNode ) {
|
||||||
$optionName = $optionNode['name'];
|
$optionName = $optionNode['name'];
|
||||||
$originOptionValue = $optionNode['__nodeText__'];
|
$originOptionValue = $optionNode['__nodeText__'];
|
||||||
|
|
||||||
if( $targetOptionExists ){
|
if( $targetOptionExists ){
|
||||||
|
|
||||||
$targetOptionValue = getMatchDropdownOptionValue($optionName, $targetOptionNode);
|
$targetOptionValue = getMatchDropdownOptionValue($optionName, $targetOptionNode);
|
||||||
@@ -529,8 +529,8 @@ class Language extends BaseLanguage {
|
|||||||
} else {
|
} else {
|
||||||
$targetOptionValue = $originOptionValue;
|
$targetOptionValue = $originOptionValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
$msgid = '[' . $xmlFormFile . '?' . $nodeName . '-' . $optionName . ']';
|
||||||
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
$poFile->addTranslatorComment($xmlFormFile . '?' . $nodeName . '-'. $optionName);
|
||||||
$poFile->addTranslatorComment($xmlFormFile);
|
$poFile->addTranslatorComment($xmlFormFile);
|
||||||
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
$poFile->addReference($nodeType . ' - ' . $nodeName . ' - ' . $optionName);
|
||||||
@@ -539,22 +539,22 @@ class Language extends BaseLanguage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} //end foreach
|
} //end foreach
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//$timer->setMarker('end xml files processed');
|
//$timer->setMarker('end xml files processed');
|
||||||
//$profiling = $timer->getProfiling();
|
//$profiling = $timer->getProfiling();
|
||||||
//$timer->stop(); $timer->display();
|
//$timer->stop(); $timer->display();
|
||||||
//echo G::getMemoryUsage();
|
//echo G::getMemoryUsage();
|
||||||
//die;
|
//die;
|
||||||
//g::pr($profiling);
|
//g::pr($profiling);
|
||||||
|
|
||||||
G::streamFile($sPOFile, true);
|
G::streamFile($sPOFile, true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Language
|
} // Language
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user