Components views are not scanned for messages
mplodowski opened this issue · 3 comments
mplodowski commented
It seems like plugin components views are not scanned for translated messages.
public function scanForMessages()
{
$this->scanThemeConfigForMessages();
$this->scanThemeTemplatesForMessages();
$this->scanMailTemplatesForMessages();
// todo scan components for messages
}
mplodowski commented
This code seems to work, but I don't know if this will work for all cases.
Event::listen('rainlab.translate.themeScanner.afterScan', function (ThemeScanner $scanner) {
$messages = [];
$manager = ComponentManager::instance();
foreach ($manager->listComponents() as $componentClass) {
$componentObj = $manager->makeComponent($componentClass);
$partial = ComponentPartial::load($componentObj, 'default');
if ($partial) {
$messages = array_merge($messages, $scanner->parseContent($partial->content));
}
}
Message::importMessages($messages);
});
daftspunk commented
We can include this in addition to the other checks. However, it won't cover partials inside the components directory other than the default one. Most components should strive to be encapsulated in a single template, this makes them easy to override, so this proposal is helpful to include.
samgeorges commented
Added this in 8c66aeb