Add file translation Mafe
This commit is contained in:
@@ -330,10 +330,10 @@ class workspaceTools
|
||||
$extension = array_pop($names);
|
||||
$langid = array_pop($names);
|
||||
CLI::logging("Updating database translations with $poName\n");
|
||||
Language::import($poFile, false, true);
|
||||
Language::import($poFile, false, true, false);
|
||||
if ($first) {
|
||||
CLI::logging("Updating XML form translations with $poName\n");
|
||||
Language::import($poFile, true, false);
|
||||
Language::import($poFile, true, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class Language extends BaseLanguage
|
||||
* @param string $bXml
|
||||
* @return void
|
||||
*/
|
||||
public function import ($sLanguageFile, $updateXml = true, $updateDB = true)
|
||||
public function import ($sLanguageFile, $updateXml = true, $updateDB = true, $generateMafe = true)
|
||||
{
|
||||
try {
|
||||
G::LoadSystem( 'i18n_po' );
|
||||
@@ -288,6 +288,11 @@ class Language extends BaseLanguage
|
||||
$trn->addTranslationEnvironment( $LOCALE, $POHeaders, $countItemsSuccess );
|
||||
}
|
||||
|
||||
if ($generateMafe) {
|
||||
$trn = new Translation();
|
||||
$trn->generateFileTranslationMafe();
|
||||
}
|
||||
|
||||
//fill the results
|
||||
$results = new stdClass();
|
||||
$results->recordsCount = $countItems;
|
||||
|
||||
@@ -169,6 +169,7 @@ class Translation extends BaseTranslation
|
||||
if (! is_dir( dirname( $cacheFileJS ) )) {
|
||||
G::mk_dir( dirname( $cacheFileJS ) );
|
||||
}
|
||||
|
||||
$f = fopen( $cacheFile, 'w+' );
|
||||
fwrite( $f, "<?php\n" );
|
||||
fwrite( $f, '$translation =' . 'unserialize(\'' . addcslashes( serialize( $translation ), '\\\'' ) . "');\n" );
|
||||
@@ -178,7 +179,7 @@ class Translation extends BaseTranslation
|
||||
//$json = new Services_JSON(); DEPRECATED
|
||||
$f = fopen( $cacheFileJS, 'w' );
|
||||
if ($f == false) {
|
||||
error_log("Error: Cannot write into cachefilejs: $cacheFileJS\n");
|
||||
error_log("Error: Cannot write into cachefilejs: $cacheFileJS\n");
|
||||
} else {
|
||||
fwrite( $f, "var G_STRINGS =" . Bootstrap::json_encode( $translationJS ) . ";\n");
|
||||
fclose( $f );
|
||||
@@ -194,6 +195,55 @@ class Translation extends BaseTranslation
|
||||
}
|
||||
}
|
||||
|
||||
/* Load strings from a Database for labels MAFE.
|
||||
*
|
||||
*/
|
||||
public function generateFileTranslationMafe ()
|
||||
{
|
||||
$translation = Array ();
|
||||
|
||||
$c = new Criteria();
|
||||
$c->add( TranslationPeer::TRN_ID, '%ID_MAFE_%', CRITERIA::LIKE );
|
||||
$c->addAscendingOrderByColumn( 'TRN_CATEGORY' );
|
||||
$c->addAscendingOrderByColumn( 'TRN_ID' );
|
||||
$c->addAscendingOrderByColumn( 'TRN_LANG' );
|
||||
$tranlations = TranslationPeer::doSelect( $c );
|
||||
|
||||
$mafeFolder = PATH_HTML . "translations";
|
||||
$cacheFileMafe = PATH_HTML . "translations" . PATH_SEP. 'translationsMafe' . ".js";
|
||||
|
||||
foreach ($tranlations as $key => $row) {
|
||||
if ($row->getTrnCategory() === 'LABEL') {
|
||||
$translation[$row->getTrnLang()][$row->getTrnId()] = $row->getTrnValue();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
if (! is_dir( dirname( $mafeFolder ) )) {
|
||||
G::mk_dir( dirname( $mafeFolder, 0777 ) );
|
||||
}
|
||||
if (! is_dir( dirname( $cacheFileMafe ) )) {
|
||||
G::mk_dir( dirname( $cacheFileMafe ) );
|
||||
}
|
||||
|
||||
$f = fopen( $cacheFileMafe, 'w+' );
|
||||
if ($f == false) {
|
||||
error_log("Error: Cannot write into cacheFileMafe: $cacheFileMafe\n");
|
||||
} else {
|
||||
fwrite( $f, "var __TRANSLATIONMAFE = " . Bootstrap::json_encode( $translation ) . ";\n");
|
||||
fclose( $f );
|
||||
}
|
||||
|
||||
$res['cacheFileMafe'] = $cacheFileMafe;
|
||||
$res['languague'] = count($cacheFileMafe);
|
||||
$res['rowsMafeJS'] = count( $translation );
|
||||
return $res;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns an array with
|
||||
* codError 0 - no error, < 0 error
|
||||
|
||||
@@ -63,8 +63,10 @@
|
||||
</script>
|
||||
<script type="text/javascript" src="/lib/js/mafe-{$buildhash}.js"></script>
|
||||
|
||||
|
||||
{/if}
|
||||
<!-- translations -->
|
||||
<script type="text/javascript" src="/translations/translationsMafe.js"></script>
|
||||
|
||||
</head>
|
||||
<body onresize="resizingFrame();">
|
||||
<section class="navBar">
|
||||
|
||||
Reference in New Issue
Block a user