function actionGoogletranslate() { if (Yii::app()->getRequest()->getIsPostRequest()) { $translation = TranslateModule::translator()->googleTranslate($_POST['message'], $_POST['language'], $_POST['sourceLanguage']); if (is_array($translation)) { echo CJSON::encode($translation); } else { echo $translation; } } else { throw new CHttpException(400); } }
<table> <thead> <th><?php echo MessageSource::model()->getAttributeLabel('category'); ?> </th> <th><?php echo MessageSource::model()->getAttributeLabel('message'); ?> </th> <th><?php echo Message::model()->getAttributeLabel('translation'); ?> </th> <?php echo $google ? CHtml::tag('th') : null; ?> </thead> <tbody> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => new CArrayDataProvider($models), 'pager' => array('id' => TranslateModule::translator()->languageKey . '-pager', 'class' => 'CLinkPager'), 'viewData' => array('messages' => $messages, 'google' => $google), 'itemView' => '_form')); ?> </tbody> </table> <?php echo CHtml::submitButton(TranslateModule::t('Translate')); ?> <?php echo CHtml::endForm(); ?> </div>
/** * helper so you can use MPTransalate::someMethod($args) * * php 5.3 only * * @param mixed $method * @param mixed $args * @return mixed */ static function __callStatic($method, $args) { return call_user_func_array(array(TranslateModule::translator(), $method), $args); }
<?php Yii::app()->controller->pageTitle = TranslateModule::t('Manage Messages'); ?> <?php $source = MessageSource::model()->findAll(); $this->widget('zii.widgets.grid.CGridView', array('id' => 'message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'filter' => CHtml::listData($source, 'id', 'id')), array('name' => 'message', 'filter' => CHtml::listData($source, 'message', 'message')), array('name' => 'category', 'filter' => CHtml::listData($source, 'category', 'category')), array('name' => 'language', 'filter' => CHtml::listData($model->findAll(new CDbCriteria(array('group' => 'language'))), 'language', 'language')), 'translation', array('class' => 'CButtonColumn', 'template' => '{update}', 'buttons' => array('update' => array('label' => t('Edit'), 'imageUrl' => false, 'url' => 'Yii::app()->getController()->createUrl("update",array("id"=>$data->id,"language"=>$data->language))'))), array('class' => 'CButtonColumn', 'template' => '{delete}', 'buttons' => array('delete' => array('label' => t('Delete'), 'imageUrl' => false, 'url' => 'Yii::app()->getController()->createUrl("delete",array("id"=>$data->id,"language"=>$data->language))'))))));
<h1><?php echo TranslateModule::t('Missing Translations') . " - " . TranslateModule::translator()->acceptedLanguages[Yii::app()->getLanguage()]; ?> </h1> <?php $source = MessageSource::model()->findAll(); $this->widget('zii.widgets.grid.CGridView', array('id' => 'message-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('class' => 'CButtonColumn', 'template' => '{create}{delete}', 'deleteButtonUrl' => 'Yii::app()->getController()->createUrl("missingdelete",array("id"=>$data->id))', 'buttons' => array('create' => array('label' => TranslateModule::t('Create'), 'url' => 'Yii::app()->getController()->createUrl("create",array("id"=>$data->id,"language"=>Yii::app()->getLanguage()))')), 'header' => TranslateModule::translator()->dropdown()), array('name' => 'message', 'filter' => CHtml::listData($source, 'message', 'message')), 'id', array('name' => 'category', 'filter' => CHtml::listData($source, 'category', 'category')))));
<?php $this->breadcrumbs = array($this->module->id); ?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="247" valign="top"> <?php $this->renderPartial('left_side'); ?> </td> <td valign="top"> <div class="cont_right formWrapper"> <h1><?php echo TranslateModule::t('Manage Messages'); ?> </h1> <?php $source = MessageSource::model()->findAll(); $this->widget('zii.widgets.grid.CGridView', array('id' => 'message-grid', 'dataProvider' => $model->search(), 'pager' => array('cssFile' => Yii::app()->baseUrl . '/css/formstyle.css'), 'cssFile' => Yii::app()->baseUrl . '/css/formstyle.css', 'columns' => array(array('name' => 'message', 'filter' => CHtml::listData($source, 'message', 'message')), array('name' => 'category', 'filter' => CHtml::listData($source, 'category', 'category')), array('name' => 'language', 'filter' => CHtml::listData($model->findAll(new CDbCriteria(array('group' => 'language'))), 'language', 'language')), 'translation', array('class' => 'CButtonColumn', 'template' => '{update}{delete}', 'updateButtonUrl' => 'Yii::app()->getController()->createUrl("update",array("id"=>$data->id,"language"=>$data->language))', 'deleteButtonUrl' => 'Yii::app()->getController()->createUrl("delete",array("id"=>$data->id,"language"=>$data->language))')))); ?> </div> </td> </tr> </table>
function attributeLabels() { return array('id' => TranslateModule::t('ID'), 'language' => TranslateModule::t('Language'), 'translation' => TranslateModule::t('Translation'), 'category' => MessageSource::model()->getAttributeLabel('category'), 'message' => MessageSource::model()->getAttributeLabel('message')); }
<?php $languageKey = TranslateModule::translator()->languageKey; $id = $data->id; $message = $messages[$id]; if ($google) { $tagId = "{$languageKey}-{$id}"; } echo CHtml::openTag('tr'); echo CHtml::tag('td', array(), CHtml::tag('span', array('margin:0 5px'), $message['category'])); echo CHtml::tag('td', array(), CHtml::tag('span', array('margin:0 5px', 'class' => $languageKey . "-google-message"), $message['message'])); echo CHtml::tag('td', array(), CHtml::activeTextArea($data, "[{$id}]translation", array('id' => $google ? $tagId : null, 'class' => "{$languageKey}-google-translation", 'cols' => 35, 'rows' => 2)) . CHtml::activeHiddenField($data, "[{$id}]language")); if ($google) { echo CHtml::tag('td', array(), CHtml::ajaxLink(TranslateModule::t('Translate'), $this->createUrl('translate/googletranslate'), array('type' => 'post', 'data' => array('message' => $message['message'], 'language' => Yii::app()->getLanguage(), 'sourceLanguage' => Yii::app()->sourceLanguage), 'success' => "js:function(response){\r\n \$('#{$tagId}').val(response);\r\n \$('#{$tagId}-button').hide();\r\n }", 'error' => 'js:function(xhr){alert(xhr.responseText);}'), array('margin:0 5px', 'class' => "{$languageKey}-google-button", 'id' => $tagId . '-button'))); } echo CHtml::closeTag('tr');
/** * Deletes a record * @param integer $id the ID of the model to be deleted * @param string $language the language of the model to de deleted */ public function actionMissingdelete($id) { if (!Yii::app()->user->isGuest) { if (Yii::app()->getRequest()->getIsPostRequest()) { $model = MessageSource::model()->findByPk($id); if ($model->delete()) { if (Yii::app()->getRequest()->getIsAjaxRequest()) { echo TranslateModule::t('Message deleted successfully'); Yii::app()->end(); } else { $this->redirect(Yii::app()->getRequest()->getUrlReferrer()); } } } else { throw new CHttpException(400); } } else { throw new CHttpException(404, "Error Processing Request"); } }
<h1><span class="fa fa-flag"></span> <?php echo TranslateModule::t('Manage Translation'); ?> <hr></h1> <ul class="breadcrumb" style="background-color:#F8F8F8;"> <li><a href="<?php echo Yii::app()->createUrl('site/admin'); ?> "><span class="fa fa-dashboard"></span> Dashboard</a></li> <li><a href="<?php echo Yii::app()->createUrl('translate/edit/admin'); ?> "><span class="fa fa-flag"></span> Translation</a></li> <li class="active"><span class="fa fa-cog"></span> Manage</li> </ul><hr> <a href="<?php echo Yii::app()->createUrl('translate/edit/missing'); ?> " class="btn btn-default"><span class="fa fa-warning"></span> Missing</a> <div class="container" style="margin-bottom:30px;min-height:450px;"> <?php $source = MessageSource::model()->findAll(); $this->widget('booster.widgets.TbGridView', array('id' => 'message-grid', 'type' => 'striped bordered', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'filter' => CHtml::listData($source, 'id', 'id')), array('name' => 'message', 'value' => 'strlen($data->message) > 5 ? substr($data->message, 0, 100)."..." : $data->message', 'htmlOptions' => array('style' => 'width:400px;')), array('name' => 'category', 'filter' => CHtml::listData($source, 'category', 'category')), array('name' => 'language', 'filter' => CHtml::listData($model->findAll(new CDbCriteria(array('group' => 'language'))), 'language', 'language')), array('name' => 'translation', 'value' => 'strlen($data->translation) > 5 ? substr($data->translation, 0, 100)."..." : $data->translation', 'htmlOptions' => array('style' => 'width:400px;')), array('class' => 'booster.widgets.TbButtonColumn', 'template' => '{update} {delete}', 'updateButtonUrl' => 'Yii::app()->getController()->createUrl("update",array("id"=>$data->id,"language"=>$data->language))', 'deleteButtonUrl' => 'Yii::app()->getController()->createUrl("delete",array("id"=>$data->id,"language"=>$data->language))')))); ?> </div>
<div class="row"> <?php echo $form->label($model->source, 'message'); ?> <?php echo $form->textField($model->source, 'message', array('disabled' => 'disabled')); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'translation'); ?> <?php echo $form->textArea($model, 'translation', array('rows' => 2, 'cols' => 80)); ?> <?php echo $form->error($model, 'translation'); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton(TranslateModule::t($action)); ?> </div> </div> <?php $this->endWidget(); ?> <!-- form -->
<div class="row buttons"> <?php echo CHtml::submitButton(TranslateModule::t($action)); ?> </div> <?php $this->endWidget(); ?> </div><!-- form --> </div> <div class="col-lg-8"> <?php $modell = new MessageSource('search'); $modell->unsetAttributes(); // clear any default values if (isset($_GET['MessageSource'])) { $modell->attributes = $_GET['MessageSource']; } $modell->language = TranslateModule::translator()->getLanguage(); $this->renderPartial('missing', array('model' => $modell)); ?> </div> </div> <script> $(document).ready(function () { $("#Message_translation").focus(); }); </script>
function attributeLabels() { return array('id' => TranslateModule::t('ID'), 'category' => TranslateModule::t('Category'), 'message' => TranslateModule::t('Message')); }
?> <hr></h1> <ul class="breadcrumb" style="background-color:#F8F8F8;"> <li><a href="<?php echo Yii::app()->createUrl('site/admin'); ?> "><span class="fa fa-dashboard"></span> Dashboard</a></li> <li><a href="<?php echo Yii::app()->createUrl('translate/edit/admin'); ?> "><span class="fa fa-flag"></span> Translation</a></li> <li><a href="<?php echo Yii::app()->createUrl('translate/edit/admin'); ?> "><span class="fa fa-cog"></span> Manage</a></li> <li class="active"><span class="fa fa-warning"></span> Missing</li> </ul><hr> <a href="<?php echo Yii::app()->createUrl('translate/edit/admin'); ?> " class="btn btn-default"><span class="fa fa-cog"></span> Manage</a> <div class="container" style="margin-bottom:30px;min-height:450px;"> <?php $source = MessageSource::model()->findAll(); $this->widget('booster.widgets.TbGridView', array('id' => 'message-grid', 'type' => 'striped bordered', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array(array('name' => 'id', 'htmlOptions' => array('style' => 'width:80px;')), array('name' => 'message', 'value' => 'strlen($data->message) > 5 ? substr($data->message, 0, 100)."..." : $data->message'), array('name' => 'category', 'filter' => CHtml::listData($source, 'category', 'category')), array('class' => 'booster.widgets.TbButtonColumn', 'template' => '{create} {delete}', 'deleteButtonUrl' => 'Yii::app()->getController()->createUrl("missingdelete",array("id"=>$data->id))', 'buttons' => array('create' => array('label' => TranslateModule::t('Create'), 'url' => 'Yii::app()->getController()->createUrl("create",array("id"=>$data->id,"language"=>Yii::app()->getLanguage()))')), 'header' => TranslateModule::translator()->dropdown())))); ?> </div>
<td><?php echo $form->textArea($model, 'translation', array('rows' => 2, 'cols' => 50)); ?> <?php echo $form->error($model, 'translation'); ?> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td><?php echo CHtml::submitButton(TranslateModule::t($action), array('class' => 'formbut')); ?> </td> </tr> </table> <div class="row"> </div> <div class="row"> </div>