mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-11 23:01:41 +09:00
Improve array handling in lang parser
This commit is contained in:
parent
1eba1a6f12
commit
fe121a0f18
1 changed files with 15 additions and 5 deletions
|
|
@ -104,7 +104,7 @@ class Lang
|
||||||
{
|
{
|
||||||
$this->_loaded_directories[] = $dir;
|
$this->_loaded_directories[] = $dir;
|
||||||
$this->_loaded_files[] = $filename;
|
$this->_loaded_files[] = $filename;
|
||||||
$compiled_filename = $this->compileXMLtoPHP($filename, $this->_language === 'ja' ? 'jp' : $this->_language);
|
$compiled_filename = self::compileXMLtoPHP($filename, $this->_language === 'ja' ? 'jp' : $this->_language);
|
||||||
if ($compiled_filename !== false)
|
if ($compiled_filename !== false)
|
||||||
{
|
{
|
||||||
include $compiled_filename;
|
include $compiled_filename;
|
||||||
|
|
@ -123,7 +123,7 @@ class Lang
|
||||||
* @param string $language
|
* @param string $language
|
||||||
* @return string|false
|
* @return string|false
|
||||||
*/
|
*/
|
||||||
public function compileXMLtoPHP($filename, $language, $output_filename = null)
|
public static function compileXMLtoPHP($filename, $language, $output_filename = null)
|
||||||
{
|
{
|
||||||
// Check if the cache file already exists.
|
// Check if the cache file already exists.
|
||||||
if ($output_filename === null)
|
if ($output_filename === null)
|
||||||
|
|
@ -148,7 +148,7 @@ class Lang
|
||||||
foreach ($xml->item as $item)
|
foreach ($xml->item as $item)
|
||||||
{
|
{
|
||||||
$name = strval($item['name']);
|
$name = strval($item['name']);
|
||||||
if (strval($item['type']) === 'array')
|
if (count($item->item))
|
||||||
{
|
{
|
||||||
$lang[$name] = array();
|
$lang[$name] = array();
|
||||||
foreach ($item->item as $subitem)
|
foreach ($item->item as $subitem)
|
||||||
|
|
@ -184,7 +184,17 @@ class Lang
|
||||||
$buff = "<?php\n";
|
$buff = "<?php\n";
|
||||||
foreach ($lang as $key => $value)
|
foreach ($lang as $key => $value)
|
||||||
{
|
{
|
||||||
$buff .= '$lang->' . $key . ' = ' . var_export($value, true) . ";\n";
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
foreach ($value as $subkey => $subvalue)
|
||||||
|
{
|
||||||
|
$buff .= '$lang->' . $key . "['" . $subkey . "']" . ' = ' . var_export($subvalue, true) . ";\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$buff .= '$lang->' . $key . ' = ' . var_export($value, true) . ";\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
\FileHandler::writeFile($output_filename, $buff);
|
\FileHandler::writeFile($output_filename, $buff);
|
||||||
return $output_filename;
|
return $output_filename;
|
||||||
|
|
@ -195,7 +205,7 @@ class Lang
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getSupportedList()
|
public static function getSupportedList()
|
||||||
{
|
{
|
||||||
return (include RX_BASEDIR . 'common/defaults/lang.php');
|
return (include RX_BASEDIR . 'common/defaults/lang.php');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue