First draft for plugins system

This commit is contained in:
Frederic Guillot
2015-09-13 14:07:56 -04:00
parent c405f99fc8
commit a6a00a0040
31 changed files with 626 additions and 237 deletions

View File

@@ -15,7 +15,7 @@ class Translator
*
* @var string
*/
const PATH = 'app/Locale/';
const PATH = 'app/Locale';
/**
* Locale
@@ -196,18 +196,27 @@ class Translator
* @static
* @access public
* @param string $language Locale code: fr_FR
* @param string $path Locale folder
*/
public static function load($language)
public static function load($language, $path = self::PATH)
{
setlocale(LC_TIME, $language.'.UTF-8', $language);
$filename = self::PATH.$language.DIRECTORY_SEPARATOR.'translations.php';
$filename = $path.DIRECTORY_SEPARATOR.$language.DIRECTORY_SEPARATOR.'translations.php';
if (file_exists($filename)) {
self::$locales = require $filename;
}
else {
self::$locales = array();
self::$locales = array_merge(self::$locales, require($filename));
}
}
/**
* Clear locales stored in memory
*
* @static
* @access public
*/
public static function unload()
{
self::$locales = array();
}
}