Basic installation with script tags
I'm missing something basic about how to load this.
<script src="{{ asset('bundles/bazingajstranslation/js/translator.min.js') }}"></script>
<script src="{{ url('bazinga_jstranslation_js') }}"></script>
translations:19 Uncaught ReferenceError: Translator is not defined at translations:19:4 (anonymous) @ translations:19
I've also been playing around with loading it as a module, but I figured I'd at least get a basic installation working first. Can anyone point me in the right direction?
Gracias.
Hello @tacman, i'm in the same situation. Do you solve this error?
No. I'll probably switch to https://symfony.com/bundles/ux-translator/current/index.html when I get around to focusing on javascript-based translations.
is the translator.min.js file loaded properly or do you have another error before that for the loading of that file ?
@stof , I see it's not loaded but it's present in the bundles/ directory. After following the doc here is my code :
{% block javascripts%}
{{ parent() }}
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap4.min.js"></script>
<script src="{{ asset('bundles/bazingajstranslation/js/translator.min.js') }}"></script>
<script src="{{ url('willdurand_js_translation_js', { 'domain': 'messages', 'locales': app.request.locale }) }}"></script>
<script type="text/javascript" src="{{ asset('admin/js/sb-admin-2.min.js') }}"></script>
<script src="{{ asset('/js/styles/datatable.js') }}"></script>
{% endblock %}
and here i want use the Translator object with Datatable:
var oTable = new DataTable(".dataTable", {
paging: true,
pageLength: 10,
responsive: true,
select: {
style: "multi", // Enable multi-selection
selector: "td:first-child", // Enable selection on the first column (checkbox)
},
language: {
processing: Translator.trans('processing'),
search: Translator.trans('search'),
lengthMenu: Translator.trans('lengthMenu'),
info: Translator.trans('info'),
infoEmpty: Translator.trans('infoEmpty'),
infoFiltered: Translator.trans('infoFiltered'),
loadingRecords: Translator.trans('loadingRecords'),
zeroRecords: Translator.trans('zeroRecords'),
emptyTable: Translator.trans('emptyTable'),
paginate: {
first: Translator.trans('first'),
previous: Translator.trans('previous'),
next: Translator.trans('next'),
last: Translator.trans('last'),
},
aria: {
sortAscending: Translator.trans('aria.sortAscending'),
sortDescending: Translator.trans('aria.sortDescending'),
},
},
});
where is the code of your second snippet ?
it's in the datatable.js
@stof do you find a solution for me?
I don't have an idea.
Would it be possible to create a reproducing case for the issue (i.e. a small Symfony project in which this error happens while using the minimal amount of code for that, which we could run to investigate as well) ?