/** * Used in actionCheckLanguage. Parse the file, putting its language fields * into $contentArr. * @param String $filePath The full path to the file. * @param Array &$contentArr The array to put the language fields in. * @return string Output string, possibly containing warnings for the user. */ private function _langFieldsToArray($filePath, &$contentArr) { $outputString = ''; $langFile = new \GO\Base\Fs\File($filePath); if (!file_exists($langFile->path())) { $outputString .= '<i><font color="red">File not found: "' . $langFile->path() . '"</font></i><br />'; } else { $this->_replaceBOM($filePath); $encodingName = $langFile->detectEncoding($langFile->getContents()); if ($encodingName == 'UTF-8' || $encodingName == 'ASCII' || $langFile->convertToUtf8()) { $lines = file($langFile->path()); if (count($lines)) { foreach ($lines as $line) { $first_equal = strpos($line, '='); if ($first_equal != 0) { $key = str_replace('"', '\'', trim(substr($line, 0, $first_equal))); $contentArr[$key] = trim(substr($line, $first_equal, strlen($line) - 1)); } } } else { $outputString .= '<i><font color="red">Could not compare ' . str_replace(\GO::config()->root_path, '', $langFile->path()) . ', because it has no translation contents!</font></i><br />'; } } else { $outputString .= '<i><font color="red">Could not compare with ' . str_replace(\GO::config()->root_path, '', $langFile->path()) . ', because it cannot be made UTF-8!</font></i><br />'; } //for displaying errors include $filePath; } return $outputString; }