From 576d285ddf1c9b4c78124b90fb902d0a57dd2a00 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 21:16:01 +0200 Subject: [PATCH] Translate date I use a kind of hacky way to convert the user locale (defined with 2 letters, like `fr`) into a local with 5 letters (like `fr_FR`). I guess it should work on most of the case.. --- src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php index 783cde3e..a305c53f 100644 --- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php +++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php @@ -138,8 +138,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa $interval = $user->getCreatedAt()->diff(new \DateTime('now')); $nbDays = (int) $interval->format('%a') ?: 1; + // force setlocale for date translation + setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage()))); + return $this->translator->trans('footer.stats', [ - '%user_creation%' => $user->getCreatedAt()->format('F jS, Y'), + '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()), '%nb_archives%' => $nbArchives, '%per_day%' => round($nbArchives / $nbDays, 2), ]); -- 2.41.0