File: /var/www/vhosts/creativefellows.nl/recht.creativefellows.nl/src/Domain/Language/LanguageData.php
<?php
namespace App\Domain\Language;
use App\Domain\Language\LocalizationLanguage;
class LanguageData{
function __construct($settings,$root=null)
{
$this->current = $settings["selected_language"];
$this->all = $settings["available_languages"];
$this->labels = $settings["language_labels"];
$this->root = $root;
$this->id = array_key_first($this->all);
}
public function current()
{
return $this->current;
}
public function currentUrl()
{
return $this->current ? $this->current."/" : "";
}
public function localeClass(){
$locale = substr($this->current,1,2);
return $locale != "en" ? $locale : "";
}
public function id()
{
return $this->id;
}
public function all()
{
return $this->all;
}
public function locale()
{
return substr($this->current(),1,2);
}
public function label($index)
{
return $this->labels[$index];
}
public function href($index)
{
$language = $this->all[$index];
return $language != "en" ? $language : "";
}
public function languageBase()
{
return "/" . $this->current;// != "" ? "/".$this->current : "";
}
public function setLanguage($language)
{
$this->current = $language;
$this->id = array_search ($language, $this->all());
}
public function isLocalized()
{
return $this->current !== null ? true : false;
}
public function localizedLanguageData()
{
//d($this->labels);
$settings = require $this->root . '/config/'. $this->labels[$this->id];
return new LocalizationLanguage($settings);
}
}