File: D:/HostingSpaces/SBogers10/rooymans.komma-mediadesign.nl/wwwroot/App/Translator/Translator.php
<?php
/**
* Created by PhpStorm.
* User: mike
* Date: 11/11/16
* Time: 09:32
*/
namespace App\Translator;
class Translator
{
/**
* Get translation
*
* @param $path
* @return mixed
*/
static function get($path, $echo = true)
{
// Find location and key
$temp = explode('.',$path);
$location = $temp[0];
$keys = [];
for($i=1;$i<count($temp);$i++)
{
$keys[] = $temp[$i];
}
// Load file (QnD: language hard coded to nl)
$file = $_SERVER['DOCUMENT_ROOT'] . '/lang/nl/' . $location . '.php';
if( ! file_exists($file)) return $path;
$translations = include $file;
// Loop through all keys to find value
$value = $translations;
foreach($keys as $key)
{
$value = $value[$key];
}
if( ! $echo) return $value;
echo $value;
}
}