Fix Hook::registerPluginTransScripts method
This commit is contained in:
parent
60a24c03b0
commit
1f63e2d24b
|
|
@ -57,14 +57,25 @@ class Hook
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function registerPluginTransScripts($id, $pages = ['*'], $priority = 1)
|
public static function registerPluginTransScripts($id, $pages = ['*'], $priority = 999)
|
||||||
{
|
{
|
||||||
$basepath = plugin($id)->getPath().'/';
|
Event::listen(Events\RenderingFooter::class, function ($event) use ($id, $pages) {
|
||||||
$relative = 'lang/'.config('app.locale').'/locale.js';
|
foreach ($pages as $pattern) {
|
||||||
|
if (! app('request')->is($pattern))
|
||||||
|
continue;
|
||||||
|
|
||||||
if (file_exists($basepath.$relative)) {
|
// We will determine current locale in the event callback,
|
||||||
static::addScriptFileToPage(plugin_assets($id, $relative), $pages, $priority);
|
// otherwise the locale is not properly detected.
|
||||||
}
|
$basepath = plugin($id)->getPath().'/';
|
||||||
|
$relative = 'lang/'.config('app.locale').'/locale.js';
|
||||||
|
|
||||||
|
if (file_exists($basepath.$relative)) {
|
||||||
|
$event->addContent('<script src="'.plugin_assets($id, $relative).'"></script>');
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}, $priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addStyleFileToPage($urls, $pages = ['*'], $priority = 1)
|
public static function addStyleFileToPage($urls, $pages = ['*'], $priority = 1)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user