HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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;
    }
}