translator() 정적인 공개 메소드

get the translate component
static public translator ( ) : MPTranslate
리턴 MPTranslate
 /**
  * 
  */
 public function actionMissing()
 {
     $model = new MessageSource('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['MessageSource'])) {
         $model->attributes = $_GET['MessageSource'];
     }
     $model->language = TranslateModule::translator()->getLanguage();
     $this->render('missing', array('model' => $model));
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
    <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>
예제 #4
0
 /**
  * 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);
 }
예제 #5
0
파일: missing.php 프로젝트: adsavin/app
<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')))));
예제 #6
0
<?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');
예제 #7
0
<?php

$translator = TranslateModule::translator();
$languageKey = $translator::ID;
$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){\n                        \$('#{$tagId}').val(response);\n                        \$('#{$tagId}-button').hide();\n                    }", 'error' => 'js:function(xhr){alert(xhr.responseText);}'), array('margin:0 5px', 'class' => "{$languageKey}-google-button", 'id' => $tagId . '-button')));
}
echo CHtml::closeTag('tr');
 /**
  * 
  */
 public function actionMissing()
 {
     if (!Yii::app()->user->isGuest) {
         $model = new MessageSource('search');
         $model->unsetAttributes();
         // clear any default values
         if (isset($_GET['MessageSource'])) {
             $model->attributes = $_GET['MessageSource'];
         }
         $model->language = TranslateModule::translator()->getLanguage();
         $this->render('missing', array('model' => $model));
     } else {
         throw new CHttpException(404, "Error Processing Request");
     }
 }
예제 #9
0
<?php

$action = $model->getIsNewRecord() ? 'Create' : 'Update';
Yii::app()->controller->pageTitle = TranslateModule::t($action . ' Message') . " # " . $model->id . " - " . TranslateModule::translator()->acceptedLanguages[$model->language];
?>


<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'message-form', 'enableAjaxValidation' => false));
?>

<div class="form">	
    
    <?php 
echo $form->hiddenField($model, 'id', array('size' => 10, 'maxlength' => 10));
?>
    <?php 
echo $form->hiddenField($model, 'language', array('size' => 16, 'maxlength' => 16));
?>
    
    <div class="row">
        <?php 
echo $form->label($model->source, 'category');
?>
        <?php 
echo $form->textField($model->source, 'category', array('disabled' => 'disabled'));
?>
    </div>
    <div class="row">
        <?php 
echo $form->label($model->source, 'message');
예제 #10
0
파일: form.php 프로젝트: adsavin/app
            <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>
예제 #11
0
<?php

$this->breadcrumbs = array($this->module->id);
$language = TranslateModule::translator();
$languageKey = $language::ID;
$google = !empty(TranslateModule::translator()->googleApiKey) ? true : false;
?>
<h2><?php 
echo TranslateModule::t('Translate to {lang}', array('{lang}' => $language->acceptedLanguages[$language->getLanguage()]));
?>
</h2>
<?php 
if ($google) {
    echo CHtml::link(TranslateModule::t('Translate all with google translate'), "#", array('id' => $languageKey . "-google-translateall"));
    echo CHtml::script("\$('#{$languageKey}-google-translateall').click(function(){\n                var messages=[];\$('.{$languageKey}-google-message').each(function(count){\n                    messages[count]=\$(this).html();\n                });" . CHtml::ajax(array('url' => $this->createUrl('translate/googletranslate'), 'type' => 'post', 'dataType' => "json", 'data' => array('language' => Yii::app()->getLanguage(), 'sourceLanguage' => Yii::app()->sourceLanguage, 'message' => 'js:messages'), 'success' => "js:function(response){\n                        \$('.{$languageKey}-google-translation').each(function(count){\n                            \$(this).val(response[count]);\n                        });\n                        \$('.{$languageKey}-google-button,#{$languageKey}-google-translateall').hide();\n                    }", 'error' => 'js:function(xhr){alert(xhr.statusText);}')) . "\n                return false;\n            });\n        ");
    if (Yii::app()->getRequest()->isAjaxRequest) {
        echo CHtml::script("\n                \$('#" . $languageKey . '-pager' . " a').click(function(){\n                    \$dialog=\$('#" . $languageKey . '-dialog' . "').load(\$(this).attr('href'));\n                    return false;\n                });\n            ");
    }
}
?>
<div class="form">

    <?php 
echo CHtml::beginForm();
//link to the page where you edit the translations
echo $translate->editLink('Edit translations page');
//link to the page where you check for all unstranslated messages of the system
echo $translate->missingLink('Missing translations page');
?>
    <table>
        <thead>
예제 #12
0
?>
<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>
예제 #13
0
<script src="<?php 
echo Yii::app()->baseUrl . '/ckeditor/ckeditor.js';
?>
"></script>

<?php 
$action = $model->getIsNewRecord() ? 'Create' : 'Update';
$breadcrumb = $model->getIsNewRecord() ? '<li class="active"><span class="fa fa-plus"></span> Create</li>' : '<li class="active"><span class="fa fa-edit"></span> Update</li>';
?>

<h1><span class="fa fa-flag"></span> <?php 
echo TranslateModule::t($action . ' Message') . " # " . $model->id . " - " . TranslateModule::translator()->acceptedLanguages[$model->language];
?>
<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>
    <?php 
echo TranslateModule::t($breadcrumb);
?>
</ul><hr>

<div class="container" style="margin-bottom:30px;min-height:450px;">

<?php