<?php
namespace Claromentis\Core\Localization;

$GLOBALS["__65da1b1ec2d6653e8a" . "0ab7848e536215"] = (@$GLOBALS["__65da1b1ec2d6653e8a0ab7848e536" . "215"] ?: array()) + array("_53d43bf" . "1f48959b" . "27c566cc" . "3f5b0668" . "1" => base64_decode("UGhyYXNlIC" . "c="), "_7d9ddc77b5329ea478ce5d43e46" . "15f53" => base64_decode("JyBkb2Vzbi" . "d0IGV4aXN0"));
use Claromentis\Core\Localization\Exception\MissingPhraseException;








class MemoryProvider implements LocalizationProviderInterface
{
    
    
    
    
    protected $files_reader;
    
    
    
    
    protected $app_code;
    
    
    
    
    protected $lm = array();
    
    
    
    
    protected $lt_parsed = array();
    
    
    
    
    
    
    
    public function __construct($_d901b83ea3a884001dad5ede20f9b05e, Files $_00f2055c7cbd408ef56949f35c62b721)
    {
        $this->app_code = $_d901b83ea3a884001dad5ede20f9b05e;
        $this->files_reader = $_00f2055c7cbd408ef56949f35c62b721;
    }
    
    
    public function getTranslation(string $key, string $language)
    {
        $this->CheckLoadMessages($language);
        if (!isset($this->lm[$language][$key])) {
            throw new MissingPhraseException($GLOBALS["__65da1b1ec2" . "d6653e8a0ab7" . "848e536215"]["_53d43bf1f48959b27c566" . "cc3f5b06681"] . $key . $GLOBALS["__65da1b1ec2d6653e8a0a" . "b7848e536215"]["_7d9ddc77b5329ea478ce5d" . "43e4615f53"]);
        }
        return $this->lm[$language][$key];
    }
    
    
    public function getTemplaterPhrases(string $language) : array
    {
        $this->CheckLoadTemplaterMessages($language);
        return $this->lt_parsed[$language];
    }
    
    
    
    
    
    
    public function CheckLoadMessages($language)
    {
        if (isset($this->lm[$language])) {
            return;
        }
        $this->lm[$language] = [];
        $this->files_reader->ReadLM($this->lm[$language], $this->app_code, $language);
    }
    
    
    
    
    
    
    protected function CheckLoadTemplaterMessages($language)
    {
        if (isset($this->lt_parsed[$language])) {
            return;
        }
        $this->lt_parsed[$language] = array();
        $this->CheckLoadMessages($language);
        $this->files_reader->ReadLT($this->lm[$language], $this->lt_parsed[$language], $this->app_code, $language);
    }
    
    
    public function hasKey(string $key, string $language) : bool
    {
        $this->CheckLoadMessages($language);
        return isset($this->lm[$language][$key]);
    }
    
    
    
    
    public function getDomain() : string
    {
        return (string) $this->app_code;
    }
    
    
    
    
    
    
    
    public function getDataHash(string $language) : ?string
    {
        return $this->files_reader->GetDataHash($this->app_code, $language);
    }
}