本文整理匯總了PHP中Translate::setLangFrom方法的典型用法代碼示例。如果您正苦於以下問題:PHP Translate::setLangFrom方法的具體用法?PHP Translate::setLangFrom怎麽用?PHP Translate::setLangFrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Translate
的用法示例。
在下文中一共展示了Translate::setLangFrom方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: translate_title_description_ajax
public function translate_title_description_ajax()
{
/*during creating property*/
$title = $this->input->post('title');
$desc = $this->input->post('desc');
$lang = $this->input->post('lang');
$lang = trim($lang);
//print $lang;die;
$translator = new Translate();
$translator->setLangFrom($lang);
$array = array();
$value['result'] = $this->system_model->get_all_langs();
foreach ($value['result']->result() as $va) {
if ($va->short_name != $lang) {
$title1 = '';
$description1 = '';
$translator->setLangTo($va->short_name);
$title1 = $translator->mm_translate($title);
$description1 = $translator->mm_translate($desc);
array_push($array, array('lang' => $va->short_name, 'title' => $title1, 'description' => $description1));
}
}
echo json_encode($array);
}
示例2: test
function test()
{
$translator = new Translate();
$translator->setLangFrom('en')->setLangTo('es');
echo $translator->translate('hello');
$lang_data = array('sign_in' => 'Sign In', 'sign_up' => 'Sign Up');
$lang_data_array = $lang_data;
$translate_array = $translator->get_translated_data_array('en', 'ar', $lang_data_array);
echo '<pre>';
print_r($translate_array);
die;
}