Created
June 20, 2018 07:23
-
-
Save msonowal/1918eec78c69ddeea74035a94ca8cebb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Route::get('/js/lang.js', function () { | |
| Cache::forget('lang.js'); | |
| $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; | |
| }); | |
| $javascript = 'window.i18n = ' . json_encode($strings) . ';'; | |
| return response($javascript, 200, ['Content-Type' => 'text/javascript']); | |
| })->name('assets.lang'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment