nystudio107 / generator-craftplugin

generator-craftplugin is a Yeoman generator for Craft CMS plugins
MIT License
74 stars 30 forks source link

No need to translate log messages #25

Closed brandonkelly closed 7 years ago

brandonkelly commented 7 years ago

This line in a generated plugin:

Craft::info('WmylForms ' . Craft::t('wmylforms', 'plugin loaded'), __METHOD__);

should just be:

Craft::info('WmylForms plugin loaded', __METHOD__);

We've found that translating log messages ends up causing more trouble than it's worth, since it's usually the developer that ends up having to parse the logs, so it's better if it's in their native language.

khalwat commented 7 years ago

Yeah, I put it in there just to show how translations are done in terms of the category to use, etc. Since it's possible people would generate a plugin with no other components, so it seemed like a good place to put it.

I will keep that in mind for other logging stuff tho thx.

brandonkelly commented 7 years ago

OK, well if it's meant to be an example, you should at least update it to use a token for the plugin name (you should never need to concatenate a non-translated string with a translated string when building a single message):

Craft::info(Craft::t('wmylforms', '{name} plugin loaded', ['name' => 'WmylForms']), __METHOD__);

or better yet,

Craft::info(Craft::t('wmylforms', '{name} plugin loaded', ['name' => $this->name]), __METHOD__);
khalwat commented 7 years ago

Gotcha, will do.

khalwat commented 7 years ago

Fixed:

https://github.com/nystudio107/generator-craftplugin/releases/tag/1.2.28