mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 21:29:58 +09:00
Add batch converter for language files
This commit is contained in:
parent
fe121a0f18
commit
8b1160c320
1 changed files with 28 additions and 0 deletions
|
|
@ -116,6 +116,34 @@ class Lang
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a directory of old language files to the RhymiX format.
|
||||
*
|
||||
* @param string $dir
|
||||
* @param array $xml_langs When converting XML to PHP, only convert these languages. (Optional)
|
||||
* @return void
|
||||
*/
|
||||
public static function convertDirectory($dir, $xml_langs = array())
|
||||
{
|
||||
if (file_exists("$dir/lang.xml"))
|
||||
{
|
||||
$langs = count($xml_langs) ? $xml_langs : array_keys(self::getSupportedList());
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
self::compileXMLtoPHP("$dir/lang.xml", $lang === 'ja' ? 'jp' : $lang, "$dir/$lang.php");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$files = glob($dir . '/*.lang.php');
|
||||
foreach ($files as $filename)
|
||||
{
|
||||
$new_filename = preg_replace('/\.lang\.php$/', '.php', str_replace('jp.lang', 'ja.lang', $filename));
|
||||
\FileHandler::rename($filename, $new_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile XE-compatible XML lang files into PHP.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue