Sommerregen/grav-plugin-toc

crash for missing translation

Closed this issue · 1 comments

For TOC version v1.3.1

I have activated languages, among these is 'nl'. Even though the toc plugin is not used on the page, processing fails here:

$lang = $language ? [$language]: $this->language;
$replacements = self::getGrav()['language']->translate('PLUGINS.TOC.PATTERNS', $lang, true);

-> $text = preg_replace(array_keys($replacements), $replacements, $text);

It seems because there's no translation for PLUGINS.TOC.PATTERNS. After adding to grav/user/languages/nl.yaml something for PLUGINS.TOC.PATTERNS it passes.

Would it not be better to skip that line if the translation does not exist rather than have a PHP exception? (Or fall back on the default language; but I'm not in favor for this)

This issue is might be related to #13. If there are no $replacements the above line fails. Will check it though before next release more thoroughly.