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