/**
  * Add a file to the current import buffer.
  *
  * @param string $filePath The path to the file
  * @param string $fileName Optional, the filename to parse to extract resources data
  *
  * @return array
  *
  * @throws ImportException
  */
 protected function importFile($filePath, $fileName = null)
 {
     // Filename parsing
     if ($fileName == null) {
         $fileName = basename($filePath);
     }
     if (!preg_match('/\\w+\\.\\w+\\.\\w+/', $fileName)) {
         throw new ImportException("Invalid filename [{$fileName}], all translation files must be named: domain.locale.format (ex: messages.en.yml)");
     }
     list($domain, $locale, $format) = explode('.', $fileName, 3);
     $catalogue = $this->translator->loadResource(array('format' => $format, 'locale' => $locale, 'domain' => $domain, 'path' => $filePath));
     // Merge with existing entries
     $translations = $this->getTranslationsFromSession();
     $counters = array('new' => 0, 'updated' => 0);
     if (!array_key_exists($locale, $translations)) {
         $translations[$locale] = array('new' => array(), 'updated' => array());
     }
     foreach ($catalogue->all() as $domain => $messages) {
         foreach ($messages as $key => $value) {
             if ($trans = $this->repository->findTranslation($domain, $key, $locale, true)) {
                 if ($trans->getValue() !== $value) {
                     $translations[$locale]['updated'][$domain][$key] = array('old' => $trans->getValue(), 'new' => $value);
                     $counters['updated'] += 1;
                 }
             } else {
                 $translations[$locale]['new'][$domain][$key] = $value;
                 $counters['new'] += 1;
             }
         }
     }
     $this->updateSession($translations);
     return $counters;
 }