mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-22 05:15:29 +09:00
Add option to specify the output filename when converting languages
This commit is contained in:
parent
2a008eb2e2
commit
1eba1a6f12
1 changed files with 10 additions and 7 deletions
|
|
@ -123,20 +123,23 @@ class Lang
|
||||||
* @param string $language
|
* @param string $language
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function compileXMLtoPHP($filename, $language)
|
public function compileXMLtoPHP($filename, $language, $output_filename = null)
|
||||||
{
|
{
|
||||||
// Check if the cache file already exists.
|
// Check if the cache file already exists.
|
||||||
$cache_filename = RX_BASEDIR . 'files/cache/lang/' . md5($filename) . '.' . $language . '.php';
|
if ($output_filename === null)
|
||||||
if (file_exists($cache_filename) && filemtime($cache_filename) > filemtime($filename))
|
|
||||||
{
|
{
|
||||||
return $cache_filename;
|
$output_filename = RX_BASEDIR . 'files/cache/lang/' . md5($filename) . '.' . $language . '.php';
|
||||||
|
if (file_exists($output_filename) && filemtime($output_filename) > filemtime($filename))
|
||||||
|
{
|
||||||
|
return $output_filename;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the XML lang file.
|
// Load the XML lang file.
|
||||||
$xml = @simplexml_load_file($filename);
|
$xml = @simplexml_load_file($filename);
|
||||||
if ($xml === false)
|
if ($xml === false)
|
||||||
{
|
{
|
||||||
\FileHandler::writeFile($cache_filename, '');
|
\FileHandler::writeFile($output_filename, '');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -183,8 +186,8 @@ class Lang
|
||||||
{
|
{
|
||||||
$buff .= '$lang->' . $key . ' = ' . var_export($value, true) . ";\n";
|
$buff .= '$lang->' . $key . ' = ' . var_export($value, true) . ";\n";
|
||||||
}
|
}
|
||||||
\FileHandler::writeFile($cache_filename, $buff);
|
\FileHandler::writeFile($output_filename, $buff);
|
||||||
return $cache_filename;
|
return $output_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue