vq2-system_library_language.php (1621B)
1 <?php 2 /** 3 * @package OpenCart 4 * @author Daniel Kerr 5 * @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/) 6 * @license https://opensource.org/licenses/GPL-3.0 7 * @link https://www.opencart.com 8 */ 9 10 /** 11 * Language class 12 */ 13 class Language { 14 private $default = 'en-gb'; 15 private $directory; 16 public $data = array(); 17 18 /** 19 * Constructor 20 * 21 * @param string $file 22 * 23 */ 24 public function __construct($directory = '') { 25 $this->directory = $directory; 26 } 27 28 /** 29 * 30 * 31 * @param string $key 32 * 33 * @return string 34 */ 35 public function get($key) { 36 return (isset($this->data[$key]) ? $this->data[$key] : $key); 37 } 38 39 public function set($key, $value) { 40 $this->data[$key] = $value; 41 } 42 43 /** 44 * 45 * 46 * @return array 47 */ 48 public function all() { 49 return $this->data; 50 } 51 52 /** 53 * 54 * 55 * @param string $filename 56 * @param string $key 57 * 58 * @return array 59 */ 60 public function load($filename, $key = '') { 61 if (!$key) { 62 $_ = array(); 63 64 $file = DIR_LANGUAGE . $this->default . '/' . $filename . '.php'; 65 66 if (is_file($file)) { 67 require(\VQMod::modCheck($file)); 68 } 69 70 $file = DIR_LANGUAGE . $this->directory . '/' . $filename . '.php'; 71 72 if (is_file($file)) { 73 require(\VQMod::modCheck($file)); 74 } 75 76 $this->data = array_merge($this->data, $_); 77 } else { 78 // Put the language into a sub key 79 $this->data[$key] = new Language($this->directory); 80 $this->data[$key]->load($filename); 81 } 82 83 return $this->data; 84 } 85 }