Fixes for new l10n
This commit is contained in:
parent
c65193aa42
commit
fddf121032
|
@ -25,8 +25,10 @@ class Plugin {
|
|||
// (dbLanguage) Plugin's localisation.
|
||||
public $language;
|
||||
|
||||
function __construct($locale)
|
||||
function __construct()
|
||||
{
|
||||
global $Site;
|
||||
|
||||
$this->dbFields = array();
|
||||
|
||||
$reflector = new ReflectionClass(get_class($this));
|
||||
|
@ -43,9 +45,15 @@ class Plugin {
|
|||
// Init empty database
|
||||
$this->db = $this->dbFields;
|
||||
|
||||
// Load localisation
|
||||
$tmp = new dbLanguage($locale, PATH_PLUGINS.$this->directoryName.DS.'languages'.DS);
|
||||
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php';
|
||||
|
||||
// --- Metadata ---
|
||||
$this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json';
|
||||
$metadataString = file_get_contents($this->filenameMetadata);
|
||||
$this->metadata = json_decode($metadataString, true);
|
||||
|
||||
// Load localisation
|
||||
$tmp = new dbLanguage($Site->locale(), PATH_PLUGINS.$this->directoryName.DS.'languages'.DS);
|
||||
// Set name and description from the language file.
|
||||
$this->setMetadata('name',$tmp->db['plugin-data']['name']);
|
||||
$this->setMetadata('description',$tmp->db['plugin-data']['description']);
|
||||
|
@ -54,13 +62,6 @@ class Plugin {
|
|||
unset($tmp->db['plugin-data']);
|
||||
$this->language = $tmp;
|
||||
|
||||
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php';
|
||||
|
||||
// --- Metadata ---
|
||||
$this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json';
|
||||
$metadataString = file_get_contents($this->filenameMetadata);
|
||||
$this->metadata = json_decode($metadataString, true);
|
||||
|
||||
// If the plugin is installed then get the database.
|
||||
if($this->installed())
|
||||
{
|
||||
|
|
|
@ -75,7 +75,7 @@ function buildPlugins()
|
|||
|
||||
foreach($pluginsDeclaredClasess as $pluginClass)
|
||||
{
|
||||
$Plugin = new $pluginClass($Site->locale());
|
||||
$Plugin = new $pluginClass();
|
||||
|
||||
// Deprecated
|
||||
// // Check if the plugin is translated.
|
||||
|
|
|
@ -6,22 +6,24 @@ class dbLanguage extends dbJSON
|
|||
public $db;
|
||||
public $currentLocale;
|
||||
|
||||
function __construct($locale)
|
||||
function __construct( $locale, $path = null )
|
||||
{
|
||||
$path = $path ? $path : PATH_LANGUAGES;
|
||||
|
||||
$this->data = array();
|
||||
$this->db = array();
|
||||
$this->currentLocale = 'en_US';
|
||||
|
||||
// Default language en_US
|
||||
$filename = PATH_LANGUAGES.'en_US.json';
|
||||
$filename = $path.'en_US.json';
|
||||
if( Sanitize::pathFile($filename) )
|
||||
{
|
||||
$Tmp = new dbJSON($filename, false);
|
||||
$this->db = array_merge($this->db, $Tmp->db);
|
||||
$this->db = $Tmp->db;
|
||||
}
|
||||
|
||||
// User language
|
||||
$filename = PATH_LANGUAGES.$locale.'.json';
|
||||
$filename = $path.$locale.'.json';
|
||||
if( Sanitize::pathFile($filename) && ($locale!=="en_US") )
|
||||
{
|
||||
$this->currentLocale = $locale;
|
||||
|
@ -29,9 +31,12 @@ class dbLanguage extends dbJSON
|
|||
$this->db = array_merge($this->db, $Tmp->db);
|
||||
}
|
||||
|
||||
if ( $this->data )
|
||||
{
|
||||
$this->data = $this->db['language-data'];
|
||||
unset($this->db['language-data']);
|
||||
}
|
||||
}
|
||||
|
||||
public function getCurrentLocale()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue