[TWIG] Implement transchoice for ICU plural translations

This commit is contained in:
Diogo Peralta Cordeiro 2022-02-27 00:36:26 +00:00
parent d4c908c194
commit 2f539d176d
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 7 additions and 0 deletions

View File

@ -79,6 +79,7 @@ class Extension extends AbstractExtension
new TwigFunction('open_details', [Runtime::class, 'openDetails']),
new TwigFunction('show_stylesheets', [Runtime::class, 'getShowStylesheets']),
new TwigFunction('add_right_panel_block', [Runtime::class, 'addRightPanelBlock']),
new TwigFunction('transchoice', [Runtime::class, 'transchoice']),
];
}
}

View File

@ -33,6 +33,7 @@ declare(strict_types = 1);
namespace App\Twig;
use App\Core\Event;
use function App\Core\I18n\_m;
use App\Core\Router\Router;
use App\Entity\Actor;
use App\Entity\Feed;
@ -56,6 +57,11 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
$this->request = $req;
}
public function transchoice(array $message, int $count): string
{
return _m($message, ['count' => $count]);
}
public function isCurrentRouteActive(string ...$routes): string
{
return $this->isCurrentRoute('active', ...$routes);