How do you create custom translation domains in Symfony?

How do you create custom translation domains in Symfony?

Minimal Steps to Create Custom Translation Domains in Symfony:

  1. Define Custom Domain in Controller:

Example

<?php
$this->addFlash('success', $this->translator->trans('message.success', [], 'custom_domain'));
?>

Create Translation Files:

  • translations/messages.custom_domain.en.yaml:

Example

message:
  success: 'Operation was successful!'

translations/messages.custom_domain.fr.yaml:

Example

message:
  success: 'L\'opération a réussi !'

Use Custom Domain in Twig Template:

Example

{{ 'message.success' | trans({}, 'custom_domain') }}

Related Questions & Topics

Powered and designed by igetvapeaustore.com | © 2024 codestap.com.