As a company located in Belgium, Kunstmaan is always asked to build multilingual websites. Dutch, French are a given, and often several other language as well. We didn't find any solution able to reliably cope with these multilangual needs, and that's the main reason we started with the Kunstmaan Bundles project. To this date, it is still the only implementation that can handle those needs.

Until now, all database related content was easily manageable in the admin interface, but minor translations like words, taglines, formlabels, error messages, ... were administered in the native Symfony2 translation files in GIT. Of course, that's not really client friendly. While there are some projects to provide interfaces on top of these files, they edit these files and these changes did not transfer well to our GIT repo's.

This is why we created the KunstmaanTranslatorBundle, a bundle which enables editing translations in the admin interface without need for editing the translations files. Translations will be stored in a (default) database and retrieved on the most efficient way possible.

A view on the Translation editor in the admin interface

Features

  • Import bundle/global translations from any type of translation file
  • Import only specific translations (only from console command)
  • Force import to overwrite existing translations with same domain/keyword/locale
  • Edit stored translations from the backend interface
  • Add new translations from the backend interface
  • Translations are cached (if debug is disabled)
  • Warning when cached translations aren't up to date with the stored translations
  • Clear translation cache to rebuild translations from the stored translations
  • Newer or updated translations are flagged
  • Create a Doctrine Migrations file with all flagged translations
  • Reset all flagged translations (from console command)
  • Clear and check translation cache from console command
  • Check your page with the keyword and domain of all translations
 

Symfony2 profiler integration

The Symfony2 Profiler shows the number of translations used on the current request:

Symfony profiler integration for the TranslatorBundle

When you click on this item, you can see all translations used on the current request, so you can easily edit them in the Kunstmaan Admin backend.

The translations in the profiler

This makes it easy to find the keys in a dev environment, but if you need to find this information in a production environment, you can add an extra GET parameter to your request. Add ?transSource=1 to your url to see all sources of the translated labels.

Instead of "Hello world" you might see header.hello_world (messages). This means:
 
  • keyword is header.hello_world
  • domain is messages

Workflow example (new project)

  1. Add translations (with keywords) in your template files (dev)
  2. Add the translations of (1) into your backend via "Add Translation" (dev)
  3. Repeat 1 & 2
  4. Create migrations diff app/console kuma:translator:migrations:diff (dev)
  5. Reset translation flags app/console kuma:translator:flag --reset (dev)
  6. Deploy your application
  7. Execute doctrine migrations app/console doctrine:migrations:migrate (prod)
  8. Edit/add translations (prod)
  9. When ready editing/adding, click Refresh live or app/console kuma:translator:cache --flush (prod)
  10. Repeat 7 & 8 when editing/adding translations in prod

Workflow example (existing project)

  1. Import current translations, click Import -> Import or app/console kuma:translator:import (prod/dev)
  2. If you did 1 in dev, go to 4 of "Workflow example (new project)", otherwise go to 7 "Workflow example (new project)"

For installation and configuration details check out the documentation on GitHub, and if you like it, please recommend this bundle on KnpBundles. 

Questions?

Feel free to contact the author