/**
  * Validate the logical structure of a lang file.
  * This function checks if a lang file exists, the file has a 
  * header, and each lang-entry consists of exactly three elements
  * (module, identifier, value).
  *
  * @return	string	system message
  * @param   string  $scope  empty (global) or "local"
  */
 function check($scope = '')
 {
     include_once "./Services/Utilities/classes/class.ilStr.php";
     if (!empty($scope)) {
         if ($scope == 'global') {
             $scope = '';
         } else {
             $scopeExtension = '.' . $scope;
         }
     }
     $path = $this->lang_path;
     if ($scope == "local") {
         $path = $this->cust_lang_path;
     }
     $tmpPath = getcwd();
     // dir check
     if (!is_dir($path)) {
         $this->ilias->raiseError("Directory not found: " . $path, $this->ilias->error_obj->MESSAGE);
     }
     chdir($path);
     // compute lang-file name format
     $lang_file = "ilias_" . $this->key . ".lang" . $scopeExtension;
     // file check
     if (!is_file($lang_file)) {
         $this->ilias->raiseError("File not found: " . $lang_file, $this->ilias->error_obj->MESSAGE);
     }
     // header check
     if (!($content = $this->cut_header(file($lang_file)))) {
         $this->ilias->raiseError("Wrong Header in " . $lang_file, $this->ilias->error_obj->MESSAGE);
     }
     // check (counting) elements of each lang-entry
     $line = 0;
     foreach ($content as $key => $val) {
         $separated = explode($this->separator, trim($val));
         $num = count($separated);
         ++$n;
         if ($num != 3) {
             $line = $n + 36;
             $this->ilias->raiseError("Wrong parameter count in " . $lang_file . " in line {$line} (Value: {$val})! Please check your language file!", $this->ilias->error_obj->MESSAGE);
         }
         if (!ilStr::isUtf8($separated[2])) {
             $this->ilias->raiseError("Non UTF8 character found in " . $lang_file . " in line {$line} (Value: {$val})! Please check your language file!", $this->ilias->error_obj->MESSAGE);
         }
     }
     chdir($tmpPath);
     // no error occured
     return true;
 }