PHPackages                             addweb/gtranslate-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. addweb/gtranslate-bundle

ActiveSymfony-bundle[Localization &amp; i18n](/categories/localization)

addweb/gtranslate-bundle
========================

A Symfony bundle that integrates the GTranslate.io widget, providing a Twig function and configurable service to easily add automatic website translation.

0.1(8mo ago)217[1 issues](https://github.com/AddWebSolution/symfony-gtranslate/issues)MITPHPPHP &gt;=8.1

Since Oct 14Pushed 8mo agoCompare

[ Source](https://github.com/AddWebSolution/symfony-gtranslate)[ Packagist](https://packagist.org/packages/addweb/gtranslate-bundle)[ RSS](/packages/addweb-gtranslate-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (5)Versions (2)Used By (0)

GtranslateBundle
================

[](#gtranslatebundle)

A Symfony 7.x bundle that integrates the [GTranslate.io](https://gtranslate.io) widget.
It provides a Twig function and service to render the GTranslate widget with fully configurable settings — so you don’t need to copy-paste raw `` snippets.

---

🚀 Features
----------

[](#-features)

- Easy integration of the **GTranslate.io** widget.
- Configurable via Symfony config (`config/packages/gtranslate.yaml`).
- Supports all widget variants: **dropdown**, **floating**, **dark floating (`dwf.js`)**.
- Twig function `gtranslate_widget()` to drop the widget anywhere in your templates.
- Optional overrides per call — change languages, script, or wrapper at runtime.
- Unit &amp; integration tests included.

---

📦 Installation
--------------

[](#-installation)

Require the bundle in your Symfony app:

```
composer require addweb/gtranslate-bundle:"*@dev"
```

⚙️ Configuration
----------------

[](#️-configuration)

Create `config/packages/gtranslate.yaml` in your Symfony app:

```
gtranslate:
  script_src: 'https://cdn.gtranslate.net/widgets/latest/dwf.js'
  auto_wrapper: true
  settings:
    default_language: 'en'
    languages: ['en','fr','it','es']
    wrapper_selector: '.gtranslate_wrapper'
    switcher_horizontal_position: 'right'
    switcher_vertical_position: 'top'
    switcher_text_color: '#f7f7f7'
    switcher_arrow_color: '#f2f2f2'
    switcher_border_color: '#161616'
    switcher_background_color: '#303030'
    switcher_background_shadow_color: '#474747'
    switcher_background_hover_color: '#3a3a3a'
    dropdown_text_color: '#eaeaea'
    dropdown_hover_color: '#748393'
    dropdown_background_color: '#474747'
```

- *script\_src* → Which GTranslate script to load (dropdown.js, float.js, dwf.js).
- *settings* → Directly mirrors window.gtranslateSettings.
- *auto\_wrapper* → If true, a

     wrapper is auto-generated based on wrapper_selector.

🖥️ Usage
--------

[](#️-usage)

### Twig

[](#twig)

Add the widget in any template:

```
{# Default (uses bundle config) #}
{{ gtranslate_widget() }}

{# Override script + settings at runtime #}
{{ gtranslate_widget({
  script_src: 'https://cdn.gtranslate.net/widgets/latest/float.js',
  settings: {
    default_language: 'en',
    languages: ['en','hi'],
    switcher_horizontal_position: 'left',
    switcher_vertical_position: 'bottom'
  },
  auto_wrapper: false
}) }}
```

### Controller

[](#controller)

You can render it from a controller as well:

```
