Translating Concerto Platform - campsych/concerto-platform GitHub Wiki
Concerto Platform translation is based on text based dictionary files in yaml format. Each language has its own set of these. There are currently two bundles (panel and test runner) that have separate dictionary files. You need to translate files for both to add a new translation to the Concerto Platform.
- Panel translations location: src/Concerto/PanelBundle/Resources/translations
- Test runner translations location: src/Concerto/TestBundle/Resources/translations
Let’s take a look at the name of dictionary file. E.g. login.en_GB.yml. It’s first part login, tells us which section this dictionary files translates. In this example it’s a login form. Next, after first dot, we have en_GB which describes the locale of the translation file. It’s British English here. When adding new translation, this needs to be replaced with the name of new locale name of translation (e.g. pt_BR for Brazilian Portuguese).
Now, let’s look at the contents of the yaml file itself.
form: legend: Please enter your credentials legend.tooltip: Enter your login and password field: login: Login login.tooltip: Please enter your login id
Each dictionary entry consist of phrase id and its specific locale translation. Let’s look at the example above, where form.legend is the id of the phrase and “Please enter your credentials” is British English translation.
For demonstration purposes, let’s assume that we’ll be adding Brazilian Portuguese translation. The name of the locale for Brazilian Portuguese will be pt_BR.
- Create a renamed copy of all translation files for both Concerto Platform bundles at:
- Panel translations location: src/Concerto/PanelBundle/Resources/translations
- Test runner translations location: src/Concerto/TestBundle/Resources/translations
British English translation files are a good source for copying files because this is the language that Concerto was originally written in, but of course, it can from be any other locale. We need to have renamed copies, where the names of the new files is the name of the old files with locale part replaced with the new locale name, e.g.:
login.en_GB.yml → login.pt_BR.yml
- Translate each phrase inside all dictionary files of newly created locale
- Save your changes and send them back to us, either through git pull request (preferably), or by sending your newly created translation files to: [email protected]
There is a useful command to check missing entries or debug your translation. You need to have a Concerto Platform set up and have a command line access to the system where it’s installed on. By running (while in Concerto Platform installation root directory):
php bin/console debug:translation pt_BR --only-missing ConcertoPanelBundle php bin/console debug:translation pt_BR --only-missing ConcertoTestBundle
you will get a list of all phrases that are missing translation in pt_BR locale.
If you have recently modified translation files and you would like to run the commands above, please clear your cache first by running:
php bin/console cache clear