use wcf\system\cache\builder\LanguageCacheBuilder;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\SystemException;
-use wcf\system\io\File;
+use wcf\system\io\AtomicWriter;
use wcf\system\language\LanguageFactory;
use wcf\system\Regex;
use wcf\system\WCF;
continue;
}
- $content = "<?php\n/**\n* WoltLab Community Framework\n* language: ".$this->languageCode."\n* encoding: UTF-8\n* category: ".$category->languageCategory."\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n";
+ $filename = WCF_DIR.'language/'.$this->languageID.'_'.$category->languageCategory.'.php';
+ $writer = new AtomicWriter($filename);
+
+ $writer->write("<?php\n/**\n* WoltLab Community Framework\n* language: ".$this->languageCode."\n* encoding: UTF-8\n* category: ".$category->languageCategory."\n* generated at ".gmdate("r")."\n* \n* DO NOT EDIT THIS FILE\n*/\n");
foreach ($languageItems as $languageItem => $languageItemValue) {
- $content .= "\$this->items['".$languageItem."'] = '".str_replace("'", "\'", $languageItemValue)."';\n";
+ $writer->write("\$this->items['".$languageItem."'] = '".str_replace("'", "\'", $languageItemValue)."';\n");
// compile dynamic language variables
if ($category->languageCategory != 'wcf.global' && strpos($languageItemValue, '{') !== false) {
+ $writer->write("\$this->dynamicItems['".$languageItem."'] = '");
+
$output = LanguageFactory::getInstance()->getScriptingCompiler()->compileString($languageItem, $languageItemValue);
- $content .= "\$this->dynamicItems['".$languageItem."'] = '".str_replace("'", "\'", $output['template'])."';\n";
+ $writer->write(str_replace("'", "\'", $output['template']));
+
+ $writer->write("';\n");
}
}
- $filename = WCF_DIR.'language/'.$this->languageID.'_'.$category->languageCategory.'.php';
- $file = new File($filename);
+ $writer->flush();
+ $writer->close();
FileUtil::makeWritable($filename);
- $file->write($content . '?>');
- $file->close();
}
}