Scaffold Translation Plugin
Purpose
This OctoberCMS plugin adds scaffold commands to generate translation aware source files.
Following php artisan
commands are enhanced :
create:plugin:translated
create:controllers:translated
create:component:translated
Note: running those commands will rewrite and reformat existing plugin language files (ie. the returned PHP array).
Usage
php artisan create:plugin:translated Acme.Demo php artisan create:controller:translated Acme.Demo Turtles php artisan create:component:translated Acme.Demo TurtleList
Those commands will create the plugin, with a controller and a component. The new Acme.Demo plugin lang/en/lang.php
will look like this :
<?php return [ 'plugin' => [ 'name' => 'Demo', 'description' => 'No description provided yet...', ], 'turtle' => [ 'new' => 'New Turtle', 'label' => 'Turtle', 'create_title' => 'Create Turtle', 'update_title' => 'Edit Turtle', 'preview_title' => 'Preview Turtle', 'list_title' => 'Manage Turtles', ], 'turtles' => [ 'delete_selected_confirm' => 'Delete the selected turtles?', 'menu_label' => 'Turtles', 'return_to_list' => 'Return to Turtles', 'delete_confirm' => 'Do you really want to delete this turtle?', 'delete_selected_success' => 'Successfully deleted the selected turtles.', 'delete_selected_empty' => 'There are no selected :name to delete.', ], 'components' => [ 'turtlelist' => [ 'name' => 'TurtleList Component', 'description' => 'No description provided yet...', ], ], ];
These keys are used in controller, component and plugin classes, views or YAML files.
Language files for en
, config('app.locale')
and config('app.fallback_locale')
are generated.
The default values can be translated in other languages using the lang/xx/lang.php
files of this plugin.
If no default value is found, the key is used.
New commands available
Generate a widget stub
php artisan create:widget:translated Acme.Plugin FooWidget
Similar to create:formwidget
, no translation here.
Find missing translation keys
php artisan plugin:translate Acme.Plugin
This new command will scan classes
, components
, models
, controllers
, widgets
, formwidgets
folders and
Plugin.php
files.
It will detect missing translation key and add them to the lang/xx/lang.php
files.
Warning: running those commands will rewrite and reformat existing language file returned array.
Manual installation
To manually install the plugin, get the sources archive from Github, uncompress the files in
plugins/bnb/scaffoldtranslation
folder and run this command at the root of OctoberCMS installation :
php artisan plugin:refresh BnB.ScaffoldTranslation
Usage
artisan create:plugin Acme.Demo artisan create:controller Acme.Demo Turtles artisan create:component Acme.Demo TurtleList
Those commands will create the plugin, with a controller and a component. The new Acme.Demo plugin lang/en/lang.php
will look like this :
<?php return [ 'plugin' => [ 'name' => 'Demo', 'description' => 'No description provided yet...', ], 'turtle' => [ 'new' => 'New Turtle', 'label' => 'Turtle', 'create_title' => 'Create Turtle', 'update_title' => 'Edit Turtle', 'preview_title' => 'Preview Turtle', 'list_title' => 'Manage Turtles', ], 'turtles' => [ 'delete_selected_confirm' => 'Delete the selected turtles?', 'menu_label' => 'Turtles', 'return_to_list' => 'Return to Turtles', 'delete_confirm' => 'Do you really want to delete this turtle?', 'delete_selected_success' => 'Successfully deleted the selected turtles.', 'delete_selected_empty' => 'There are no selected :name to delete.', ], 'components' => [ 'turtlelist' => [ 'name' => 'TurtleList Component', 'description' => 'No description provided yet...', ], ], ];
Those keys are used in the controller, component and plugin classes, views or YAML files.
Language files for en
, config('app.locale')
and config('app.fallback_locale')
are generated.
The default values can be translated in other languages using the lang/xx/lang.php
files of this plugin.
If no default value is found, the key is used. Feel free to create pull request for new default translations in the master branch of the public repository.
Settings
Only one setting is available through the back-end settings screen, in the System section. The switch, which is
on
by default, enables or disables the usage of translated stub (fallback to October's stub).
If it is unchecked, translated stub can still be generated using the --translated
(or -t
) option switch with
create:plugin
, create:controller
and create:component
commands.
2.0.0 |
Update for October v2 Aug 31, 2021 |
---|---|
1.2.2 |
Polish translation Jan 23, 2020 |
1.2.1 |
Fix for L5.5 release Sep 12, 2017 |
1.2.0 |
LTS compatibility Aug 08, 2017 |
1.1.2 |
Scan more folders for news translation strings Jul 29, 2016 |
1.1.1 |
OctoberCMS stable release Jul 02, 2016 |
1.1.0 |
!!! Updated code to match OctoberCMS release update (requires build 326 or newer) Apr 21, 2016 |
1.0.17 |
Plugin stub updated to reflect current October version Feb 21, 2016 |
1.0.16 |
Fix the language folders lookup. Now checks only two or three letters folder that are writable. Jan 21, 2016 |
1.0.15 |
Checks for `backend.manage_preferences` to display the settings menu Nov 19, 2015 |
1.0.14 |
Portuguese default translation file Nov 14, 2015 |
1.0.13 |
Scans report widget Oct 09, 2015 |
1.0.12 |
Fix stub on case-sensitive file system Aug 28, 2015 |
1.0.11 |
Fix default settings options to true Aug 24, 2015 |
1.0.10 |
Fix typos in sources comment Aug 15, 2015 |
1.0.9 |
Removed unnecessary trans call in component details stub Aug 15, 2015 |
1.0.8 |
plugin:translate command now also scans models folder Aug 15, 2015 |
1.0.7 |
Improved french translation Aug 13, 2015 |
1.0.6 |
Added a disclaimer comment in overriden command Aug 13, 2015 |
1.0.5 |
Updated documentation for marketplace Aug 13, 2015 |
1.0.4 |
Improved settings description Aug 12, 2015 |
1.0.3 |
Fix controller stub Aug 12, 2015 |
1.0.2 |
Fix delete_confirm default message Aug 11, 2015 |
1.0.1 |
First version of ScaffoldTranslation Aug 11, 2015 |