mirror of
https://github.com/flarum/framework.git
synced 2024-11-30 21:44:12 +08:00
Fix locale JS files not being added; add (temporary?) API to add locale CSS files
fixes flarum/core#970
This commit is contained in:
parent
7a7649ec7f
commit
9059b7ad79
|
@ -63,6 +63,10 @@ class ConfigureLocales
|
|||
$this->locales->addJsFile($locale, $file);
|
||||
}
|
||||
|
||||
if (file_exists($file = $localeDir.'/config.css')) {
|
||||
$this->locales->addCssFile($locale, $file);
|
||||
}
|
||||
|
||||
foreach (new DirectoryIterator($localeDir) as $file) {
|
||||
if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) {
|
||||
$this->locales->addTranslations($locale, $file->getPathname());
|
||||
|
|
|
@ -159,6 +159,14 @@ class WebAppView
|
|||
$locale = $this->locales->getLocale();
|
||||
$this->localeJs = $this->assets->getLocaleJs($locale);
|
||||
$this->localeCss = $this->assets->getLocaleCss($locale);
|
||||
|
||||
foreach ($this->locales->getJsFiles($locale) as $file) {
|
||||
$this->localeJs->addFile($file);
|
||||
}
|
||||
|
||||
foreach ($this->locales->getCssFiles($locale) as $file) {
|
||||
$this->localeCss->addFile($file);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,6 +23,8 @@ class LocaleManager
|
|||
|
||||
protected $js = [];
|
||||
|
||||
protected $css = [];
|
||||
|
||||
/**
|
||||
* @param SymfonyTranslator $translator
|
||||
*/
|
||||
|
@ -79,6 +81,24 @@ class LocaleManager
|
|||
return $files;
|
||||
}
|
||||
|
||||
public function addCssFile($locale, $css)
|
||||
{
|
||||
$this->css[$locale][] = $css;
|
||||
}
|
||||
|
||||
public function getCssFiles($locale)
|
||||
{
|
||||
$files = array_get($this->css, $locale, []);
|
||||
|
||||
$parts = explode('-', $locale);
|
||||
|
||||
if (count($parts) > 1) {
|
||||
$files = array_merge(array_get($this->css, $parts[0], []), $files);
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SymfonyTranslator
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue
Block a user