mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Merge branch 'develop' into pr/new-config-format
Conflicts: classes/context/Context.class.php
This commit is contained in:
commit
5afefc063c
42 changed files with 435 additions and 58 deletions
|
|
@ -197,25 +197,54 @@ class Lang
|
|||
|
||||
// Convert XML to a PHP array.
|
||||
$lang = array();
|
||||
foreach ($xml->item as $item)
|
||||
self::_toArray($xml, $lang, $language);
|
||||
unset($xml);
|
||||
|
||||
// Save the array as a cache file.
|
||||
$buff = "<?php\n";
|
||||
foreach ($lang as $key => $value)
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
foreach ($value as $subkey => $subvalue)
|
||||
{
|
||||
if (is_array($subvalue))
|
||||
{
|
||||
foreach ($subvalue as $subsubkey => $subsubvalue)
|
||||
{
|
||||
$buff .= '$lang->' . $key . "['$subkey']['$subsubkey']" . ' = ' . var_export($subsubvalue, true) . ";\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$buff .= '$lang->' . $key . "['$subkey']" . ' = ' . var_export($subvalue, true) . ";\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$buff .= '$lang->' . $key . ' = ' . var_export($value, true) . ";\n";
|
||||
}
|
||||
}
|
||||
\FileHandler::writeFile($output_filename, $buff);
|
||||
return $output_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* XML to array conversion callback.
|
||||
*
|
||||
* @param array $items
|
||||
* @return void
|
||||
*/
|
||||
protected static function _toArray($items, &$lang, $language)
|
||||
{
|
||||
foreach ($items as $item)
|
||||
{
|
||||
$name = strval($item['name']);
|
||||
if (count($item->item))
|
||||
{
|
||||
$lang[$name] = array();
|
||||
foreach ($item->item as $subitem)
|
||||
{
|
||||
$subname = strval($subitem['name']);
|
||||
foreach ($subitem->value as $value)
|
||||
{
|
||||
$attribs = $value->attributes('xml', true);
|
||||
if (strval($attribs['lang']) === $language)
|
||||
{
|
||||
$lang[$name][$subname] = strval($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
self::_toArray($item->item, $lang[$name], $language);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -230,26 +259,6 @@ class Lang
|
|||
}
|
||||
}
|
||||
}
|
||||
unset($xml);
|
||||
|
||||
// Save the array as a cache file.
|
||||
$buff = "<?php\n";
|
||||
foreach ($lang as $key => $value)
|
||||
{
|
||||
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);
|
||||
return $output_filename;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -304,7 +313,14 @@ class Lang
|
|||
// Search custom translations first.
|
||||
if (isset($this->_loaded_plugins['_custom_']->{$key}))
|
||||
{
|
||||
return $this->_loaded_plugins['_custom_']->{$key};
|
||||
if (is_array($this->_loaded_plugins['_custom_']->{$key}))
|
||||
{
|
||||
return new \ArrayObject($this->_loaded_plugins['_custom_']->{$key}, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_loaded_plugins['_custom_']->{$key};
|
||||
}
|
||||
}
|
||||
|
||||
// Search other plugins.
|
||||
|
|
@ -312,7 +328,14 @@ class Lang
|
|||
{
|
||||
if (isset($this->_loaded_plugins[$plugin_name]->{$key}))
|
||||
{
|
||||
return $this->_loaded_plugins[$plugin_name]->{$key};
|
||||
if (is_array($this->_loaded_plugins[$plugin_name]->{$key}))
|
||||
{
|
||||
return new \ArrayObject($this->_loaded_plugins[$plugin_name]->{$key}, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->_loaded_plugins[$plugin_name]->{$key};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue