2017 © Pedro Peláez
 

symfony-bundle translate-bundle

Seamless integration of Weglot into your Symfony project

image

weglot/translate-bundle

Seamless integration of Weglot into your Symfony project

  • Tuesday, July 10, 2018
  • by Shked0wn
  • Repository
  • 4 Watchers
  • 8 Stars
  • 768 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 29 Versions
  • 194 % Grown

The README.md

, (*1)

Symfony Translate Bundle

WeglotSlack Latest Stable Version Maintainability License, (*2)

Overview

Seamless integration of Weglot into your Symfony project., (*3)

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:, (*4)

composer require weglot/translate-bundle

When you require the bundle with symfony/flex (available for symfony/symfony:^4.0) it should ask you if you wanna execute a recipe, tell yes. Like that it will make bundle registration in config/bundles.php & default config creation in config/packages/weglot_translate.yaml., (*5)

To use the library, use Composer's autoload:, (*6)

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

Getting Started

Bundle Register

Symfony 4

Add Weglot bundle in the config/bundles.php:, (*7)

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:, (*8)

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

Quick configuration

For Symfony 4, create configuration file under config/packages/weglot_translate.yaml and add following content. For Symfony 3 & 2, add following content to your app/config/config.yaml., (*9)

weglot_translate:
    api_key: '%env(WG_API_KEY)%'
    original_language : 'en'
    cache: true
    destination_languages:
        - 'fr'
        - 'de'

This is the default configuration file, if you want more default, check next part., (*10)

Configuration

As already said, depending on Symfony version, we've different configuration file paths: - Symfony 4: config/packages/weglot_translate.yaml - Symfony 3 & 2: app/config/config.yaml, (*11)

There is a full configuration file:, (*12)

weglot_translate:
  api_key: '%env(WG_API_KEY)%'
  original_language : 'en'
  cache: false
  destination_languages:
    - 'fr'
    - 'de'
  exclude_blocks:
    - '.material-icons'

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. Look at Caching part for more details., (*13)

There is also a non-required parameters: - exclude_blocks : You can list here all blocks you don't want to be translated. In this example, we won't translate all DOM tags with "material-icons" class., (*14)

Twig extensions

Hreflang links are a way to describe your website and to tell webcrawlers (such as search engines) if this page is available in other languages. More details on Google post about hreflang: https://support.google.com/webmasters/answer/189077, (*15)

You can add them through the Twig function: weglot_hreflang_render, (*16)

Just put the function at the end of your <head> tag:, (*17)

<html>
    <head>
        ...

        {{ weglot_hreflang_render() }}
    </head>

Language button

You can add a language button if you're using Twig with function: weglot_translate_render, (*18)

Two layouts exists:, (*19)


{{ weglot_translate_render(1) }}


{{ weglot_translate_render(2) }}

Language code

Simple filter to convert ISO 639-1 code to full language name. It can takes one boolean parameter that allow you to choose having english name or original language name., (*20)

Here is some examples:, (*21)


{{ 'bg' | language }}


{{ 'bg' | language(false) }}

Caching

We implemented usage of cache pool service for both Symfony 4 and Symfony 3 (symfony/cache bundle was released with Symfony 3, so there is no compatibility for Symfony 2)., (*22)

If you wanna use cache, just add cache: true to this bundle configuration. It will use a file-based cache through Symfony cache.system service., (*23)

To clear the cache, you just have to use the usual pool clear command:, (*24)

$ php bin/console cache:pool:clear weglot_translate.cache

Examples

You'll find a short README with details about example on each repository, (*25)

  • Symfony 4: https://github.com/weglot/translate-bundle-example-sf4
  • Symfony 3: https://github.com/weglot/translate-bundle-example-sf3
  • Symfony 2: https://github.com/weglot/translate-bundle-example-sf2

About

translate-bundle is guided and supported by the Weglot Developer Team., (*26)

translate-bundle is maintained and funded by Weglot SAS. The names and logos for translate-bundle are trademarks of Weglot SAS., (*27)

License

The MIT License (MIT), (*28)

The Versions

10/07 2018

dev-develop

dev-develop https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT proprietary

The Requires

 

by Floran Pagliai
by Remy Berda
by Baptiste Leduc

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

10/07 2018

dev-master

9999999-dev https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

10/07 2018

0.7.2

0.7.2.0 https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

10/07 2018

dev-feature/api-host-optional-param

dev-feature/api-host-optional-param https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

05/07 2018

0.7.1

0.7.1.0 https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

31/05 2018

0.7.0

0.7.0.0 https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

31/05 2018

dev-feature/using-symfony-cache-pool

dev-feature/using-symfony-cache-pool https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

31/05 2018

dev-feature/twig-compiler-implementation

dev-feature/twig-compiler-implementation https://weglot.com/

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

php symfony2 symfony3 symfony translation translator i18n localization languages translate weglot symfony4 weglot-integration

24/05 2018

0.6.11

0.6.11.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

23/05 2018

0.6.10

0.6.10.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

15/05 2018

0.6.9

0.6.9.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

15/05 2018

0.6.8

0.6.8.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

07/05 2018

0.6.7

0.6.7.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

07/05 2018

0.6.6

0.6.6.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

07/05 2018

0.6.5

0.6.5.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

07/05 2018

0.6.4

0.6.4.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

26/04 2018

0.6.3

0.6.3.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

25/04 2018

0.6.2

0.6.2.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

24/04 2018

0.6.1

0.6.1.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

24/04 2018

0.6

0.6.0.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

17/04 2018

0.5

0.5.0.0

Seamless integration of Weglot into your Symfony project

  Sources   Download

MIT

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

06/04 2018

0.4

0.4.0.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

06/04 2018

0.3.2

0.3.2.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

06/04 2018

0.3.1

0.3.1.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

05/04 2018

0.3

0.3.0.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

07/03 2018

0.2

0.2.0.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

05/03 2018

dev-4-rework-for-_locale-compatibility

dev-4-rework-for-_locale-compatibility

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

13/02 2018

0.1.2

0.1.2.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot

13/12 2017

0.1.1

0.1.1.0

TODO

  Sources   Download

proprietary

The Requires

 

by Floran Pagliai
by Remy Berda

translation localization languages translate weglot