Improvement function processmaker plugins-translation

- file .po is read and created in the plugin.
This commit is contained in:
Marco Antonio Nina
2013-03-18 09:54:30 -04:00
parent 2602ef162f
commit 87cd036826
2 changed files with 13 additions and 13 deletions

View File

@@ -537,20 +537,20 @@ class Language extends BaseLanguage
} }
G::streamFile( $sPOFile, true ); G::streamFile( $sPOFile, true );
} }
function updateLanguagePlugin ($plugin, $idLanguage) public function updateLanguagePlugin ($plugin, $idLanguage)
{ {
if (!file_exists(PATH_PLUGINS . $plugin)) { if (!file_exists(PATH_PLUGINS . $plugin)) {
throw new Exception( 'The plugin ' . $plugin . ' not exist' ); throw new Exception( 'The plugin ' . $plugin . ' not exist' );
die(); die();
} }
if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translation.php')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) {
throw new Exception( 'Translation.php not exist in plugin ' . $plugin); throw new Exception( 'Translations.php not exist in plugin ' . $plugin);
} }
if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) {
throw new Exception( 'The file ' . $plugin . '.' . $idLanguage . '.po not exists' ); throw new Exception( 'The file ' . $plugin . '.' . $idLanguage . '.po not exists' );
die(); die();
} }
$languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po' ;//PATH_LANGUAGECONT . $plugin . '.' . $idLanguage; $languageFile = PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po' ;
try { try {
G::LoadSystem( 'i18n_po' ); G::LoadSystem( 'i18n_po' );
$POFile = new i18n_PO( $languageFile ); $POFile = new i18n_PO( $languageFile );
@@ -657,9 +657,9 @@ class Language extends BaseLanguage
} }
} }
function createLanguagePlugin ($plugin, $idLanguage) public function createLanguagePlugin ($plugin, $idLanguage)
{ {
if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translation.php')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) {
throw new Exception( 'Translation.php not exist in plugin ' . $plugin); throw new Exception( 'Translation.php not exist in plugin ' . $plugin);
} }
@@ -667,7 +667,7 @@ class Language extends BaseLanguage
G::LoadClass( "system" ); G::LoadClass( "system" );
//creating the .po file //creating the .po file
$sPOFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po'; $sPOFile = PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po';
$poFile = new i18n_PO( $sPOFile ); $poFile = new i18n_PO( $sPOFile );
$poFile->buildInit(); $poFile->buildInit();
@@ -693,7 +693,7 @@ class Language extends BaseLanguage
$aLabels = array (); $aLabels = array ();
$aMsgids = array ('' => true $aMsgids = array ('' => true
); );
include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translations.php';
foreach ($translations as $id => $translation) { foreach ($translations as $id => $translation) {
$msgid = trim( $translation); $msgid = trim( $translation);

View File

@@ -230,11 +230,11 @@ class Translation extends BaseTranslation
*/ */
public function generateFileTranslationPlugin ($plugin, $languageId = '') public function generateFileTranslationPlugin ($plugin, $languageId = '')
{ {
if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translation.php')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translations.php')) {
return; return;
} }
if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po')) { if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po')) {
return; return;
} }
$translation = Array (); $translation = Array ();
@@ -243,7 +243,7 @@ class Translation extends BaseTranslation
if ($languageId === '') { if ($languageId === '') {
$languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en'; $languageId = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
} }
include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translation.php'; include PATH_PLUGINS . $plugin . PATH_SEP . 'translations'. PATH_SEP . 'translations.php';
$cacheFile = PATH_LANGUAGECONT . $plugin . "." . $languageId; $cacheFile = PATH_LANGUAGECONT . $plugin . "." . $languageId;
$cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js"; $cacheFileJS = PATH_CORE . 'js' . PATH_SEP . 'labels' . PATH_SEP . $languageId . ".js";
@@ -251,7 +251,7 @@ class Translation extends BaseTranslation
foreach ($translations as $key => $row) { foreach ($translations as $key => $row) {
$translation[$key] = $row; $translation[$key] = $row;
} }
$languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po' ; $languageFile = PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po' ;
G::LoadSystem( 'i18n_po' ); G::LoadSystem( 'i18n_po' );
$POFile = new i18n_PO( $languageFile ); $POFile = new i18n_PO( $languageFile );
$POFile->readInit(); $POFile->readInit();