コード例 #1
0
 /**
  * Add missing translations to the source table and 
  * If we are using a different translation then the original one
  * Then add the same message to the translation table.
  */
 public static function load($event)
 {
     // Load the messages
     $objSource = Stringsource::model()->find('message=:message AND category=:category', array(':message' => $event->message, ':category' => $event->category));
     // If we didn't find one then add it
     if (!$objSource) {
         // Add it
         $objSource = new Stringsource();
         $objSource->category = $event->category;
         $objSource->message = $event->message;
         $objSource->save();
         $lastID = Yii::app()->db->lastInsertID;
     }
     if ($event->language != Yii::app()->sourceLanguage) {
         // Do the same thing with the messages
         $objTranslate = Stringtranslate::model()->find('language=:language AND id=:id', array(':language' => $event->language, ':id' => $objSource->id));
         // If we didn't find one then add it
         if (!$objTranslate) {
             // Add it
             $objTranslate = new Stringtranslate();
             $objTranslate->id = $objSource->id;
             $objTranslate->language = $event->language;
             $objTranslate->translation = $event->message;
             $objTranslate->save();
         }
     }
 }