#!/usr/bin/php ]*)>)([^(<\/nls:)]*)(<\/nls:\\2>)/m'; // $preg = '/(]*)>)(.*)(<\/nls:\\2>)/m'; //$preg = '/(]*)>)([^(\/nls)]+)(<\/nls:\\2>)/m'; $preg = '#(]*)>)(.*)()#msU'; while( ( $file = $dh->read() ) !== false ) { if( $file[0] == '.' ) { continue; } if( is_dir( $tmplDir . '/' . $file ) ) { continue; } $basename = basename( $file, '.nls.tmpl' ); // wrong file format if( $basename == $file ) { continue; } echo "nlsTemplate: $file \n"; $tmplNls = $basename . '.nls.tmpl'; $tmplPot = $basename . '.nls.pot'; $phpNls = $basename . '.nls.php'; $tmpl = $basename . '.tmpl'; $html = file_get_contents( $tmplDir . '/' . $tmplNls ); if( !preg_match_all( $preg, $html, $match, PREG_SET_ORDER ) ) { // nothing to replace // wbDebugger::printMsg(); echo "not found ?\n"; // exit; continue; } $tmplVarFormat = str_replace( '/', '_', $basename ) . '_%04d'; $tmplReplace = array( 'pattern' => array(), 'placeholder' => array(), 'text' => array() ); $phpCode = array(); array_push( $phpCode, '' ); $phpCode = implode( "\n", $phpCode ); $phpFh = fopen( $tmplDir . '/' . $phpNls, 'w' ); if( !$phpFh ) { wbDebugger::printMsg(); echo "Could not open " . $phpNls . "for writing\n"; exit; } fwrite( $phpFh, $phpCode ); fclose( $phpFh ); $html = str_replace( $tmplReplace['pattern'], $tmplReplace['placeholder'], $html ); // write translatable template $tmplFh = fopen( $tmplDir . '/' . $tmplPot, 'w' ); if( !$tmplFh ) { wbDebugger::printMsg(); echo "Could not open " . $tmplPot . "for writing\n"; exit; } fwrite( $tmplFh, $html ); fclose( $tmplFh ); // write translated template for C $html = str_replace( $tmplReplace['placeholder'], $tmplReplace['text'], $html ); $tmplFh = fopen( $tmplDir . '/' . $tmpl, 'w' ); if( !$tmplFh ) { wbDebugger::printMsg(); echo "Could not open " . $tmpl . "for writing\n"; exit; } fwrite( $tmplFh, $html ); fclose( $tmplFh ); } exit; wbDebugger::printMsg(); ?>