Translations can be done with both the trans tag and the trans filter.
The filter is less powerful as it only works for simple variables or strings.
For more complex scenario, like pluralization, you can use a two-step
strategy:

{# assign the translation to a temporary variable #}{%setdefault_value%}{%trans%} Hey {{name}}, I have one apple.{%pluralapple_count%} Hey {{name}}, I have {{count}} apples.{%endtrans%}{%endset%}{# use the temporary variable within an expression #}{{var|default(default_value|trans)}}

Unfortunately, the xgettext utility does not understand Twig templates
natively and neither do tools based on it such as free versions of Poedit.
But there is a simple workaround: as Twig converts templates to
PHP files, you can use xgettext on the template cache instead.

Create a script that forces the generation of the cache for all your
templates. Here is a simple example to get you started: