diff --git a/asstats.yml b/asstats.yml index 404d1c0..0cbcd9e 100644 --- a/asstats.yml +++ b/asstats.yml @@ -1,4 +1,5 @@ config: + language: 'fr' top: 20 daystatsfile: '/home/nidebr/data/DEV/asstats/stats/asstats_day.txt' knownlinksfile: '/home/nidebr/data/DEV/asstats/conf/knownlinks' diff --git a/src/Application/ConfigApplication.php b/src/Application/ConfigApplication.php index 159c9f4..50c7bbb 100644 --- a/src/Application/ConfigApplication.php +++ b/src/Application/ConfigApplication.php @@ -66,9 +66,9 @@ class ConfigApplication return self::getAsStatsConfig()['top']; } - public static function getLangage(): string + public static function getLanguage(): string { - if (false === \array_key_exists('langage', self::getAsStatsConfig())) { + if (false === \array_key_exists('language', self::getAsStatsConfig())) { return 'en'; } diff --git a/src/Controller/BaseController.php b/src/Controller/BaseController.php index 62f25a8..6f78d22 100644 --- a/src/Controller/BaseController.php +++ b/src/Controller/BaseController.php @@ -11,21 +11,25 @@ use Symfony\Component\Form\FormView; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Translation\LocaleSwitcher; +use Symfony\Contracts\Translation\TranslatorInterface; abstract class BaseController extends AbstractController { protected ConfigApplication $configApplication; + protected TranslatorInterface $translator; protected array $base_data = []; public function __construct( ConfigApplication $configApplication, RequestStack $requestStack, LocaleSwitcher $localeSwitcher, + TranslatorInterface $translator, ) { $this->configApplication = $configApplication; $this->base_data = self::getBaseData($requestStack); + $this->translator = $translator; - $localeSwitcher->setLocale($this->configApplication::getLangage()); + $localeSwitcher->setLocale($this->configApplication::getLanguage()); } private function getBaseData( diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index eb037e5..c3eee36 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -16,7 +16,6 @@ use Doctrine\DBAL\Exception; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; -use Symfony\Contracts\Translation\TranslatorInterface; #[Menu('top_as')] class IndexController extends BaseController @@ -38,12 +37,11 @@ class IndexController extends BaseController Request $request, GetAsDataRepository $asDataRepository, GetStartEndGraph $getStartEndGraph, - TranslatorInterface $translator, ): Response { $this->base_data['content_wrapper']['titre'] = \sprintf( 'Top %s (%s)', $this->base_data['top'], - $translator->trans('hour', ['num_hours' => 24]), + $this->translator->trans('hour', ['num_hours' => 24]), ); $form = $this->createForm(LegendForm::class); diff --git a/templates/base/_page_header.html.twig b/templates/base/_page_header.html.twig index e1a5d27..bc6587a 100644 --- a/templates/base/_page_header.html.twig +++ b/templates/base/_page_header.html.twig @@ -17,11 +17,11 @@