/**
  * Display the grid's containing page.
  * @param $args array
  * @param $request PKPRequest
  */
 function save($args, $request)
 {
     $filename = $this->_getFilename($request);
     $notificationManager = new NotificationManager();
     $user = $request->getUser();
     if (!file_exists($filename)) {
         $dir = dirname($filename);
         if (!file_exists($dir)) {
             mkdir($dir);
         }
         $localeList = PKPLocale::getAllLocales();
         file_put_contents($filename, strtr(file_get_contents(self::$plugin->getRegistryPath() . '/locale.xml'), array('{$locale}' => $this->locale, '{$localeName}' => $localeList[$this->locale])));
     }
     // Use the EditableLocaleFile class to handle changes.
     import('lib.pkp.classes.file.EditableLocaleFile');
     $this->file = new EditableLocaleFile($this->locale, $filename);
     // Delegate processing to the listbuilder handler. This will invoke the callbacks below.
     self::$plugin->import('controllers.listbuilder.LocaleFileListbuilderHandler');
     if (LocaleFileListbuilderHandler::unpack($request, $request->getUserVar('localeKeys'))) {
         if ($this->file->write()) {
             $notificationManager->createTrivialNotification($user->getId());
         } else {
             // Could not write the file
             $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.couldNotWriteFile', array('filename' => $filename))));
         }
     } else {
         // Some kind of error occurred (probably garbled formatting)
         $notificationManager->createTrivialNotification($user->getId(), NOTIFICATION_TYPE_ERROR, array('contents' => __('plugins.generic.translator.errorEditingFile', array('filename' => $filename))));
     }
     $message = new JSONMessage(true);
     return $message->getString();
 }
 /**
  * Set the translator plugin.
  * @param $plugin StaticPagesPlugin
  */
 static function setPlugin($plugin)
 {
     self::$plugin = $plugin;
 }