New in Symfony 5.3: Translation Providers

Contributed by Mathieu Santostefano in #38475.

The process of translating Symfony applications requires extracting all translatable contents from templates and code. This task is boring and error-prone; that’s why Symfony provides a translation:update command to extract contents and update catalogs automatically. This works great, unless your application uses external translation services with their own local or SaaS-based translation tools. Then you need to send them the translation catalogs from time to time to translate the new contents and then merge the returned catalog back into your application. In Symfony 5.3 we’ve improved this workflow thanks to the integration of external translation providers. You can now upload/download translations to services like Crowdin, Loco, Lokalise and PoEditor and merge the new translations automatically into your application. Let’s imagine that you hire a translation company that uses Crowdin to share their work with you. First, configure the access to this provider: 1 2 3 4 5 6 7 8# config/packages/translation.yaml framework: translator: providers: crowdin: dsn: 'crowdin://PROJECT_ID:API_TOKEN@ORGANIZATION_DOMAIN.default' domains: ['messages'] locales: ['en', 'ja']

Now you can upload the current application translations with this command: 1 2 3 4 5 6 7 8# upload all translations for all locales $ php bin/console translation:push crowdin --force

or upload translations only for some locale(s)

$ php bin/console translation:push crowdin --locales ja

or just upload the translations of a particular domain

$ php bin/console translation:push crowdin --domain admin

Similarly, you can download the translations from the external service and let Symfony merge them automatically with the existing translations: 1 2 3 4 5 6# download all translations for all locales $ php bin/console translation:pull crowdin --force

download all translations for 'ja' locale and add the new

translations into the existing file

$ php bin/console translation:pull crowdin --locales ja

Both commands define more flags and options. Run them with the --help option to learn about those options.

                Sponsor the Symfony project.

http://feedproxy.google.com/~r/symfony/blog/~3/t9dIHT2SYpw/new-in-symfony-5-3-translation-providers

Vytvořeno 4y | 21. 5. 2021 7:21:48


Chcete-li přidat komentář, přihlaste se

Ostatní příspěvky v této skupině

A Week of Symfony #955 (April 14–20, 2025)

This week, the upcoming Symfony 7.3 version improved the AsAlias attribute by adding a new argument, introduced Clock support for UriSigner, and refined the return type of the ContainerInterface::get(

20. 4. 2025 8:30:06 | Symfony
SymfonyOnline June 2025: Rethinking File Handling in Symfony

SymfonyOnline June 2025 is almost here, starting in almost 2 months on:

June 10-11: Workshop days. It is possible to attend 1 two-day training or 2 one-day trainings. June 12-13: Online confe

16. 4. 2025 16:30:02 | Symfony
SymfonyLive Paris 2025: Recap and replay!

SymfonyLive Paris 2025 took place three weeks ago — a big thank you to everyone who joined us! The conference was held entirely in French, and now you can relive the best moments: replays, hig

15. 4. 2025 14:50:24 | Symfony
A Week of Symfony #954 (April 7–13, 2025)

This week, Symfony 7.3 entered its "feature freeze" period in preparation for its release at the end of May 2025. Development activity focused on refining and polishing its new features, including a n

13. 4. 2025 9:40:02 | Symfony
SymfonyOnline June 2025: What's New in Symfony 7.3

SymfonyOnline June 2025 is almost here, starting in almost 2 months on:

June 10-11: Workshop days. It is possible to attend 1 two-day training or 2 one-day trainings. June 12-13: Online confe

10. 4. 2025 16:40:34 | Symfony
SymfonyCon Amsterdam 2025: Last days to enjoy early bird tickets!

The international Symfony conference of the year, SymfonyCon Amsterdam 2025, will take place in the Netherlands on November 27 & 28, 2025!

⏳ Early bird registration ends this Wednesday! D

8. 4. 2025 9:10:13 | Symfony
A Week of Symfony #953 (March 31 – April 6, 2025)

This week, the upcoming Symfony 7.3 version entered its feature freeze period to tweak and polish its new features before releasing it at the end of May 2025. In addition, we celebrated the SymfonyLiv

6. 4. 2025 8:30:10 | Symfony