* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Loader; use Symfony\Component\Translation\Exception\InvalidResourceException; /** * JsonFileLoader loads translations from an json file. * * @author singles */ class JsonFileLoader extends FileLoader { protected function loadResource(string $resource): array { $messages = []; if ($data = file_get_contents($resource)) { $messages = json_decode($data, true); if (0 < $errorCode = json_last_error()) { throw new InvalidResourceException('Error parsing JSON: '.$this->getJSONErrorMessage($errorCode)); } } return $messages; } /** * Translates JSON_ERROR_* constant into meaningful message. */ private function getJSONErrorMessage(int $errorCode): string { return match ($errorCode) { \JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', \JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', \JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', \JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', \JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', default => 'Unknown error', }; } } __halt_compiler();----SIGNATURE:----IYsvwyloo1qzIAQeDRF88NgohR/rDZl0eaeLWBp+1XiW4iyl9ThVGQRpWV09zg1Jli7LZzN83bzvYUlCu1UG6DoFk5o168q5puN8LVBP04nDF6lW577VWKWulVkM/xkqociCYMiHTZtvoKlgi851fn8F3Pe5/8TkmXcfGBLfV9pj/oESEXy27pcWPgzuhmDXcr/8vt1SOf/NugAGsv8cb1hFnUfnkoyo2qiiqnwR+aZ4KgR5/FglRPEPX23VMT1Qkol1cCQoFwk6hqlbCAUvoetgboK5KCCAft3O0+dx08Y1jTozVmER5s9Ic3MCXKLaDYKyLyySMAx14Z+/I6SYzsM6mpFurDi4e5OeSDGHUGTVmPx1ANiz6SUCSQ9snvfrUHc0zBGIQXyiIhROyZc3RxsSInU46L/IPkU2pT39fpaWxgJh366SOLNfnC4IqmGly15q7kz5/9PzEpQSuBqgaTkxSs52FsS9ZOkvrXyLWApHN4amu0Af5A1atKd+yRdotprILG+5Zx9+vdR464aELEM7nQkOyXDx6rFuquJCxjM69hicCCbqNTuHpu4Zw7zQkuW4t47IAmn9JAHizfugSy6mIQ1mDZZkW4szeavia2L+xofQ8pBgutcgRvd7mbD1rheBCCD2wM00InO4Zev/jkpwpoJVcvZHzQ00cFF8izU=----ATTACHMENT:----MjkzNjI5OTkyMjE1NTgxNiA4MDMyODEzOTY0OTEwNzc5IDM0NDg3MzM0OTk4NDA2NjM=