I'm trying to use BazingaJsTranslationBundle for take advance of Symfony2 translations. After read docs this is what I've done:
Include needed JS libraries
<script src="{{ asset('bundles/bazingajstranslation/js/translator.min.js') }}"></script> // Tried this way <script src="{{ url('bazinga_jstranslation_js', { 'domain': 'AppBundle' }) }}"></script> // Also tried this one <script src="{{ url('bazinga_jstranslation_js') }}"></script>
Setup bundle at
config.yml
:bazinga_js_translation: locale_fallback: "%locale%" default_domain: AppBundle
Dump translations using the bazinga supply command:
Symfony > bazinga:js-translation:dump Installing translation files in /var/www/html/sencamer.dev/web/js directory
Start using translations in JS files:
Translator.trans('mensaje.msgAgregarSatisfactorio', {"pronombre": "la", "elemento": "solicitud"}, 'AppBundle')
where this is the original string from
AppBundle.es.yml
:msgAgregarSatisfactorio: Se ha creado %pronombre% %elemento% satisfactoriamente.
and this is the dump translation at
web\js\translations\AppBundle\es.js
Translator.add("mensajes.msgAgregarSatisfactorio", "Se ha creado %pronombre% %elemento% satisfactoriamente.", "AppBundle", "es");
When that code is executed I get the untranslated string: mensaje.msgAgregarSatisfactorio
but not the message, why? What's wrong? This topic is related to this one in somehow, any advice?
As this image shows, there are no Javascript errors on console and also file is loaded and I think it's well formed: