/**
  * @depends testImportOneMessageNew
  */
 public function testImportOneMessageUpdated()
 {
     ZurmoMessageSourceUtil::importOneMessage(self::$testLanguageCode, self::$testCategory, self::$testMessageSource, self::$testMessageUpdatedTranslation);
     ZurmoMessageSource::clearCache(self::$testCategory, self::$testLanguageCode);
     $messageSource = new ZurmoMessageSource();
     $translation = $messageSource->translate(self::$testCategory, self::$testMessageSource, self::$testLanguageCode);
     $this->assertEquals($translation, self::$testMessageUpdatedTranslation);
 }
Exemplo n.º 2
0
 /**
  * Loads all messages with context from PO file and imports them to the database
  *
  * @param String $languageCode The language code
  * @param String $messageFile Path to the PO file to import.
  * @return Boolean Status of the import
  * @throws NotSupportedException
  */
 public static function importPoFile($languageCode, $messageFile)
 {
     assert('is_string($languageCode) && !empty($languageCode)');
     if (!is_string($languageCode) || empty($languageCode)) {
         throw new NotSupportedException();
     }
     $file = new ZurmoGettextPoFile($messageFile);
     $messages = $file->read();
     $categories = array();
     foreach ($messages as $message) {
         if (!in_array($message['msgctxt'], $categories)) {
             $categories[] = $message['msgctxt'];
         }
         self::importOneMessage($languageCode, $message['msgctxt'], $message['msgid'], $message['msgstr']);
     }
     foreach ($categories as $category) {
         ZurmoMessageSource::clearCache($category, $languageCode);
     }
     return true;
 }