]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Translate date
authorJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 20 Oct 2016 19:16:01 +0000 (21:16 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Thu, 20 Oct 2016 19:16:01 +0000 (21:16 +0200)
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

index 783cde3e70897aedb877f45f8ad0562a5b68cc9b..a305c53fc1819a50733746578b9bd30792ab66ef 100644 (file)
@@ -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),
         ]);