Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create:plugin command to include languages scaffold #2833

Closed
CptMeatball opened this issue Apr 20, 2017 · 20 comments
Closed

create:plugin command to include languages scaffold #2833

CptMeatball opened this issue Apr 20, 2017 · 20 comments

Comments

@CptMeatball
Copy link
Contributor

CptMeatball commented Apr 20, 2017

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
@daftspunk
Copy link
Member

Possibly solved by this plugin: https://octobercms.com/plugin/bnb-scaffoldtranslation

@LukeTowers
Copy link
Contributor

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

@daftspunk
Copy link
Member

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

@LukeTowers
Copy link
Contributor

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

@daftspunk
Copy link
Member

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

@Samuell1
Copy link
Member

Samuell1 commented Jul 3, 2019

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

@LukeTowers
Copy link
Contributor

@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.

@Samuell1
Copy link
Member

Samuell1 commented Jul 15, 2019

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.

bennothommo pushed a commit to octobercms/library that referenced this issue Aug 19, 2019
@github-actions
Copy link

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.

@LukeTowers
Copy link
Contributor

@Samuell1 stub files now support Twig

@github-actions
Copy link

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.

@LukeTowers
Copy link
Contributor

@Samuell1 @CptMeatball is this still desired?

@Samuell1
Copy link
Member

@LukeTowers Yeah

@github-actions
Copy link

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.

@github-actions
Copy link

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.

@github-actions
Copy link

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.

@LukeTowers
Copy link
Contributor

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

@Samuell1
Copy link
Member

@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.

@LukeTowers
Copy link
Contributor

@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.

@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

6 participants