mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-24 00:20:28 +00:00
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..
This commit is contained in:
parent
166e8cc6a9
commit
576d285ddf
1 changed files with 4 additions and 1 deletions
|
@ -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),
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue