src/wcmf/lib/util/I18nUtil.php
public static function createPHPLanguageFile($language, $messages) {
    $fileUtil = new FileUtil();

    // get locale directory
    $config = ObjectFactory::getInstance('configuration');
    $localeDir = $config->getDirectoryValue('localeDir', 'application');
    $fileUtil->mkdirRec($localeDir);
    $file = $localeDir.'messages_'.$language.'.php';

    // backup old file
    if (file_exists($file)) {
      rename($file, $file.".bak");
    }
    $fh = fopen($file, "w");

    // write header
    $header = <<<EOT
<?php
\$messages_{$language} = [];
\$messages_{$language}[''] = '';
EOT;
    fwrite($fh, $header."\n");

    // write messages
    foreach($messages as $message => $attributes) {
      $lines = '// file(s): '.$attributes['files']."\n";
      $lines .= "\$messages_".$language."['".str_replace("'", "\'", $message)."'] = '".str_replace("'", "\'", $attributes['translation'])."';"."\n";
      fwrite($fh, $lines);
    }

    // write footer
    $footer = <<<EOT
?>
EOT;
    fwrite($fh, $footer."\n");

    fclose($fh);
  }
public static function createPHPLanguageFile($language, $messages) {
    $fileUtil = new FileUtil();

    // get locale directory
    $config = ObjectFactory::getInstance('configuration');
    $localeDir = $config->getDirectoryValue('localeDir', 'application');
    $fileUtil->mkdirRec($localeDir);
    $file = $localeDir.'messages_'.$language.'.php';

    // backup old file
    if (file_exists($file)) {
      rename($file, $file.".bak");
    }
    $fh = fopen($file, "w");

    // write header
    $header = <<<EOT
<?php
\$messages_{$language} = [];
\$messages_{$language}[''] = '';
EOT;
    fwrite($fh, $header."\n");

    // write messages
    foreach($messages as $message => $attributes) {
      $lines = '// file(s): '.$attributes['files']."\n";
      $lines .= "\$messages_".$language."['".str_replace("'", "\'", $message)."'] = '".str_replace("'", "\'", $attributes['translation'])."';"."\n";
      fwrite($fh, $lines);
    }

    // write footer
    $footer = <<<EOT
?>
EOT;
    fwrite($fh, $footer."\n");

    fclose($fh);
  }
public static function createPHPLanguageFile ( $ language , $ messages ) { $ fileUtil = new FileUtil ( ) ; // get locale directory $ config = ObjectFactory :: getInstance ( 'configuration' ) ; $ localeDir = $ config -> getDirectoryValue ( 'localeDir' , 'application' ) ; $ fileUtil -> mkdirRec ( $ localeDir ) ; $ file = $ localeDir . 'messages_' . $ language . '.php' ; // backup old file if ( file_exists ( $ file ) ) { rename ( $ file , $ file . ".bak" ) ; } $ fh = fopen ( $ file , "w" ) ; // write header $ header =  <<<EOT
<?php
\$messages_{$language} = [];
\$messages_{$language}[''] = '';
EOT ; fwrite ( $ fh , $ header . "\n" ) ; // write messages foreach ( $ messages as $ message => $ attributes ) { $ lines = '// file(s): ' . $ attributes [ 'files' ] . "\n" ; $ lines .= "\$messages_" . $ language . "['" . str_replace ( "'" , "\'" , $ message ) . "'] = '" . str_replace ( "'" , "\'" , $ attributes [ 'translation' ] ) . "';" . "\n" ; fwrite ( $ fh , $ lines ) ; } // write footer $ footer =  <<<EOT
?>
EOT ; fwrite ( $ fh , $ footer . "\n" ) ; fclose ( $ fh ) ; }
Create a message file for use with the Message class. The file will
be created in the directory defined in configutation key 'localeDir' in
'application' section.
@param $language The language of the file (language code e.g. 'de')
@param $messages An assoziative array with the messages as keys
and assoziative array with keys 'translation' and 'files' (occurences of the message)
@return Boolean whether successful or not.
Create a message file for use with the Message class . The file will be created in the directory defined in configutation key localeDir in application section .