Developed with love by KnpLabs Hire us for your project!
22

translate-bundle

by weglot

Seamless integration of Weglot into your Symfony project.

<!-- logo -->

Symfony Translate Bundle

<!-- tags -->
Latest Stable Version
Maintainability
License

Overview

Seamless integration of Weglot into your Symfony project.

Requirements

  • PHP version 5.5 and later
  • Weglot API Key, starting at free level

Installation

You can install the library 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';

Getting Started

Bundle Register

Symfony 4

Add Weglot bundle in the config/bundles.php:
php
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
// ... Other bundles ...
Weglot\TranslateBundle\WeglotTranslateBundle::class => ['all' => true],
];

Symfony 3 & 2

Add Weglot bundle to app/AppKernel.php file:
php
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
// ... Other bundles ...
new Weglot\TranslateBundle\WeglotTranslateBundle(),
);

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.
yaml
weglot_translate:
api_key: 'YOUR_WEGLOT_API_KEY'
original_language : 'en'
destination_languages:
- '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.

There is also a non-required parameters exclude_blocks where you can list all blocks you don't want to be translated. For example, if I've a block with class "site-name", you've to do as following:
yaml
exclude_blocks:
- .site-name

Optional - Language button

You can add a language button if you're using Twig with function: weglot_translate_render

Two layouts exists:
```twig
<!-- first layout -->
{{ weglot_translate_render(1) }}

<!-- second layout -->
{{ weglot_translate_render(2) }}
```

Examples

You'll find a short README with details about example on each repository

About

translate-bundle is guided and supported by the Weglot Developer Team.

translate-bundle is maintained and funded by Weglot SAS.
The names and logos for translate-bundle are trademarks of Weglot SAS.

License

The MIT License (MIT)

weglot_translate:
api_key: ~ # Required
original_language: ~ # Required
destination_languages: [] # Required
exclude_blocks: []
  • adding SF2 example
    By Korbeil, 3 days ago
  • updating README & CHANGELOG to add SF3 example
    By Korbeil, 3 days ago
  • updating changelog
    By Korbeil, 3 days ago
  • removing Enum for templates & updating README
    By Korbeil, 3 days ago
  • adding backlink on readme
    By Korbeil, 3 days ago
  • updating config file path for SF3 & SF2 in readme
    By Korbeil, 3 days ago
  • Merge branch 'release/0.5' into develop
    By Korbeil, 3 days ago
  • updating twig template call
    By Korbeil, 3 days ago
  • updating readme
    By Korbeil, 3 days ago
  • code cleaning
    By Korbeil, 3 days ago
  • fixing Loader complexity based on codeclimate analysis
    By Korbeil, 3 days ago
  • adding header
    By Korbeil, 3 days ago
  • updating README
    By Korbeil, 3 days ago
  • adding default editor configuration
    By Korbeil, 3 days ago
  • adding codeclimate configuration
    By Korbeil, 3 days ago
  • adding LICENSE file
    By Korbeil, 3 days ago
  • adding code of conduct & contributing
    By Korbeil, 3 days ago
  • adding github files
    By Korbeil, 3 days ago
  • updating composer.json
    By Korbeil, 3 days ago
  • removing version from README
    By Korbeil, 3 days ago
  • updating changelog
    By Korbeil, 3 days ago
  • Merge branch 'feature/new_library_integration' into develop
    By Korbeil, 3 days ago
  • private > protected
    By Korbeil, 3 days ago
  • fixing services config
    By Korbeil, 4 days ago
  • updating Listener/RequestListener with library
    By Korbeil, 4 days ago
  • updating Twig/LanguageCodeExtension with library
    By Korbeil, 4 days ago
  • updating Twig/WeglotButtonExtension with library
    By Korbeil, 4 days ago
  • adding default resources to config
    By Korbeil, 4 days ago
  • adding weglot php library through composer
    By Korbeil, 4 days ago
  • removing old library classes
    By Korbeil, 4 days ago