I would like to achieve localization in laravel https://laravel.com/docs/5.8/localization
I would want to allow a user to set up a .json file and upload the key value translations.
To achieve this, I need to create a directory on resources/lang/' . $request->language
that is $path = base_path('resources/lang/' . $request->language . '/');
then a json file $request->language. '.json'
I tried this
File::makeDirectory(base_path()."'resources/lang/' . $request->language . '/'", $mode = 0777, true, true);
Then
//Write File
$newJsonString = json_encode($request->translation, JSON_PRETTY_PRINT);
file_put_contents(base_path($path . $request->language. '.json'), stripslashes($newJsonString));
For some reasons, it does not create even the directory. Could I be missing something?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire