Skip to content

Commit

Permalink
localizations support copy from mdmsoft#368
Browse files Browse the repository at this point in the history
in ./views/assignnets/view.php and ./views/item/view.php add $labels - localization support js. Update _script.js too.
  • Loading branch information
noname007 committed May 28, 2019
1 parent d47c0c8 commit dd78092
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 5 additions & 2 deletions views/assignment/_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ function search(target) {
$list.html('');
var q = $('.search[data-target="' + target + '"]').val();


var groups = {
role: [$('<optgroup label="Roles">'), false],
permission: [$('<optgroup label="Permission">'), false],
role: [$('<optgroup label="' + _labels['Roles'] + '">'), false],
permission: [$('<optgroup label="' + _labels['Permissions'] + '">'), false],
};


$.each(_opts.items[target], function (name, group) {
if (name.indexOf(q) >= 0) {

Expand Down
6 changes: 6 additions & 0 deletions views/assignment/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
$opts = Json::htmlEncode([
'items' => $model->getItems(),
]);
$labels = Json::htmlEncode([
'Roles' => Yii::t('rbac-admin', 'Roles'),
'Permissions' => Yii::t('rbac-admin', 'Permissions'),
]);

$this->registerJs("var _opts = {$opts};");
$this->registerJs("var _labels = {$labels};");
$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
?>
Expand Down
7 changes: 4 additions & 3 deletions views/item/_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ function search(target) {
var q = $('.search[data-target="' + target + '"]').val();

var groups = {
role: [$('<optgroup label="Roles">'), false],
permission: [$('<optgroup label="Permission">'), false],
route: [$('<optgroup label="Routes">'), false],
role: [$('<optgroup label="' + _labels['Roles'] + '">'), false],
permission: [$('<optgroup label="' + _labels['Permissions'] + '">'), false],
route: [$('<optgroup label="' + _labels['Routes'] + '">'), false],
};

$.each(_opts.items[target], function (name, group) {
if (name.indexOf(q) >= 0) {

Expand Down
8 changes: 8 additions & 0 deletions views/item/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
'items' => $model->getItems(),
]);
$this->registerJs("var _opts = {$opts};");

$labels = Json::htmlEncode([
'Roles' => Yii::t('rbac-admin', 'Roles'),
'Permissions' => Yii::t('rbac-admin', 'Permissions'),
'Routes' => Yii::t('rbac-admin', 'Routes'),
]);
$this->registerJs("var _labels = {$labels};");

$this->registerJs($this->render('_script.js'));
$animateIcon = ' <i class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></i>';
?>
Expand Down

0 comments on commit dd78092

Please sign in to comment.