diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-20 21:16:01 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-20 21:16:01 +0200 |
commit | 576d285ddf1c9b4c78124b90fb902d0a57dd2a00 (patch) | |
tree | 8a19eef9728470995252b3ea92c5a4eb6371d744 /src/Wallabag | |
parent | 166e8cc6a92590177cae7a3e898615f9f3c33962 (diff) | |
download | wallabag-576d285ddf1c9b4c78124b90fb902d0a57dd2a00.tar.gz wallabag-576d285ddf1c9b4c78124b90fb902d0a57dd2a00.tar.zst wallabag-576d285ddf1c9b4c78124b90fb902d0a57dd2a00.zip |
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..
Diffstat (limited to 'src/Wallabag')
-rw-r--r-- | src/Wallabag/CoreBundle/Twig/WallabagExtension.php | 5 |
1 files changed, 4 insertions, 1 deletions
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 | |||
138 | $interval = $user->getCreatedAt()->diff(new \DateTime('now')); | 138 | $interval = $user->getCreatedAt()->diff(new \DateTime('now')); |
139 | $nbDays = (int) $interval->format('%a') ?: 1; | 139 | $nbDays = (int) $interval->format('%a') ?: 1; |
140 | 140 | ||
141 | // force setlocale for date translation | ||
142 | setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage()))); | ||
143 | |||
141 | return $this->translator->trans('footer.stats', [ | 144 | return $this->translator->trans('footer.stats', [ |
142 | '%user_creation%' => $user->getCreatedAt()->format('F jS, Y'), | 145 | '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()), |
143 | '%nb_archives%' => $nbArchives, | 146 | '%nb_archives%' => $nbArchives, |
144 | '%per_day%' => round($nbArchives / $nbDays, 2), | 147 | '%per_day%' => round($nbArchives / $nbDays, 2), |
145 | ]); | 148 | ]); |