Translate your Symfony website into multiple languages

This section shows how to integrate Weglot to your Symfony website and translate your Symfony website. It's quick and easy to make your Symfony website multilingual.

1) Installation

You can install the Symfony via Composer. Run the following command:

composer require weglot/translate-bundle

To use the library, use Composer's autoload:

require_once __DIR__. '/vendor/autoload.php';

2) Register bundle

On Symfony 4, add Weglot bundle in the config/bundles.php

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    // ... Other bundles ...
    Weglot\TranslateBundle\WeglotTranslateBundle::class => ['all' => true],

On Symfony 2 & 3, add Weglot bundle in the config/AppKernel.php

$bundles = array(
    new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
    // ... Other bundles ...
    new Weglot\TranslateBundle\WeglotTranslateBundle(),

3) Configuration

For Symfony 4, create configuration file under config/packages/weglot_translate.yml and add following content. For Symfony 3 & 2, add following content to your app/config/config.yml.

    api_key: 'YOUR_WEGLOT_API_KEY'
    original_language: 'en'
    cache: false
        - 'fr'
        - 'de'

This is an example of configuration, enter your own API key, your original language and destination languages that you want.

  • api_key : is your personal API key. You can get an API Key by signing up on Weglot.
  • original_language : original language is the language of your website before translation.
  • destination_languages : are the languages that you want your website to be translated into.
  • cache : if you wanna use cache or not. It's not a required field and set as false by default.

4) Check additional resources

You can find more resources about what you can do with the Symfony bundle in our developer space.