This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

UpTop
UpTop

Can also be found here: https://github.com/octobercms/october/issues/2833

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
lunfel
lunfel

I agree with that!

alxy
alxy

This can be soled by a plugin

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.