How to work with I18N in PHP and Symfony?

Asked

Viewed 201 times

0

There is an add-on to Symfony that allows you to work with i18n and . po and . mo or similar or is it really necessary to implement a solution for this? Ideally I could call the translation both on Twig and Controller. If there is one or two options?

1 answer

1


Symfony itself has an internationalization component, and XML or YAML files are used for this. You can still read the translation of a database. Take a look at their documentation regarding:

http://symfony.com/doc/current/book/translation.html

You can use internationalization in both PHP and template files (using Twig). In the first case, after calling the services container internationalization service, just translate so:

$translator->trans('Hi!');

On Twig, just use the filter trans:

{{ "Hi!"|trans }}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.