Commit 311bd469 by Luciano Baraglia

Changes in GII I18N

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