Download the PHP package weglot/translate-bundle without Composer
On this page you can find all versions of the php package weglot/translate-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weglot/translate-bundle
More information about weglot/translate-bundle
Files in weglot/translate-bundle
Package translate-bundle
Short Description Seamless integration of Weglot into your Symfony project
License MIT
Homepage https://weglot.com/
Informations about the package translate-bundle
Symfony Translate Bundle
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:
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
.
To use the library, use Composer's autoload:
Getting Started
Bundle Register
Symfony 4
Add Weglot bundle in the config/bundles.php
:
Symfony 3 & 2
Add Weglot bundle to app/AppKernel.php
file:
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
.
This is the default configuration file, if you want more default, check next part.
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
There is a full configuration file:
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.
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.
Twig extensions
Hreflang links
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
You can add them through the Twig function: weglot_hreflang_render
Just put the function at the end of your <head>
tag:
Language button
You can add a language button if you're using Twig with function: weglot_translate_render
Two layouts exists:
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.
Here is some examples:
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).
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.
To clear the cache, you just have to use the usual pool clear command:
Examples
You'll find a short README with details about example on each repository
- 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.
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)