当前位置: 首页>>代码示例>>PHP>>正文


PHP Translation::save方法代码示例

本文整理汇总了PHP中Translation::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::save方法的具体用法?PHP Translation::save怎么用?PHP Translation::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Translation的用法示例。


在下文中一共展示了Translation::save方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: post

 /**
  * Implementation for 'POST' method for Rest API
  *
  * @param  mixed $trnCategory, $trnId, $trnLang Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function post($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
 {
     try {
         $result = array();
         $obj = new Translation();
         $obj->setTrnCategory($trnCategory);
         $obj->setTrnId($trnId);
         $obj->setTrnLang($trnLang);
         $obj->setTrnValue($trnValue);
         $obj->setTrnUpdateDate($trnUpdateDate);
         $obj->save();
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
 }
开发者ID:rodrigoivan,项目名称:processmaker,代码行数:23,代码来源:Translation.php

示例2: translate

 public function translate($s)
 {
     global $language_data;
     if (isset($language_data) and isset($language_data[$s])) {
         return $language_data[$s];
     } else {
         global $config, $home_dir, $db;
         if ($config['debug_mode']) {
             require_once $home_dir . 'models/translation.m.php';
             require_once $home_dir . 'models/language.m.php';
             $language = new Language($db);
             $language->loadByCode($language_data['language_code']);
             $t = new Translation($db);
             $t->load($language->ival('language_id'), $s);
             if (!$t->is_loaded) {
                 $t->data['translation_name'] = $s;
                 $t->data['translation_language_id'] = $language->ival('language_id');
                 $t->save();
             }
         }
         return $s;
     }
 }
开发者ID:lotcz,项目名称:zshop,代码行数:23,代码来源:localization.php

示例3: addTranslation

 /**
  * returns an array with
  * codError      0 - no error, < 0 error
  * rowsAffected  0,1 the number of rows affected
  * message       message error.
  */
 function addTranslation($category, $id, $languageId, $value)
 {
     //if exists the row in the database propel will update it, otherwise will insert.
     $tr = TranslationPeer::retrieveByPK($category, $id, $languageId);
     if (!(is_object($tr) && get_class($tr) == 'Translation')) {
         $tr = new Translation();
     }
     $tr->setTrnCategory($category);
     $tr->setTrnId($id);
     $tr->setTrnLang($languageId);
     $tr->setTrnValue($value);
     $tr->setTrnUpdateDate(date('Y-m-d'));
     if ($tr->validate()) {
         // we save it, since we get no validation errors, or do whatever else you like.
         $res = $tr->save();
     } else {
         // Something went wrong. We can now get the validationFailures and handle them.
         $msg = '';
         $validationFailuresArray = $tr->getValidationFailures();
         foreach ($validationFailuresArray as $objValidationFailure) {
             $msg .= $objValidationFailure->getMessage() . "\n";
         }
         return array('codError' => -100, 'rowsAffected' => 0, 'message' => $msg);
     }
     return array('codError' => 0, 'rowsAffected' => $res, 'message' => '');
     //to do: uniform  coderror structures for all classes
 }
开发者ID:nshong,项目名称:processmaker,代码行数:33,代码来源:Translation.php

示例4: resetLang

 public static function resetLang(Language $language, $pages = [], $level = 1)
 {
     /*
     @level
         - level 1 : adds only non existing values
         - level 2 : reset everything
     */
     // create new language config file
     foreach ($language->getLanguageList() as $lang_temp) {
         // check if lang dir exists
         $langDir = './languages/' . $lang_temp;
         if (!file_exists($langDir)) {
             mkdir($langDir, 0755);
         }
         $targets = array_merge(self::listTemplates(), self::listPages());
         foreach ($targets as $target) {
             // store found items
             $items = [];
             // name of the file
             $name = $target['filename'];
             $translation = new Translation();
             if ($level == 1) {
                 // get existing translations from file
                 $translation->setList($language, $name);
             }
             if ($name == 'main') {
                 // main is a built in file which is generated manually (for now)
                 // it contains global translations
                 #$translation->addItem('%head-title%', '');
                 #$translation->addItem('%head-author%', '');
                 #$translation->addItem('%head-description%', '');
                 #$translation->addItem('%head-keywords%', '');
                 $items['%head-title%'] = '';
                 $items['%head-author%'] = '';
                 $items['%head-description%'] = '';
                 $items['%head-keywords%'] = '';
                 foreach ($pages as $temp) {
                     #$translation->addItem('%page-'.$temp.'-title%', '');
                     $items['%page-' . $temp . '-title%'] = '';
                 }
                 foreach ($language->getLanguageList() as $temp) {
                     #$translation->addItem('%lang-'.$temp.'-name%', '');
                     $items['%lang-' . $temp . '-name%'] = '';
                 }
             } else {
                 // need to read to tpl file to get each entries
                 $file = $target['dirname'] . '/' . $target['basename'];
                 if (file_exists($file)) {
                     preg_match_all("#%[a-z\\-0-9]+%#isU", file_get_contents($file), $matches);
                     if (is_array($matches[0])) {
                         foreach ($matches[0] as $match) {
                             #$translation->addItem($match, '');
                             $items[$match] = '';
                         }
                     }
                 }
             }
             if ($level == 1) {
                 // clean files from unused translations
                 $temp = $translation->getList();
                 foreach ($items as $key => $value) {
                     if (isset($temp[$key]) && !empty($temp[$key])) {
                         $items[$key] = $temp[$key];
                     }
                 }
             }
             // force list setup
             $translation->setListBypass($items);
             // set a type based on the file location
             if (file_exists('./view/pages/' . $target['basename'])) {
                 $translation->setType(Translation::TYPE_PAGE);
             } else {
                 if (file_exists('./view/templates/' . $target['basename'])) {
                     $translation->setType(Translation::TYPE_TEMPLATE);
                 } else {
                     $translation->setType(Translation::TYPE_UNDEFINED);
                 }
             }
             $translation->save($lang_temp, $name);
         }
     }
 }
开发者ID:metterrothan,项目名称:cv-reboot-tpl-sys,代码行数:82,代码来源:Config.class.php

示例5: onSubmit

 function onSubmit($vals)
 {
     $collection = $vals['_collection'];
     $status = $vals['_status'];
     $key = $vals['_key'];
     $lang = $vals['_lang'];
     unset($vals['_collection']);
     unset($vals['_status']);
     unset($vals['_key']);
     unset($vals['_lang']);
     unset($vals['_header']);
     unset($vals['submit_button']);
     foreach ($vals as $k => $v) {
         if (empty($v)) {
             unset($vals[$k]);
         }
     }
     $tr = new Translation($collection, $lang);
     $id = $tr->getID($key);
     if (!$id) {
         $tr->add($key, $status, $vals);
     } else {
         $tr->save($key, $status, $vals);
     }
     page_title(intl_get('Translation Saved'));
     echo '<p><a href="' . site_prefix() . '/index/multilingual-app">' . intl_get('Continue') . '</a></p>';
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:27,代码来源:index.php

示例6: Localization

<?php

global $home_dir, $language_data;
require_once $home_dir . 'classes/localization.php';
require_once $home_dir . 'models/translation.m.php';
require_once $home_dir . 'models/language.m.php';
$localization = new Localization($home_dir . 'lang/');
$language = new Language($db);
$language->loadByCode($language_data['language_code']);
foreach ($language_data as $name => $translation) {
    $t = new Translation($db);
    $t->load($language->ival('language_id'), $name);
    $t->data['translation_name'] = $name;
    $t->data['translation_translation'] = $translation;
    $t->data['translation_language_id'] = $language->ival('language_id');
    $t->save();
}
echo 'Language imported.';
开发者ID:lotcz,项目名称:zshop,代码行数:18,代码来源:implang.j.php

示例7: addOrUpdateString

 public static function addOrUpdateString($sStringKey, $sContent, $sLanguageId = null)
 {
     if ($sLanguageId === null) {
         $sLanguageId = Session::language();
     }
     $oString = TranslationQuery::create()->findPk(array($sLanguageId, $sStringKey));
     if (!$sContent) {
         if ($oString !== null) {
             $oString->delete();
         }
         return;
     }
     if ($oString === null) {
         $oString = new Translation();
         $oString->setLanguageId($sLanguageId);
         $oString->setStringKey($sStringKey);
     }
     $oString->setText($sContent);
     $oString->save();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:20,代码来源:TranslationPeer.php

示例8: generateAction

 public function generateAction()
 {
     if (!empty($_POST)) {
         require_once MODEL . 'Translation.php';
         $translation = new Translation();
         foreach ($_POST as $variable => $languages) {
             $translation->languages = $languages;
             $translation->variable = $variable;
             $translation->save();
         }
     }
     $this->generate();
     Header::location(UrlFactory::module($this->module));
 }
开发者ID:ben33,项目名称:framework,代码行数:14,代码来源:TranslationsController.php

示例9: saveData

 public function saveData($aTagData)
 {
     $aTagData['name'] = StringUtil::normalize($aTagData['name']);
     if ($this->iTagId === null) {
         $oTag = new Tag();
     } else {
         $oTag = TagQuery::create()->findPk($this->iTagId);
     }
     $this->validate($aTagData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $sStringName = "tag.{$aTagData['name']}";
     if ($oTag->getName() !== $aTagData['name']) {
         //Rename Strings for the tag
         $sOldStringName = "tag.{$oTag->getName()}";
         foreach (TranslationQuery::create()->filterByStringKey($sOldStringName)->find() as $oString) {
             $sLanguageId = $oString->getLanguageId();
             //You can’t technically rename strings because string_key is the PKEY so we delete it and re-generate
             $oString->delete();
             $oString = new Translation();
             $oString->setStringKey($sStringName);
             $oString->setLanguageId($sLanguageId);
             $oString->save();
         }
         $oTag->setName($aTagData['name']);
     }
     foreach ($aTagData['edited_languages'] as $iIndex => $sLanguageId) {
         TranslationPeer::addOrUpdateString($sStringName, $aTagData['text'][$iIndex], $sLanguageId);
     }
     $oTag->save();
 }
开发者ID:rapila,项目名称:cms-base,代码行数:32,代码来源:TagDetailWidgetModule.php

示例10: saveData

 public function saveData($aStringData)
 {
     $this->validate($aStringData);
     if (!Flash::noErrors()) {
         throw new ValidationException();
     }
     $oConnection = Propel::getConnection();
     foreach (LanguageQuery::create()->orderById()->find() as $oLanguage) {
         $oUpdateCriteria = new Criteria();
         $oUpdateCriteria->add(TranslationPeer::LANGUAGE_ID, $oLanguage->getId());
         $oUpdateCriteria->add(TranslationPeer::STRING_KEY, $this->sStringId);
         if (isset($aStringData['text_' . $oLanguage->getId()])) {
             $sText = trim($aStringData['text_' . $oLanguage->getId()]);
             $oString = TranslationQuery::create()->findPk(array($oLanguage->getId(), $this->sStringId));
             if ($sText === '') {
                 if ($oString !== null) {
                     $oString->delete();
                 }
                 continue;
             }
             if ($oString === null) {
                 $oString = new Translation();
                 $oString->setLanguageId($oLanguage->getId());
                 $oString->setStringKey($aStringData['string_key']);
             } else {
                 if ($this->sStringId !== null && $this->sStringId !== $aStringData['string_key']) {
                     $oString->setStringKey($aStringData['string_key']);
                     BasePeer::doUpdate($oUpdateCriteria, $oString->buildCriteria(), $oConnection);
                 }
             }
             $oString->setText($sText);
             $oString->save();
         } else {
             $oString = TranslationQuery::create()->findPk(array($oLanguage->getId(), $this->sStringId));
             if ($oString === null) {
                 continue;
             }
             if ($this->sStringId !== null && $this->sStringId !== $aStringData['string_key']) {
                 $oString->setStringKey($aStringData['string_key']);
                 BasePeer::doUpdate($oUpdateCriteria, $oString->buildCriteria(), $oConnection);
             }
         }
     }
     // check sidebar reload criteria
     $sNameSpaceOld = TranslationPeer::getNameSpaceFromStringKey($this->sStringId);
     $sNameSpaceNew = TranslationPeer::getNameSpaceFromStringKey($aStringData['string_key']);
     // if both are the same the sidebar is not effected
     $bSidebarHasChanged = false;
     if ($sNameSpaceOld !== $sNameSpaceNew) {
         // if there was an old name space then we have to check whether it was the last string with this namespace
         if ($sNameSpaceOld !== null && !TranslationPeer::nameSpaceExists($sNameSpaceOld)) {
             $bSidebarHasChanged = true;
         }
         // if the new exits only once it has been created and the sidebar needs to be relaoded
         if ($sNameSpaceNew !== null && TranslationPeer::countNameSpaceByName($sNameSpaceNew) === 1) {
             $bSidebarHasChanged = true;
         }
     }
     $this->sStringId = $aStringData['string_key'];
     return array('id' => $this->sStringId, self::SIDEBAR_CHANGED => $bSidebarHasChanged);
 }
开发者ID:rapila,项目名称:cms-base,代码行数:61,代码来源:StringDetailWidgetModule.php

示例11: actionTransupdate

 public function actionTransupdate()
 {
     /* @var $word Translation */
     /* @var $lngObject TranslationLng */
     //get id from request
     $id = Yii::app()->request->getParam('id', null);
     // get word array
     $words = Yii::app()->request->getParam('word', null);
     // get label
     $label = Yii::app()->request->getParam('label', null);
     $word = null;
     if ($id == null) {
         $word = new Translation();
         $word->save();
     } else {
         $word = Translation::model()->findByPk($id);
     }
     //update lng objects
     foreach (Constants::GetLngArray() as $lngIndex => $lng) {
         $lngObject = $word->getLng($lng);
         $lngObject->word = $words[$lng];
         if ($lngObject->isNewRecord) {
             $lngObject->save();
         } else {
             $lngObject->update();
         }
     }
     $word->label = $label;
     $word->status = Constants::STATUS_VISIBLE;
     $word->update();
     //redirect to list
     $this->redirect($this->createUrl('/admin/panel/translations'));
 }
开发者ID:ruslankus,项目名称:inlux-transfer,代码行数:33,代码来源:PanelController.php


注:本文中的Translation::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。