本文整理汇总了PHP中Translation::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::add方法的具体用法?PHP Translation::add怎么用?PHP Translation::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTranslations
/**
* Sets translation in database
*
* @param string $codeName the code naeme to add/update/delete
* @param array $translationList array like array('en' => 'enValue', 'fr' => 'deValue')
*/
public static function setTranslations($codeName, $translationList)
{
if (empty($translationList)) {
return;
}
foreach ($translationList as $language => $translation) {
// If translation text is null, removes the entry
if ($translation === NULL) {
ElementFactory::deleteElementList('Translation', 'translation_text=\'' . $codeName . '\' AND translation_language=\'' . $language . '\'');
continue;
}
try {
$translationElement = ElementFactory::getElement('Translation', NULL, 'translation_text=\'' . $codeName . '\' AND translation_language=\'' . $language . '\'');
$translationElement->value = $translation;
$translationElement->update();
} catch (ElementNoResultException $e) {
$translationElement = new Translation();
$translationElement->language = $language;
$translationElement->text = $codeName;
$translationElement->value = $translation;
$translationElement->add();
}
}
}
示例2: 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>';
}