예제 #1
0
 public static function Translate($strWord)
 {
     //must specify the source language and word to get translation
     return LuxTranslation::getTranslationFromDefiniteLng($strWord, INPUT_LANGUAGE, $language = Yii::app()->language);
     //must just specify word on any language to get translation (eats lots of server resources - low performance)
     //       return Translation::getTranslationFromWordOnSomeLng($strWord,Yii::app()->language);
 }
예제 #2
0
 public function actionTransdel()
 {
     /* @var $word LuxTranslation */
     //get id from request
     $id = Yii::app()->request->getParam('id', null);
     //get word by id
     $word = LuxTranslation::model()->findByPk($id);
     //if not found - redirect to index
     if ($word == null) {
         $this->redirect($this->createUrl('/admin/inlux/index'));
     }
     //delete
     $word->deleteLng();
     $word->delete();
     //redirect to list
     $this->redirect($this->createUrl('/admin/inlux/translations'));
 }
예제 #3
0
 public static function getTranslationFromWordOnSomeLng($str, $toLng)
 {
     /* @var $lng LuxTranslationLng */
     /* @var $word LuxTranslation */
     /* @var $neededWord LuxTranslation */
     $ret = "";
     $neededWord = null;
     $allWords = LuxTranslation::model()->findAll();
     foreach ($allWords as $word) {
         foreach (Constants::GetLngArray() as $lngIndex => $lng) {
             $strWord = $word->getWordByLng($lng);
             if ($str == $strWord) {
                 $neededWord = $word;
             }
         }
     }
     if ($neededWord != null) {
         $ret = $neededWord->getWordByLng($toLng);
     } else {
         $ret = $str;
     }
     return $ret;
 }