From 90f938554585099e413fd6e56668f77db4b21e4b Mon Sep 17 00:00:00 2001 From: RomainMazB Date: Mon, 7 Jun 2021 22:27:01 +0200 Subject: [PATCH 1/3] Improve stubs adding missing translation keys --- .../Console/controller/_list_toolbar.stub | 6 +++--- src/Scaffold/Console/controller/create.stub | 12 ++++++------ src/Scaffold/Console/controller/preview.stub | 2 +- src/Scaffold/Console/controller/update.stub | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Scaffold/Console/controller/_list_toolbar.stub b/src/Scaffold/Console/controller/_list_toolbar.stub index f6aae31be..62c47434d 100644 --- a/src/Scaffold/Console/controller/_list_toolbar.stub +++ b/src/Scaffold/Console/controller/_list_toolbar.stub @@ -2,7 +2,7 @@ - New {{title_singular_name}} + '{{title_singular_name}}'])) ?> diff --git a/src/Scaffold/Console/controller/create.stub b/src/Scaffold/Console/controller/create.stub index 4afb14ae6..f66e9a0da 100644 --- a/src/Scaffold/Console/controller/create.stub +++ b/src/Scaffold/Console/controller/create.stub @@ -19,21 +19,21 @@ type="submit" data-request="onSave" data-hotkey="ctrl+s, cmd+s" - data-load-indicator="Creating {{singular_name}}..." + data-load-indicator=" '{{singular_name}}'])) ?>" class="btn btn-primary"> - Create + - or Cancel + @@ -43,6 +43,6 @@

fatalError) ?>

-

Return to {{lower_title_name}} list

+

'{{lower_title_name}}'])) ?>

diff --git a/src/Scaffold/Console/controller/preview.stub b/src/Scaffold/Console/controller/preview.stub index df5524cd4..5a7f3459a 100644 --- a/src/Scaffold/Console/controller/preview.stub +++ b/src/Scaffold/Console/controller/preview.stub @@ -14,6 +14,6 @@

fatalError) ?>

-

Return to {{lower_title_name}} list

+

'{{lower_title_name}}'])) ?>

diff --git a/src/Scaffold/Console/controller/update.stub b/src/Scaffold/Console/controller/update.stub index ce472060a..fa488f73f 100644 --- a/src/Scaffold/Console/controller/update.stub +++ b/src/Scaffold/Console/controller/update.stub @@ -20,28 +20,28 @@ data-request="onSave" data-request-data="redirect:0" data-hotkey="ctrl+s, cmd+s" - data-load-indicator="Saving {{singular_name}}..." + data-load-indicator=" '{{singular_name}}'])) ?>" class="btn btn-primary"> - Save + - or Cancel + @@ -51,6 +51,6 @@

fatalError) ?>

-

Return to {{lower_title_name}} list

+

'{{lower_title_name}}'])) ?>

From feeca44c7959c7969cee414c6cc581d9c02200cc Mon Sep 17 00:00:00 2001 From: RomainMazB Date: Wed, 9 Jun 2021 00:04:30 +0200 Subject: [PATCH 2/3] Revert "Improve stubs adding missing translation keys" This reverts commit 90f938554585099e413fd6e56668f77db4b21e4b. --- .../Console/controller/_list_toolbar.stub | 6 +++--- src/Scaffold/Console/controller/create.stub | 12 ++++++------ src/Scaffold/Console/controller/preview.stub | 2 +- src/Scaffold/Console/controller/update.stub | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Scaffold/Console/controller/_list_toolbar.stub b/src/Scaffold/Console/controller/_list_toolbar.stub index 62c47434d..f6aae31be 100644 --- a/src/Scaffold/Console/controller/_list_toolbar.stub +++ b/src/Scaffold/Console/controller/_list_toolbar.stub @@ -2,7 +2,7 @@ - '{{title_singular_name}}'])) ?> + New {{title_singular_name}} diff --git a/src/Scaffold/Console/controller/create.stub b/src/Scaffold/Console/controller/create.stub index f66e9a0da..4afb14ae6 100644 --- a/src/Scaffold/Console/controller/create.stub +++ b/src/Scaffold/Console/controller/create.stub @@ -19,21 +19,21 @@ type="submit" data-request="onSave" data-hotkey="ctrl+s, cmd+s" - data-load-indicator=" '{{singular_name}}'])) ?>" + data-load-indicator="Creating {{singular_name}}..." class="btn btn-primary"> - + Create - + or Cancel @@ -43,6 +43,6 @@

fatalError) ?>

-

'{{lower_title_name}}'])) ?>

+

Return to {{lower_title_name}} list

diff --git a/src/Scaffold/Console/controller/preview.stub b/src/Scaffold/Console/controller/preview.stub index 5a7f3459a..df5524cd4 100644 --- a/src/Scaffold/Console/controller/preview.stub +++ b/src/Scaffold/Console/controller/preview.stub @@ -14,6 +14,6 @@

fatalError) ?>

-

'{{lower_title_name}}'])) ?>

+

Return to {{lower_title_name}} list

diff --git a/src/Scaffold/Console/controller/update.stub b/src/Scaffold/Console/controller/update.stub index fa488f73f..ce472060a 100644 --- a/src/Scaffold/Console/controller/update.stub +++ b/src/Scaffold/Console/controller/update.stub @@ -20,28 +20,28 @@ data-request="onSave" data-request-data="redirect:0" data-hotkey="ctrl+s, cmd+s" - data-load-indicator=" '{{singular_name}}'])) ?>" + data-load-indicator="Saving {{singular_name}}..." class="btn btn-primary"> - + Save - + or Cancel @@ -51,6 +51,6 @@

fatalError) ?>

-

'{{lower_title_name}}'])) ?>

+

Return to {{lower_title_name}} list

From 0f90bb48ba1ac8105dffbfebf18793a28ed7c2ca Mon Sep 17 00:00:00 2001 From: RomainMazB Date: Wed, 9 Jun 2021 00:23:02 +0200 Subject: [PATCH 3/3] Add --with-translations option --- src/Scaffold/Console/CreateController.php | 27 +++++++-- .../_list_toolbar-with-translations.stub | 21 +++++++ .../controller/create-with-translations.stub | 48 ++++++++++++++++ .../controller/preview-with-translations.stub | 19 +++++++ .../controller/update-with-translations.stub | 56 +++++++++++++++++++ 5 files changed, 167 insertions(+), 4 deletions(-) create mode 100644 src/Scaffold/Console/controller/_list_toolbar-with-translations.stub create mode 100644 src/Scaffold/Console/controller/create-with-translations.stub create mode 100644 src/Scaffold/Console/controller/preview-with-translations.stub create mode 100644 src/Scaffold/Console/controller/update-with-translations.stub diff --git a/src/Scaffold/Console/CreateController.php b/src/Scaffold/Console/CreateController.php index 081d2ce99..dc0b85a4a 100644 --- a/src/Scaffold/Console/CreateController.php +++ b/src/Scaffold/Console/CreateController.php @@ -34,16 +34,34 @@ class CreateController extends GeneratorCommand * @var array */ protected $stubs = [ - 'controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', 'controller/config_form.stub' => 'controllers/{{lower_name}}/config_form.yaml', 'controller/config_list.stub' => 'controllers/{{lower_name}}/config_list.yaml', - 'controller/create.stub' => 'controllers/{{lower_name}}/create.htm', 'controller/index.stub' => 'controllers/{{lower_name}}/index.htm', - 'controller/preview.stub' => 'controllers/{{lower_name}}/preview.htm', - 'controller/update.stub' => 'controllers/{{lower_name}}/update.htm', 'controller/controller.stub' => 'controllers/{{studly_name}}.php', ]; + /** @inheritDoc */ + public function handle() + { + if ($this->option('with-translations')) { + $this->stubs = array_merge($this->stubs, [ + 'controller/_list_toolbar-with-translations.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', + 'controller/create-with-translations.stub' => 'controllers/{{lower_name}}/create.htm', + 'controller/preview-with-translations.stub' => 'controllers/{{lower_name}}/preview.htm', + 'controller/update-with-translations.stub' => 'controllers/{{lower_name}}/update.htm', + ]); + } else { + $this->stubs = array_merge($this->stubs, [ + 'controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', + 'controller/create.stub' => 'controllers/{{lower_name}}/create.htm', + 'controller/preview.stub' => 'controllers/{{lower_name}}/preview.htm', + 'controller/update.stub' => 'controllers/{{lower_name}}/update.htm', + ]); + } + + parent::handle(); // TODO: Change the autogenerated stub + } + /** * Prepare variables for stubs. * @@ -99,6 +117,7 @@ protected function getOptions() return [ ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], ['model', null, InputOption::VALUE_OPTIONAL, 'Define which model name to use, otherwise the singular controller name is used.'], + ['with-translations', null, InputOption::VALUE_NONE, 'Generate view files with translation keys.'], ]; } } diff --git a/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub b/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub new file mode 100644 index 000000000..62c47434d --- /dev/null +++ b/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub @@ -0,0 +1,21 @@ +
+ + '{{title_singular_name}}'])) ?> + + + +
diff --git a/src/Scaffold/Console/controller/create-with-translations.stub b/src/Scaffold/Console/controller/create-with-translations.stub new file mode 100644 index 000000000..f66e9a0da --- /dev/null +++ b/src/Scaffold/Console/controller/create-with-translations.stub @@ -0,0 +1,48 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + + +

fatalError) ?>

+

'{{lower_title_name}}'])) ?>

+ + diff --git a/src/Scaffold/Console/controller/preview-with-translations.stub b/src/Scaffold/Console/controller/preview-with-translations.stub new file mode 100644 index 000000000..5a7f3459a --- /dev/null +++ b/src/Scaffold/Console/controller/preview-with-translations.stub @@ -0,0 +1,19 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + + +

fatalError) ?>

+

'{{lower_title_name}}'])) ?>

+ + diff --git a/src/Scaffold/Console/controller/update-with-translations.stub b/src/Scaffold/Console/controller/update-with-translations.stub new file mode 100644 index 000000000..fa488f73f --- /dev/null +++ b/src/Scaffold/Console/controller/update-with-translations.stub @@ -0,0 +1,56 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + +
+
+ + + + + +

fatalError) ?>

+

'{{lower_title_name}}'])) ?>

+ +