Exemple #1
0
 public function translate()
 {
     $domain = $this->input->post('domain');
     $translation = $this->input->post('translation');
     $origin = $this->input->post('origin');
     $comment = $this->input->post('comment');
     $poFileManager = new PoFileManager();
     $po_Attributes = getPoFileAttributes($domain);
     if ($po_Attributes) {
         $data[$origin] = array('translation' => $translation, 'comment' => $comment);
         if ($poFileManager->update($po_Attributes['name'], $po_Attributes['type'], $po_Attributes['lang'], $data)) {
             return json_encode(array('success' => TRUE, 'message' => lang('Successfully translated.', 'translator')));
         } else {
             return json_encode(array('errors' => TRUE, 'message' => $poFileManager->getErrors()));
         }
     } else {
         return json_encode(array('errors' => TRUE, 'message' => lang('Not valid translation file attributes.', 'translator')));
     }
 }
 public function updateOne()
 {
     $name = $this->input->post('name');
     $type = $this->input->post('type');
     $locale = $this->input->post('locale');
     $translation = $this->input->post('translation');
     $origin = $this->input->post('origin');
     $poFileManager = new PoFileManager();
     if ($name && $type && $locale && $origin) {
         $data[$origin] = array('translation' => $translation);
         if ($poFileManager->update($name, $type, $locale, $data)) {
             return json_encode(array('success' => TRUE, 'message' => lang('Successfully translated.', 'translator')));
         } else {
             return json_encode(array('errors' => TRUE, 'message' => $poFileManager->getErrors()));
         }
     } else {
         return json_encode(array('errors' => TRUE, 'message' => lang('Not valid translation file attributes.', 'translator')));
     }
 }