%PDF- %PDF-
| Direktori : /www/loslex/demo/vendor/amirami/localizator/src/Services/Collectors/ |
| Current File : /www/loslex/demo/vendor/amirami/localizator/src/Services/Collectors/JsonKeyCollector.php |
<?php
namespace Amirami\Localizator\Services\Collectors;
use Amirami\Localizator\Collections\JsonKeyCollection;
use Amirami\Localizator\Contracts\Collectable;
use Illuminate\Support\Collection;
class JsonKeyCollector implements Collectable
{
/**
* @param string $locale
* @return Collection
*/
public function getTranslated(string $locale): Collection
{
$file = lang_path("{$locale}.json");
if (! file_exists($file)) {
return new JsonKeyCollection;
}
return new JsonKeyCollection(
json_decode(file_get_contents($file), true)
);
}
}