this bug 6014 was solved, added a way to validate if a file exist
This commit is contained in:
@@ -93,26 +93,36 @@ class Translation extends BaseTranslation {
|
||||
}
|
||||
}
|
||||
|
||||
if( ! is_dir(dirname($cacheFile)) )
|
||||
G::mk_dir(dirname($cacheFile));
|
||||
|
||||
$f = fopen( $cacheFile , 'w+');
|
||||
fwrite( $f , "<?php\n" );
|
||||
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n");
|
||||
fwrite( $f , "?>" );
|
||||
fclose( $f );
|
||||
try {
|
||||
|
||||
if( ! is_dir(dirname($cacheFile)) )
|
||||
G::mk_dir(dirname($cacheFile));
|
||||
|
||||
$json=new Services_JSON();
|
||||
if (!file_exists($cacheFile) || !file_exists($cacheFileJS)){
|
||||
$error = 'translation file does not exist';
|
||||
throw new Exception($error);
|
||||
}
|
||||
$f = fopen( $cacheFile , 'w+');
|
||||
fwrite( $f , "<?php\n" );
|
||||
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n");
|
||||
fwrite( $f , "?>" );
|
||||
fclose( $f );
|
||||
|
||||
$f = fopen( $cacheFileJS , 'w');
|
||||
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n");
|
||||
fclose( $f );
|
||||
$json=new Services_JSON();
|
||||
|
||||
$f = fopen( $cacheFileJS , 'w');
|
||||
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n");
|
||||
fclose( $f );
|
||||
|
||||
$res['cacheFile'] = $cacheFile;
|
||||
$res['cacheFileJS'] = $cacheFileJS;
|
||||
$res['rows'] = count ( $translation );
|
||||
$res['rowsJS'] = count ( $translationJS );
|
||||
return $res;
|
||||
} catch( Exception $e ) {
|
||||
//echo 'Caught exception: ', $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
$res['cacheFile'] = $cacheFile;
|
||||
$res['cacheFileJS'] = $cacheFileJS;
|
||||
$res['rows'] = count ( $translation );
|
||||
$res['rowsJS'] = count ( $translationJS );
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user