2018-11-10 14:24:36 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
|
2019-01-27 00:22:57 +01:00
|
|
|
/**
|
|
|
|
* Class TranslationController
|
|
|
|
* @package App\Http\Controllers
|
|
|
|
*/
|
2019-03-28 22:34:58 +01:00
|
|
|
class TranslationController extends BaseController
|
2018-11-10 14:24:36 +01:00
|
|
|
{
|
2019-03-28 22:34:58 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-11-10 14:24:36 +01:00
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$strings = Cache::rememberForever('lang.js', function () {
|
|
|
|
$lang = config('app.locale');
|
|
|
|
|
|
|
|
$files = glob(resource_path('lang/' . $lang . '/*.php'));
|
|
|
|
$strings = [];
|
|
|
|
|
|
|
|
foreach ($files as $file) {
|
|
|
|
$name = basename($file, '.php');
|
|
|
|
$strings[$name] = require $file;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $strings;
|
|
|
|
});
|
|
|
|
|
|
|
|
header('Content-Type: text/javascript');
|
2019-02-17 11:34:46 +01:00
|
|
|
echo('i18n = ' . $this->easyMinify(json_encode($strings)) . ';');
|
2018-11-10 14:24:36 +01:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
private function easyMinify($javascript){
|
|
|
|
return preg_replace(array("/\s+\n/", "/\n\s+/", "/ +/"), array("\n", "\n ", " "), $javascript);
|
|
|
|
}
|
|
|
|
|
2018-11-10 14:24:36 +01:00
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function create()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function store(Request $request)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function show($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function edit($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request, $id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
|
|
|
* @param int $id
|
|
|
|
* @return \Illuminate\Http\Response
|
|
|
|
*/
|
|
|
|
public function destroy($id)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|