Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Debrigode committed Feb 5, 2024
1 parent b79da8b commit 96087e8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
1 change: 1 addition & 0 deletions asstats.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions src/Application/ConfigApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public static function getAsStatsConfigTop(): int
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';
}

Expand Down
6 changes: 5 additions & 1 deletion src/Controller/BaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@
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(
Expand Down
4 changes: 1 addition & 3 deletions src/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
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
Expand All @@ -38,12 +37,11 @@ public function index(
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);
Expand Down
8 changes: 4 additions & 4 deletions templates/base/_page_header.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<div class="col">
<div class="list-inline list-inline-dots mb-0 text-secondary d-sm-block d-none">
{% if configapplication_graph('outispositive') %}
<div class="list-inline-item">{{ icon('up') }} Outbound traffic</div>
<div class="list-inline-item">{{ icon('down') }} Inbound traffic</div>
<div class="list-inline-item">{{ icon('up') }} {{ 'outbound traffic'|trans }}</div>
<div class="list-inline-item">{{ icon('down') }} {{ 'inbound traffic'|trans }}</div>
{% else %}
<div class="list-inline-item">{{ icon('up') }} Inbound traffic</div>
<div class="list-inline-item">{{ icon('down') }} Outbound traffic</div>
<div class="list-inline-item">{{ icon('up') }} {{ 'inbound traffic'|trans }}</div>
<div class="list-inline-item">{{ icon('down') }} {{ 'outbound traffic'|trans }}</div>
{% endif %}
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions translations/messages+intl-icu.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ hour: >-
=1 {# hour}
other {# hours}
}
outbound traffic: Outbound traffic
inbound traffic: Inbound traffic

3 changes: 3 additions & 0 deletions translations/messages+intl-icu.fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ hour: >-
=1 {# heure}
other {# heures}
}
outbound traffic: Trafic sortant
inbound traffic: Trafic entrant

0 comments on commit 96087e8

Please sign in to comment.