Commit 311bd469 by Luciano Baraglia

Changes in GII I18N

parent d54c6159
......@@ -457,7 +457,7 @@ abstract class Generator extends Model
public function generateString($string = '', $placeholders = []){
if ($this->enableI18N) {
// If there are placeholders, use them
if (count($placeholders) > 0) {
if (!empty($placeholders)) {
$search = ['array (', ')'];
$replace = ['[', ']'];
$ph = ', ' . str_replace($search, $replace, var_export($placeholders, true));
......@@ -467,7 +467,7 @@ abstract class Generator extends Model
$str = "Yii::t('" . $this->translationCategory . "', '" . $string . "'" . $ph . ")";
} else {
// No I18N, replace placeholders by real words, if any
if (count($placeholders) > 0) {
if (!empty($placeholders)) {
$phKeys = array_map(function($word) {
return '{' . $word . '}';
}, array_keys($placeholders));
......
......@@ -111,12 +111,12 @@ yii.gii = (function ($) {
initConfirmationCheckboxes();
// model generator: hide class name input when table name input contains *
$('#model-generator #generator-tablename').on('change',function () {
$('#model-generator #generator-tablename').change(function () {
$('#model-generator .field-generator-modelclass').toggle($(this).val().indexOf('*') == -1);
}).change();
// CRUD generator: hide translationCategory when I18N is disabled
$('#crud-generator #generator-enablei18n').on('change',function () {
$('#crud-generator #generator-enablei18n').change(function () {
$('#crud-generator .field-generator-translationcategory').toggle($(this).is(':checked'));
}).change();
......
......@@ -166,7 +166,7 @@ class Generator extends \yii\gii\Generator
*/
public function validateTranslationCategory()
{
if ((boolean)$this->enableI18N && empty($this->translationCategory)) {
if ($this->enableI18N && empty($this->translationCategory)) {
$this->addError('translationCategory', "Translation Category cannot be blank.");
}
}
......
......@@ -49,7 +49,7 @@ class <?= $searchModelClass ?> extends Model
{
return [
<?php foreach ($labels as $name => $label): ?>
<?= "'$name' => " . $generator->generateString(addslashes($label)) . ",\n" ?>
<?= "'$name' => " . addslashes($generator->generateString($label)) . ",\n" ?>
<?php endforeach; ?>
];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment