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); }
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; }