mirror of
https://github.com/flarum/framework.git
synced 2025-06-16 23:12:22 +08:00
Using Core Translator in Locale Manager, type hinted its methods and removed unnecessary phpdoc
This commit is contained in:
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
namespace Flarum\Locale;
|
namespace Flarum\Locale;
|
||||||
|
|
||||||
use Illuminate\Contracts\Translation\Translator;
|
|
||||||
|
|
||||||
class LocaleManager
|
class LocaleManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -26,52 +24,49 @@ class LocaleManager
|
|||||||
|
|
||||||
protected $css = [];
|
protected $css = [];
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Translator $translator
|
|
||||||
*/
|
|
||||||
public function __construct(Translator $translator)
|
public function __construct(Translator $translator)
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocale()
|
public function getLocale(): string
|
||||||
{
|
{
|
||||||
return $this->translator->getLocale();
|
return $this->translator->getLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setLocale($locale)
|
public function setLocale(string $locale)
|
||||||
{
|
{
|
||||||
$this->translator->setLocale($locale);
|
$this->translator->setLocale($locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addLocale($locale, $name)
|
public function addLocale(string $locale, string $name)
|
||||||
{
|
{
|
||||||
$this->locales[$locale] = $name;
|
$this->locales[$locale] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLocales()
|
public function getLocales(): array
|
||||||
{
|
{
|
||||||
return $this->locales;
|
return $this->locales;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasLocale($locale)
|
public function hasLocale(string $locale): bool
|
||||||
{
|
{
|
||||||
return isset($this->locales[$locale]);
|
return isset($this->locales[$locale]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addTranslations($locale, $file, $module = null)
|
public function addTranslations(string $locale, $file, string $module = null)
|
||||||
{
|
{
|
||||||
$prefix = $module ? $module.'::' : '';
|
$prefix = $module ? $module.'::' : '';
|
||||||
|
|
||||||
$this->translator->addResource('prefixed_yaml', compact('file', 'prefix'), $locale);
|
$this->translator->addResource('prefixed_yaml', compact('file', 'prefix'), $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addJsFile($locale, $js)
|
public function addJsFile(string $locale, string $js)
|
||||||
{
|
{
|
||||||
$this->js[$locale][] = $js;
|
$this->js[$locale][] = $js;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getJsFiles($locale)
|
public function getJsFiles(string $locale): array
|
||||||
{
|
{
|
||||||
$files = array_get($this->js, $locale, []);
|
$files = array_get($this->js, $locale, []);
|
||||||
|
|
||||||
@ -84,12 +79,12 @@ class LocaleManager
|
|||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addCssFile($locale, $css)
|
public function addCssFile(string $locale, string $css)
|
||||||
{
|
{
|
||||||
$this->css[$locale][] = $css;
|
$this->css[$locale][] = $css;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCssFiles($locale)
|
public function getCssFiles(string $locale): array
|
||||||
{
|
{
|
||||||
$files = array_get($this->css, $locale, []);
|
$files = array_get($this->css, $locale, []);
|
||||||
|
|
||||||
@ -102,18 +97,12 @@ class LocaleManager
|
|||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function getTranslator(): Translator
|
||||||
* @return SymfonyTranslator
|
|
||||||
*/
|
|
||||||
public function getTranslator()
|
|
||||||
{
|
{
|
||||||
return $this->translator;
|
return $this->translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function setTranslator(Translator $translator)
|
||||||
* @param SymfonyTranslator $translator
|
|
||||||
*/
|
|
||||||
public function setTranslator(SymfonyTranslator $translator)
|
|
||||||
{
|
{
|
||||||
$this->translator = $translator;
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user