public function phrase($phrase, $filter) { $tr = $this->get_translation($phrase, $filter); //var_dump($tr); //die; if ($tr) { return $tr; } else { //save for curr. language if ($this->language->id != Language::get_default()->id) { $newphr = Phrase::factory()->where('phrase', $phrase)->where_related_language($this->language)->limit(1)->get(); $newphr->phrase = $phrase; $newphr->filter = $filter; $newphr->save($this->language); } //return default return Phrase::get_default($phrase, $filter)->translation; } /* $phrase_obj = Phrase::factory() ->where("phrase", $phrase) ->where("filter", $filter) ->where_related_language($this->language) ->get(); if ($phrase_obj->exists()) { if (trim($phrase_obj->translation) != "") return $phrase_obj->translation; else return Phrase::get_default($phrase, $filter)->translation; } else { //save for curr. language if ($this->language->id != Language::get_default()->id) { $newphr = new Phrase(); $newphr->phrase = $phrase; $newphr->filter = $filter; $newphr->save($this->language); } //return default return Phrase::get_default($phrase, $filter)->translation; }//*/ }