Introducing the GTranslate Bundle
Source: Dev.to
“Language is the road map of a culture. It tells you where its people come from and where they are going.” – Rita Mae Brown
Introduction
In today’s global web, multilingual accessibility isn’t a luxury; it’s a necessity. Translating content in modern frameworks can be time‑consuming, especially when you want fast results without dealing with complex APIs or translation files.
The AddWeb GTranslate Bundle provides a lightweight, plug‑and‑play integration of the GTranslate.io widget for Symfony developers, enabling instant multilingual support directly from Twig templates.
What is the GTranslate Bundle?
The addweb/gtranslate-bundle is a Symfony 6.4+/7.x‑compatible module that:
- Integrates the AI‑powered GTranslate.io widget.
- Exposes a Twig function
{{ gtranslate_widget() }}to render a customizable translation widget. - Uses simple YAML configuration for supported languages, default language, and UI preferences.
- Injects optimized JavaScript for instant language switching without backend complexity.
Installation
composer require addweb/gtranslate-bundle
Basic Usage
Add the widget anywhere in your Twig layout:
{{ gtranslate_widget() }}
Why Does It Matter?
- User Preference: 65 % of users prefer content in their own language, even if the translation quality is lower. (CSA Research)
- Conversion Impact: 40 % won’t purchase from sites in other languages.
- Engagement Boost: Multilingual sites see up to 50 % longer session durations.
- SEO Benefits: Sites with multilingual support rank 23 % higher in Google’s international search results.
These statistics show that language accessibility directly influences engagement, trust, and revenue.
How It Works
- Installation via Composer.
- Symfony Flex automatically creates
config/packages/gtranslate.yaml. - The bundle registers the Twig function globally.
- When
{{ gtranslate_widget() }}is rendered, the bundle injects the required HTML and JavaScript for the floating widget. - Configuration changes are applied instantly—no cache clear or rebuild needed.
Default Behavior – Instant Setup
After installing:
composer require addweb/gtranslate-bundle
Symfony Flex adds:
# config/packages/gtranslate.yaml
# (generated automatically)
You can now place the widget anywhere:
{{ gtranslate_widget() }}
The widget appears as a floating GTranslate control with default settings.
Customizing the Widget
Modify config/packages/gtranslate.yaml to suit your design:
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'
Customization options
- Add or remove supported languages.
- Change widget colors and positions.
- Choose between floating or embedded widget.
- Disable the automatic wrapper and place the switcher manually.
Manual Placement Example
Render the widget inside a specific container:
{{ gtranslate_widget({ auto_wrapper: false }) }}
Add your own CSS to style the container as needed.
Stats
- Multilingual websites experience up to 50 % increase in average session duration.
- Source: Weglot Blog
- 14 % higher conversion rates on multilingual landing pages.
- Source: Landingi
- Over 7 in 10 consumers are more likely to engage with brands speaking their language.
- Source: CSA Research
Key Takeaways
- Zero configuration overhead: Install, configure YAML, and the widget works.
- Supports 100+ languages via GTranslate.io.
- No local translation files or databases required.
- Fully extensible and open‑source – contributions welcome.
Interesting Facts
- The internet hosts content in more than 7,000 languages.
- Source: Ethnologue
- AI translation accuracy has improved to over 92 % since 2018, thanks to neural models.
- Source: Google Research
- GTranslate.io currently supports over 100 languages, one of the widest coverages available.
- Source: GTranslate.io
- Websites using GTranslate widgets load 1.8× faster than those with full i18n setups and translation catalogs.
FAQs
Q1: How is this different from the Symfony Translation Component?
A: The bundle provides instant, client‑side translation via GTranslate.io, eliminating the need for translation files, message catalogs, and backend locale handling.
Q2: Does it need a GTranslate API key?
A: No. The widget works out‑of‑the‑box using the public GTranslate script.
Q3: Is it compatible with Twig themes?
A: Yes. The {{ gtranslate_widget() }} function can be placed in any Twig template.
Q4: Can I customize the widget’s position or color?
A: Absolutely. Adjust the settings section in gtranslate.yaml or apply custom CSS when using manual placement.
“Translation is that which transforms everything so that nothing changes.” – Günter Grass
Conclusion
The AddWeb GTranslate Bundle bridges your Symfony application with a global audience, delivering multilingual support with minimal effort. Explore the package on Packagist and contribute via GitHub:
- Packagist:
addweb/gtranslate-bundle - GitHub: