diff --git a/workflow/engine/classes/model/Translation.php b/workflow/engine/classes/model/Translation.php index 49a08ea41..36002fdbe 100644 --- a/workflow/engine/classes/model/Translation.php +++ b/workflow/engine/classes/model/Translation.php @@ -93,26 +93,36 @@ class Translation extends BaseTranslation { } } - if( ! is_dir(dirname($cacheFile)) ) - G::mk_dir(dirname($cacheFile)); - - $f = fopen( $cacheFile , 'w+'); - 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 , "" ); + 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; } /**