本文整理汇总了PHP中Translation::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Translation::create方法的具体用法?PHP Translation::create怎么用?PHP Translation::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translation
的用法示例。
在下文中一共展示了Translation::create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
// Create a View (radio)
/*$view['radio'] = Viewr::create(array(
'path' => 'public.form.input.radio',
));
$view['textarea'] = Viewr::create(array(
'path' => 'public.form.input.textarea',
));
$view['text'] = Viewr::create(array(
'path' => 'public.form.input.text',
));
$view['password'] = Viewr::create(array(
'path' => 'public.form.input.password',
));
$view['hidden'] = Viewr::create(array(
'path' => 'public.form.input.hidden',
));
$view['checkbox'] = Viewr::create(array(
'path' => 'public.form.input.checkbox',
));
$view['submit'] = Viewr::create(array(
'path' => 'public.form.input.submit',
));
$view['select'] = Viewr::create(array(
'path' => 'public.form.input.select',
));
$this->command->info('View created => next step');*/
/**
*
* Title translation
*
*/
// i18n radio title
$i18n['title']['radio'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : radio title
$translation['title']['radio']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['radio']->id, 'locale_id' => 'fr', 'text' => 'Titre du radion'));
// Translation EN : radio title
$translation['title']['radio']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['radio']->id, 'locale_id' => 'en', 'text' => 'Radio title'));
// i18n textarea title
$i18n['title']['textarea'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : textarea title
$translation['title']['textarea']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['textarea']->id, 'locale_id' => 'fr', 'text' => 'Titre du Textarea'));
// Translation EN : textarea title
$translation['title']['textarea']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['textarea']->id, 'locale_id' => 'en', 'text' => 'Textarea title'));
// i18n text title
$i18n['title']['text'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : text title
$translation['title']['text']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['text']->id, 'locale_id' => 'fr', 'text' => 'Titre du text'));
// Translation EN : text title
$translation['title']['text']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['text']->id, 'locale_id' => 'en', 'text' => 'Text title'));
// i18n password title
$i18n['title']['password'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : password title
$translation['title']['password']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['password']->id, 'locale_id' => 'fr', 'text' => 'Titre du password'));
// Translation EN : password title
$translation['title']['password']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['password']->id, 'locale_id' => 'en', 'text' => 'PAssword title'));
// i18n hidden title
$i18n['title']['hidden'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : hidden title
$translation['title']['hidden']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['hidden']->id, 'locale_id' => 'fr', 'text' => 'Titre du hidden'));
// Translation EN : hidden title
$translation['title']['hidden']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['hidden']->id, 'locale_id' => 'en', 'text' => 'hidden title'));
// i18n checkbox title
$i18n['title']['checkbox'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : checkbox title
$translation['title']['checkbox']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['checkbox']->id, 'locale_id' => 'fr', 'text' => 'Titre du checkbox'));
// Translation EN : checkbox title
$translation['title']['checkbox']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['checkbox']->id, 'locale_id' => 'en', 'text' => 'checkbox title'));
// i18n submit title
$i18n['title']['submit'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : submit title
$translation['title']['submit']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['submit']->id, 'locale_id' => 'fr', 'text' => 'Titre du submit'));
// Translation EN : submit title
$translation['title']['submit']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['submit']->id, 'locale_id' => 'en', 'text' => 'submit title'));
// i18n select title
$i18n['title']['select'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : select title
$translation['title']['select']['FR'] = Translation::create(array('i18n_id' => $i18n['title']['select']->id, 'locale_id' => 'fr', 'text' => 'Titre du select'));
// Translation EN : select title
$translation['title']['select']['EN'] = Translation::create(array('i18n_id' => $i18n['title']['select']->id, 'locale_id' => 'en', 'text' => 'select title'));
/**
*
* label translation
*
*/
// i18n radio label
$i18n['label']['radio'] = I18n::create(array('i18n_type_id' => 2));
// Translation FR : radio label
$translation['label']['radio']['FR'] = Translation::create(array('i18n_id' => $i18n['label']['radio']->id, 'locale_id' => 'fr', 'text' => 'Titre du radion'));
// Translation EN : radio label
$translation['label']['radio']['EN'] = Translation::create(array('i18n_id' => $i18n['label']['radio']->id, 'locale_id' => 'en', 'text' => 'Radio label'));
//.........这里部分代码省略.........
示例2: set
public function set($locale, $value = null)
{
// Array format passed
if (is_array($locale)) {
foreach ($locale as $loc => $value) {
$this->set($loc, $value);
}
return;
}
// Update an existing translation
if ($this->has($locale)) {
$this->get($locale)->update(['value' => $value]);
} else {
// Create new translation
$this->translations[$locale] = Translation::create(['group_id' => $this->group_id, 'value' => $value, 'locale' => $locale]);
}
}
示例3: setName
/**
* Set the type name for the given language. A new entry in
* the database will be created if the language did not exist.
*
* @param int $p_languageId
* @param string $p_value
*
* @return boolean
*/
public function setName($p_languageId, $p_value)
{
global $g_ado_db;
if (!is_numeric($p_languageId)) {
return false;
}
// if the string is empty, nuke it
if (!is_string($p_value) || $p_value == '') {
if ($phrase_id = $this->translationExists($p_languageId)) {
$trans = new Translation($p_languageId, $phrase_id);
$trans->delete();
$changed = true;
} else {
$changed = false;
}
} else {
$description = new Translation($p_languageId, $this->getProperty('fk_phrase_id'));
if ($description->exists()) {
$changed = $description->setText($p_value);
} else {
$changed = $description->create($p_value);
if ($changed && is_null($this->getProperty('fk_phrase_id'))) {
$this->setProperty('fk_phrase_id', $description->getPhraseId());
}
}
}
return $changed;
}
示例4: setName
/**
* Set the type name for the given language. A new entry in
* the database will be created if the language did not exist.
*
* @param int $p_languageId
* @param string $p_value
*
* @return boolean
*/
public function setName($p_languageId, $p_value)
{
global $g_ado_db;
if (!is_numeric($p_languageId)) {
return false;
}
// if the string is empty, nuke it
if (!is_string($p_value) || $p_value == '') {
if ($phrase_id = $this->translationExists($p_languageId)) {
$trans = new Translation($p_languageId, $phrase_id);
$trans->delete();
$changed = true;
} else {
$changed = false;
}
} else {
$description = new Translation($p_languageId, $this->getProperty('fk_phrase_id'));
if ($description->exists()) {
$changed = $description->setText($p_value);
} else {
$changed = $description->create($p_value);
if ($changed && is_null($this->getProperty('fk_phrase_id'))) {
$this->setProperty('fk_phrase_id', $description->getPhraseId());
}
}
}
if ($changed) {
if (function_exists("camp_load_translation_strings")) {
camp_load_translation_strings("api");
}
$logtext = getGS('Field "$1" updated', $this->m_data['field_name']);
Log::Message($logtext, null, 143);
}
return $changed;
} // fn setName
示例5: SetPhrase
/**
* Enter description here...
*
* @param int $p_phraseId
* @param int $p_languageId
* @param string $p_text
*/
public static function SetPhrase($p_languageId, $p_phraseId, $p_text)
{
if (!is_numeric($p_languageId) || !is_numeric($p_phraseId) || !is_string($p_text)) {
return false;
}
$translation = new Translation($p_languageId, $p_phraseId);
if ($translation->exists()) {
return $translation->setText($p_text);
} else {
return $translation->create($p_text);
}
}
示例6: DebateAnswer
// UPLOAD_ERR_NO_TMP_DIR
case 7:
// UPLOAD_ERR_CANT_WRITE
camp_html_display_error(getGS("There was a problem uploading the file."), null, true);
break;
}
} else {
camp_html_display_error(getGS("The file exceeds the allowed max file size."), null, true);
}
$DebateAnswer = new DebateAnswer($f_fk_language_id, $f_debate_nr, $f_debateanswer_nr);
if (!$DebateAnswer->exists()) {
camp_html_display_error(getGS("Debate Answer \$1 does not exist.", $f_debateanswer_nr), null, true);
exit;
}
$description = new Translation(@$f_language_id);
$description->create($f_description);
$attributes = array();
$attributes['fk_description_id'] = $description->getPhraseId();
$attributes['fk_user_id'] = $g_user->getUserId();
if ($f_language_specific == "yes") {
$attributes['fk_language_id'] = @$f_language_id;
}
if ($f_content_disposition == "attachment") {
$attributes['content_disposition'] = "attachment";
}
if (!empty($_FILES['f_file'])) {
$file = Attachment::OnFileUpload($_FILES['f_file'], $attributes);
} else {
camp_html_goto_page(camp_html_article_url($articleObj, @$f_language_id, 'files/popup.php'));
}
// Check if image was added successfully
示例7: Translation
require_once($GLOBALS['g_campsiteDir'].'/classes/Log.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Article.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Attachment.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php');
require_once($GLOBALS['g_campsiteDir'].'/classes/Translation.php');
if (!SecurityToken::isValid()) {
camp_html_display_error(getGS('Invalid security token!'));
exit;
}
$f_language_id = Input::Get('f_language_id', 'int', 0);
$f_language_selected = Input::Get('f_language_selected', 'int', 0);
foreach ($_POST['file'] as $id => $values) {
$description = new Translation((int) $f_language_selected);
$description->create($values['f_description']); //$values
$updateArray = array();
$updateArray['fk_description_id'] = $description->getPhraseId();
/* if ($values['f_language_specific'] == "yes") {
$updateArray['fk_language_id'] = $f_language_selected;
}
*/
if ($values['f_content_disposition'] == "attachment") {
$updateArray['content_disposition'] = "attachment";
}
$fileObj = new Attachment((int) $id);
$fileObj->update($updateArray);
}
camp_html_add_msg(getGS("Images updated."), "ok");