SimpleSAML\Locale\Translate::readDictionaryJSON PHP Method

readDictionaryJSON() private method

Read a dictionary file in JSON format.
private readDictionaryJSON ( string $filename ) : array
$filename string The absolute path to the dictionary file, minus the .definition.json ending.
return array An array holding all the translations in the file.
    private function readDictionaryJSON($filename)
    {
        $definitionFile = $filename . '.definition.json';
        assert('file_exists($definitionFile)');
        $fileContent = file_get_contents($definitionFile);
        $lang = json_decode($fileContent, true);
        if (empty($lang)) {
            \SimpleSAML\Logger::error('Invalid dictionary definition file [' . $definitionFile . ']');
            return array();
        }
        $translationFile = $filename . '.translation.json';
        if (file_exists($translationFile)) {
            $fileContent = file_get_contents($translationFile);
            $moreTrans = json_decode($fileContent, true);
            if (!empty($moreTrans)) {
                $lang = array_merge_recursive($lang, $moreTrans);
            }
        }
        return $lang;
    }