bludit/kernel/dblanguage.class.php

35 lines
742 B
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
class dbLanguage extends dbJSON
{
2015-06-26 06:31:53 +02:00
public $en_US;
2015-05-05 03:00:01 +02:00
function __construct($language)
{
2015-06-26 06:31:53 +02:00
parent::__construct(PATH_LANGUAGES.'en_US.json', false);
$this->en_US = $this->db;
2015-05-05 03:00:01 +02:00
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
}
// Return the translation, if the translation does'n exist then return the English translation.
public function get($text)
{
2015-05-31 03:06:55 +02:00
$key = Text::lowercase($text);
$key = Text::replace(' ', '-', $key);
2015-05-05 03:00:01 +02:00
if(isset($this->db[$key]))
return $this->db[$key];
// If the key is not translated then return the English translation.
2015-06-26 06:31:53 +02:00
return $this->en_US[$key];
2015-05-05 03:00:01 +02:00
}
// Print the translation.
public function p($text)
{
echo $this->get($text);
}
2015-05-31 03:06:55 +02:00
}