Improvement add options processmaker

- Add plugins-translation-create.
- Add plugins-translation-update
This commit is contained in:
Marco Antonio Nina
2013-03-13 12:34:23 -04:00
parent 4f1e036477
commit 0bc5001117
3 changed files with 23 additions and 34 deletions

View File

@@ -29,7 +29,7 @@ G::LoadClass("wsTools");
CLI::taskName('plugins-translation-update');
CLI::taskDescription(<<<EOT
Update language of plugin
Update plugin translations
EOT
);
@@ -39,7 +39,7 @@ CLI::taskRun(run_update);
CLI::taskName('plugins-translation-create');
CLI::taskDescription(<<<EOT
Created language .po of plugin
Create .po file for the plugin
EOT
);
@@ -50,11 +50,11 @@ CLI::taskRun(run_create);
function run_create($command, $args)
{
CLI::logging("Creating file .po ..\n");
CLI::logging("Create .po file ...\n");
$language = new Language();
$language->createLanguagePlugin($command[0], $command[1]);
CLI::logging("Creating successful\n");
CLI::logging("Create successful\n");
}

View File

@@ -44,6 +44,7 @@
*/
class Language extends BaseLanguage
{
private $exceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable');
public function load ($sLanUid)
{
@@ -423,11 +424,6 @@ class Language extends BaseLanguage
//$timer->setMarker('end making 1th .po from db');
//now find labels in xmlforms
$aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable'
);
//find all xml files into PATH_XMLFORM
$aXMLForms = glob( PATH_XMLFORM . '*/*.xml' );
//from a sublevel to
@@ -455,7 +451,7 @@ class Language extends BaseLanguage
//$arrayNode = $dynaForm->getArray($oNode, Array('type', $_BASE_LANG, $_BASE_LANG));
$arrayNode = $dynaForm->getArray( $oNode );
//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'], $this->exceptionFields ))) {
continue; //just continue with the next node
}
@@ -548,7 +544,7 @@ class Language extends BaseLanguage
die();
}
if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) {
throw new Exception( 'The not exist the file ' . $plugin . '.' . $idLanguage . '.po' );
throw new Exception( 'The file ' . $plugin . '.' . $idLanguage . '.po not exists' );
die();
}
$languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po' ;//PATH_LANGUAGECONT . $plugin . '.' . $idLanguage;
@@ -664,7 +660,6 @@ class Language extends BaseLanguage
G::LoadClass( "system" );
//creating the .po file
//$sPOFile = PATH_LANGUAGECONT . $plugin . '.' . $idLanguage . '.po';
$sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po';
$poFile = new i18n_PO( $sPOFile );
$poFile->buildInit();
@@ -672,8 +667,8 @@ class Language extends BaseLanguage
$language = new Language();
$locale = $language;
$_TARGET_LANG = $idLanguage;
$_BASE_LANG = 'en';
$targetLang = $idLanguage;
$baseLang = 'en';
//setting headers
$poFile->addHeader( 'Project-Id-Version', $plugin );
@@ -691,7 +686,6 @@ class Language extends BaseLanguage
$aLabels = array ();
$aMsgids = array ('' => true
);
//global $translations;
include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php';
foreach ($translations as $id => $translation) {
@@ -705,9 +699,6 @@ class Language extends BaseLanguage
$aMsgids[$msgid] = true;
}
//now find labels in xmlforms
$aExceptionFields = array ('','javascript','hidden','phpvariable','private','toolbar','xmlmenu','toolbutton','cellmark','grid','CheckboxTable'
);
$aXMLForms = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*.xml' );
$aXMLForms2 = glob( PATH_PLUGINS . $plugin . PATH_SEP . '*/*.xml' );
$aXMLForms = array_merge( $aXMLForms, $aXMLForms2 );
@@ -729,22 +720,22 @@ class Language extends BaseLanguage
$sNodeName = $oNode->nodeName;
$arrayNode = $dynaForm->getArray( $oNode );
//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[$baseLang] ) || ! isset( $arrayNode['type'] ) || (isset( $arrayNode['type'] ) && in_array( $arrayNode['type'], $this->exceptionFields ))) {
continue; //just continue with the next node
}
// Getting the Base Origin Text
if (! is_array( $arrayNode[$_BASE_LANG] )) {
$originNodeText = trim( $arrayNode[$_BASE_LANG] );
if (! is_array( $arrayNode[$baseLang] )) {
$originNodeText = trim( $arrayNode[$baseLang] );
} else {
$langNode = $arrayNode[$_BASE_LANG][0];
$langNode = $arrayNode[$baseLang][0];
$originNodeText = $langNode['__nodeText__'];
}
// Getting the Base Target Text
if (isset( $arrayNode[$_TARGET_LANG] )) {
if (! is_array( $arrayNode[$_TARGET_LANG] )) {
$targetNodeText = trim( $arrayNode[$_TARGET_LANG] );
if (isset( $arrayNode[$targetLang] )) {
if (! is_array( $arrayNode[$targetLang] )) {
$targetNodeText = trim( $arrayNode[$targetLang] );
} else {
$langNode = $arrayNode[$_TARGET_LANG][0];
$langNode = $arrayNode[$targetLang][0];
$targetNodeText = $langNode['__nodeText__'];
}
} else {
@@ -764,11 +755,11 @@ class Language extends BaseLanguage
$aMsgids[$msgid] = true;
//if this node has options child nodes
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
if (isset( $arrayNode[$baseLang] ) && isset( $arrayNode[$baseLang][0] ) && isset( $arrayNode[$baseLang][0]['option'] )) {
$originOptionNode = $arrayNode[$baseLang][0]['option']; //get the options
$targetOptionExists = false;
if (isset( $arrayNode[$_TARGET_LANG] ) && isset( $arrayNode[$_TARGET_LANG][0] ) && isset( $arrayNode[$_TARGET_LANG][0]['option'] )) {
$targetOptionNode = $arrayNode[$_TARGET_LANG][0]['option'];
if (isset( $arrayNode[$targetLang] ) && isset( $arrayNode[$targetLang][0] ) && isset( $arrayNode[$targetLang][0]['option'] )) {
$targetOptionNode = $arrayNode[$targetLang][0]['option'];
$targetOptionExists = true;
}
if (! is_array( $originOptionNode )) {
@@ -800,7 +791,6 @@ class Language extends BaseLanguage
}
} //end foreach
}
//G::streamFile( $sPOFile, true );
}
}
// Language

View File

@@ -225,7 +225,7 @@ class Translation extends BaseTranslation
//to do: uniform coderror structures for all classes
}
/* Load strings from plugin translation.php .
/* Load strings from plugin translation.php.
* @parameter $languageId (es|en|...).
*/
public function generateFileTranslationPlugin ($plugin, $languageId = '')
@@ -236,7 +236,6 @@ class Translation extends BaseTranslation
if ($languageId === '') {
$languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
}
global $translations;
include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php';
$cacheFile = PATH_LANGUAGECONT . $plugin . "." . $languageId;
@@ -255,7 +254,7 @@ class Translation extends BaseTranslation
}
$f = fopen( $cacheFile, 'w+' );
fwrite( $f, "<?php\n" );
fwrite( $f, '$translation =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
fwrite( $f, '$translation' . $plugin . ' =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
fwrite( $f, "?>" );
fclose( $f );