Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Gtranslate Bundle

Gtranslate Bundle Laravel Package

addweb/gtranslate-bundle

Symfony 7 bundle to integrate the GTranslate.io widget without copy‑pasting scripts. Configure via gtranslate.yaml, supports dropdown/float/dwf variants, provides a gtranslate_widget() Twig function with optional per-call overrides for script and settings.

View on GitHub
Deep Wiki
Context7

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

Frequently asked questions about Gtranslate Bundle
Can I use GtranslateBundle in Laravel instead of Symfony?
No, this bundle is Symfony 7-specific and relies on Twig, Symfony’s DI container, and config system. For Laravel, you’d need a custom wrapper or a Laravel-specific package that replicates its functionality (e.g., Blade directives or a service provider).
What Laravel alternatives exist for GTranslate.io integration?
For Laravel, consider packages like `spatie/laravel-translatable` (for backend translations) or manually embed GTranslate.io’s script via Laravel Mix/Vite. Alternatively, explore `laravel-translation-manager` for UI/UX-focused solutions, though none directly mirror this bundle’s Twig integration.
How do I configure GtranslateBundle for production?
Start by defining `gtranslate.yaml` with your GTranslate.io API key and preferred script (e.g., `dwf.js`). Use Symfony’s `%kernel.environment%` or parameter bags to override settings per environment (e.g., disable auto-wrapper in staging). Test with `symfony var:dump-server:env` to validate config loading.
Does GtranslateBundle support dark mode or custom styling?
Yes, the bundle supports all GTranslate.io widget variants, including dark floating (`dwf.js`). Customize styles via the `settings` block in `gtranslate.yaml` (e.g., `switcher_background_color`, `dropdown_text_color`). Override these per-call in Twig if needed.
Will this bundle break if GTranslate.io’s CDN changes?
Potentially. The bundle loads GTranslate.io’s script dynamically, so CDN changes or downtime could disrupt functionality. Mitigate this by implementing a fallback (e.g., local JS cache, static language selectors) or monitoring GTranslate.io’s status via their API or third-party tools like UptimeRobot.
How do I test GtranslateBundle in a CI pipeline?
Use Symfony’s `WebTestCase` to verify the Twig function renders correctly. Mock the GTranslate.io script by intercepting network requests in tests (e.g., with `Symfony Panther` or `GuzzleHttpHandler`). Test edge cases like missing config or invalid script URLs by temporarily breaking `gtranslate.yaml`.
Can I override widget settings per route or template?
Yes. Use the Twig function’s optional arguments to override settings at runtime, such as `{{ gtranslate_widget({ settings: { languages: ['en', 'fr'] } }) }}`. For route-specific overrides, pass dynamic data via Symfony’s `twig` extension or a controller service.
Does this bundle work with Symfony 6 or older versions?
No, this bundle explicitly targets Symfony 7.x. For older versions, check if a compatible fork exists or assess the effort to backport dependencies (e.g., Twig 3.x, Symfony Config). Alternatively, manually embed GTranslate.io’s script in your templates.
How do I handle caching for the GTranslate.io script?
Leverage Symfony’s HTTP cache or a CDN (e.g., Cloudflare) to cache the GTranslate.io script. For local caching, use Symfony’s `HttpCache` or a reverse proxy like Nginx. Avoid inline script caching, as it may conflict with dynamic language overrides.
What’s the performance impact of loading GTranslate.io’s script?
The script adds ~50–150KB to page load, depending on the widget type. Test with Lighthouse or WebPageTest to measure impact on Core Web Vitals. Mitigate latency by loading the script asynchronously or deferring it until after page render. Consider lazy-loading the widget on non-critical pages.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope