From 911b96f3e008580cb77a50e92e50694540e96457 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Fri, 15 Mar 2013 14:27:33 -0400 Subject: [PATCH 1/2] Improvement functions processmaker plugins-translation --- workflow/engine/classes/model/Translation.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index 65e39c8f1..0dd3110dd 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -244,6 +244,37 @@ class Translation extends BaseTranslation foreach ($translations as $key => $row) { $translation[$key] = $row; } + $languageFile = PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po' ; + G::LoadSystem( 'i18n_po' ); + $POFile = new i18n_PO( $languageFile ); + $POFile->readInit(); + while ($rowTranslation = $POFile->getTranslation()) { + foreach ($POFile->translatorComments as $a => $aux) { + $aux = trim( $aux ); + if ($aux == 'TRANSLATION') { + $identifier = $aux; + } else { + $var = explode( '/', $aux ); + if ($var[0] == 'LABEL') { + $context = $aux; + } + if ($var[0] == 'JAVASCRIPT') { + $context = $aux; + } + } + if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml\?)/', $aux, $match )) { + $identifier = $aux; + } else { + if (preg_match( '/^([\w-]+)\/([\w-]+\/*[\w-]*\.xml$)/', $aux, $match )) { + $context = $aux; + } + } + } + if ($identifier == 'TRANSLATION') { + list ($category, $id) = explode( '/', $context ); + $translation[$id] = $rowTranslation['msgstr'] ; + } + } try { if (! is_dir( dirname( $cacheFile ) )) { From b9f5552ed6cd779ad27384a58adba096a87e1f61 Mon Sep 17 00:00:00 2001 From: Marco Antonio Nina Date: Fri, 15 Mar 2013 15:37:22 -0400 Subject: [PATCH 2/2] Improvement validation funcition plugin-translation --- workflow/engine/classes/model/Language.php | 7 +++++++ workflow/engine/classes/model/Translation.php | 11 +++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/workflow/engine/classes/model/Language.php b/workflow/engine/classes/model/Language.php index c139f0a46..5619bf8d9 100755 --- a/workflow/engine/classes/model/Language.php +++ b/workflow/engine/classes/model/Language.php @@ -543,6 +543,9 @@ class Language extends BaseLanguage throw new Exception( 'The plugin ' . $plugin . ' not exist' ); die(); } + if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translation.php')) { + throw new Exception( 'Translation.php not exist in plugin ' . $plugin); + } if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $idLanguage . '.po')) { throw new Exception( 'The file ' . $plugin . '.' . $idLanguage . '.po not exists' ); die(); @@ -656,6 +659,10 @@ class Language extends BaseLanguage function createLanguagePlugin ($plugin, $idLanguage) { + if (!file_exists(PATH_PLUGINS . $plugin . PATH_SEP . 'translations' . PATH_SEP . 'translation.php')) { + throw new Exception( 'Translation.php not exist in plugin ' . $plugin); + } + G::LoadSystem( 'i18n_po' ); G::LoadClass( "system" ); diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index 0dd3110dd..d817d5591 100755 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -230,6 +230,13 @@ class Translation extends BaseTranslation */ public function generateFileTranslationPlugin ($plugin, $languageId = '') { + if (!file_exists(PATH_PLUGINS . $plugin . 'translations' . PATH_SEP . 'translation.php')) { + return; + } + + if (!file_exists(PATH_CORE . 'content' . PATH_SEP . 'translations' . PATH_SEP . $plugin . '.' . $languageId . '.po')) { + return; + } $translation = Array (); $translationJS = Array (); @@ -271,8 +278,8 @@ class Translation extends BaseTranslation } } if ($identifier == 'TRANSLATION') { - list ($category, $id) = explode( '/', $context ); - $translation[$id] = $rowTranslation['msgstr'] ; + list ($category, $id) = explode( '/', $context ); + $translation[$id] = $rowTranslation['msgstr'] ; } }