You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Languages.php 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace SCF\Core;
  3. class Languages
  4. {
  5. /**
  6. * @var Database
  7. */
  8. private $_db;
  9. /**
  10. * @var
  11. */
  12. private $language;
  13. /**
  14. * @var array
  15. */
  16. private $phrases = [];
  17. /**
  18. * Languages constructor.
  19. * @param Database $db
  20. * @param $langCode
  21. */
  22. public function __construct(Database $db, $langCode)
  23. {
  24. $this->_db = $db;
  25. $this->language = $langCode;
  26. $this->setLanguage();
  27. }
  28. /**
  29. * Create Language Array for the current language
  30. */
  31. private function setLanguage()
  32. {
  33. $this->_db->query("SELECT * FROM system_localization ORDER BY locaId ASC");
  34. $result = $this->_db->fetchArray();
  35. foreach ($result as $lang) {
  36. $this->phrases[$lang['locaVarname']] = $lang['locaString_'.$this->language];
  37. }
  38. }
  39. /**
  40. * @return array
  41. */
  42. public function postArray()
  43. {
  44. return $this->phrases;
  45. }
  46. /**
  47. * @param $phraseName
  48. * @return mixed
  49. */
  50. public function getPhrase($phraseName)
  51. {
  52. if (isset($this->phrases[$phraseName])) {
  53. return $this->phrases[$phraseName];
  54. } else {
  55. return $phraseName;
  56. }
  57. }
  58. }