Translate the frontend¶
The Translation Manager ships with a handy command to translate source code using an automatic translation service such as Google. It relies on the ibexa/automated-translation bundle to connect to the API provided by such services.
Usage¶
Usage examples¶
Use Google API to translate all English XLIFF files in the project to German (includes project bundles but excludes vendors):
console xrow:translate --from=en --to=de --service=google src translations --verbose
Use Google API to translate all US English XLIFF files in bundles provided by acme
to German:
console xrow:translate --from=en_US --to=de --service=google vendor/acme --verbose
Use Google API to translate the XLIFF files in the bundle acme/awesome-bundle
from English to German:
console xrow:translate --from=en --to=de --service=google vendor/acme/awesome-bundle --verbose
Use Google API to translate all project translations from English to German, French and Spanish (excludes project bundles and vendors):
console xrow:translate --from=en --to=de,fr,es --service=google --verbose
(Explanation: when no directories are specified on the command line only the translations
folder is translated).
Other options¶
Disable automatic git commits¶
By default the xrow:translate
command always commits its changes to the relevant git repositories.
The developer should then review the commits for each repository and push them.
To disable the automatic git commit functionality add the option --no-commits
. For example:
console xrow:translate --from=en --to=de,fr,es --service=google --no-commits --verbose
If you want to commit new translations for bundles make sure you have loaded the
source packages. The project's composer.json
should have something like:
"config": {
"preferred-install": {
"acme/*": "source"
}
}
Change git commit message¶
To change the automatic git commit message add the option --message=''
. For example:
console xrow:translate --from=en --to=de,fr,es --service=google --message='Add my awesome translations' --verbose
Configuration¶
The automatic translation services must be configured before this feature can be used.
Define them in config/packages/ibexa_automated_translation.yaml
. Example for Google's service:
ibexa_automated_translation:
system:
default:
configurations:
google:
apiKey: 'api-key-provided-by-google'
Note¶
Although the ibexa/automated-translation
bundle is normally used to generate automatic translations of content in the Ibexa Admin UI,
that functionality is disabled by the Translation Manager (see class
Xrow\TranslationBundle\DependencyInjection\Compiler\DisableAutomatedTranslation
).