October: create:plugin command to include languages scaffold

Created on 20 Apr 2017  路  20Comments  路  Source: octobercms/october

When creating plugins with the create:plugin artisan command, it creates a number of files to start working on your own plugin. Currently the command creates two files updates/version.yaml and plugin.php with the correct name spacing etc.

To increase the quality and extensibility of all new plugins this command should also include a language directory with the default's locale language file (lang/{locale}/lang.php).

The advantage of this approach is that plugins that use this can be easily extended without being modified. People just need to add the language files for their locales and make a PR in the repo. It's easier for the author, third party developers and most importantly it should give end users a more solid user experience in the long run as well.

Changes in the current scaffold

Currently, the scaffold generates placeholder names and descriptions for in plugin.php . These need to be changed to support the default use of the language file.

Plugin.php

public function pluginDetails()
{
    return [
     -->'name'        => '{author}.{plugin}::lang.plugin.name', 
     -->'description' => '{author}.{plugin}::lang.plugin.description',
        'author'      => '{author}',
        'icon'        => 'icon-leaf'
    ];
}

public function registerNavigation()
{
    return []; // Remove this line to activate

    return [
        '{plugin}' => [
         -->'label'       => '{author}.{plugin}::lang.plugin.name',
            'url'         => Backend::url('{author}/{plugin}/mycontroller'),
            'icon'        => 'icon-leaf',
            'permissions' => ['{author}.{plugin}.*'],
            'order'       => 500,
        ],
    ];
}

Additions to the current scaffold

lang/{locale}/lang.php

return [
    'plugin' => [
        'name' => '{plugin}',
        'description' => '{translated description text}'
]

Caveats

Default locale

When generating a plugin with language files, the OctoberCMS default language should be taken into account. In /config/cms.php the default language for the CMS is set. This language can be used as the default when generating the language directory.

Language file markup

A standard set of language files has to be included to generate the correct placeholder text for the description as this is the only "real text" that is generated by the current command. This means that for all of the possible languages the string No description has been provided yet... should be added in the translation of October.

Expected/Current Behaviour

Expected behavior

$ php artisan create:plugin acme.corporation

Bootstraps plugin directory with:

lang/{default_locale}/lang.php
updates/version.yaml
plugin.php

Actual behavior

$ php artisan create:plugin acme.corporation

Bootstraps plugin directory with:

updates/version.yaml
plugin.php
Low Accepted Archived Conceptual Enhancement help wanted

All 20 comments

Any reason why we couldn't look at merging the changes into core?

This has been discussed before. Languages are not supported by default for accessibility reasons, including it makes the output look too scary for beginners.

How about enabling it as a flag passed to the create:plugin scaffolding command?

Totally on board with that idea so long as the default is non translated scaff.

@LukeTowers can this same be done for create:controller command?

@Samuell1 sure. I don't have the time to implement it myself right now unless someone wants to sponsor it but feel free to go for it.

After searching there is no way to use if statements in stub files. Then this needs to be created in one or in 2 separate files. Maybe moving stub files to twig parse will be better idea.

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.

@Samuell1 stub files now support Twig

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.

@Samuell1 @CptMeatball is this still desired?

@LukeTowers Yeah

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days.

  • If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue. - If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

@Samuell1 you interested in submitting a PR for a flag to add this?

@LukeTowers Yes i am but it will take a lot of time to rework all scafollding files. But now i dont have time to do it.

@Samuell1 all right. I'll leave it open for now, but we'll close it the next time the github bot comments in a month and then we can re-open it when you have time to implement it.

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

Was this page helpful?
0 / 5 - 0 ratings