Simplify loading function for supported language list

This commit is contained in:
Kijin Sung 2016-01-31 14:47:01 +09:00
parent a39e0b0993
commit f45779c3f8
4 changed files with 39 additions and 15 deletions

21
common/defaults/lang.php Normal file
View file

@ -0,0 +1,21 @@
<?php
/**
* List of languages supported by RhymiX
*
* Copyright (c) Rhymix Developers and Contributors
*/
return array(
'ko' => '한국어',
'en' => 'English',
'ja' => '日本語',
'zh-CN' => '中文(中国)',
'zh-TW' => '中文(臺灣)',
'de' => 'Deutsch',
'es' => 'Español',
'fr' => 'Français',
'mn' => 'Mongolian',
'ru' => 'Русский',
'tr' => 'Türkçe',
'vi' => 'Tiếng Việt',
);

View file

@ -45,7 +45,7 @@ class Lang
*/
protected function __construct($language)
{
$this->_language = strtolower(preg_replace('/[^a-z0-9_-]/i', '', $language));
$this->_language = preg_replace('/[^a-z0-9_-]/i', '', $language);
}
/**
@ -154,7 +154,7 @@ class Lang
foreach ($subitem->value as $value)
{
$attribs = $value->attributes('xml', true);
if (strtolower($attribs['lang']) === $language)
if (strval($attribs['lang']) === $language)
{
$lang[$name][$subname] = strval($value);
break;
@ -167,7 +167,7 @@ class Lang
foreach ($item->value as $value)
{
$attribs = $value->attributes('xml', true);
if (strtolower($attribs['lang']) === $language)
if (strval($attribs['lang']) === $language)
{
$lang[$name] = strval($value);
break;
@ -187,6 +187,16 @@ class Lang
return $cache_filename;
}
/**
* Get the list of supported languages.
*
* @return array
*/
public function getSupportedList()
{
return (include RX_BASEDIR . 'common/defaults/lang.php');
}
/**
* Magic method for translations with arguments.
*