Skip to content

Instantly share code, notes, and snippets.

@matrunchyk
Created March 1, 2017 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matrunchyk/e18eb943d2caac65b8920685363a5f1a to your computer and use it in GitHub Desktop.
Save matrunchyk/e18eb943d2caac65b8920685363a5f1a to your computer and use it in GitHub Desktop.
Route::get('/js/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;
}
header('Content-Type: text/javascript');
echo('window.i18n = ' . json_encode($strings) . ';');
exit();
})->name('assets.lang');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment