<?php

namespace languages;

class languages
{
    public $lang = '';
    public static $msgs = [];
    public static $pattern_admin = [];
    public static $pattern = [];
    public $setData = false;

    public function __construct()
    {
        if ($this->setData) {
            return $this;
        }
        if (!empty(DF_LANG)) {
            $this->lang = DF_LANG;
        }
        if (isset($GLOBALS['lang']) and !empty($GLOBALS['lang'])) {
            $this->lang = $GLOBALS['lang'];
        }
        $this->SetArray();
    }

    private function SetArray()
    {
        $file = json_decode(file_get_contents(__DIR__ . '/' . $this->lang . '.json'), true);
        self::$msgs = $file['msg'];
        self::$pattern_admin = $file['pattern_admin'];
        self::$pattern = $file['pattern'];
        $this->setData = true;
    }


}
