Prep for translations in JS.

This commit is contained in:
James Cole 2016-08-14 08:34:59 +02:00
parent 117bb602dc
commit d287ae97f8
2 changed files with 14 additions and 9 deletions

View File

@ -5,7 +5,7 @@
* This software may be modified and distributed under the terms * This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details. * of the MIT license. See the LICENSE file for details.
*/ */
/* globals $, jobImportUrl, jobStartUrl, token */ /* globals $, jobImportUrl, jobStartUrl, token, langImportMultiError, langImportSingleError */
var startedImport = false; var startedImport = false;
@ -57,13 +57,15 @@ function updateBar(data) {
function reportErrors(data) { function reportErrors(data) {
"use strict"; "use strict";
if (data.errors.length == 1) { if (data.errors.length == 1) {
$('#import-status-error-intro').text('An error has occured during the import. The import can continue, however.'); $('#import-status-error-intro').text(langImportSingleError);
//'An error has occured during the import. The import can continue, however.'
} }
if (data.errors.length > 1) { if (data.errors.length > 1) {
$('#import-status-error-intro').text('Errors have occured during the import. The import can continue, however.'); // 'Errors have occured during the import. The import can continue, however.'
$('#import-status-error-intro').text(langImportMultiError);
} }
// fill the list: // fill the list with error texts
$('#import-status-error-list').empty(); $('#import-status-error-list').empty();
for (var i = 0; i < data.errors.length; i++) { for (var i = 0; i < data.errors.length; i++) {
var item = $('<li>').text(data.errors[i]); var item = $('<li>').text(data.errors[i]);
@ -110,14 +112,11 @@ function failedJobImport(jqxhr, textStatus, error) {
"use strict"; "use strict";
// set status // set status
// "There was an error during the import routine. Please check the log files. The error seems to be: '"
$('#import-status-txt').addClass('text-danger').text( $('#import-status-txt').addClass('text-danger').text(
"There was an error during the import routine. Please check the log files. The error seems to be: '" + textStatus + ' ' + error + "'." langImportFatalError + textStatus + ' ' + error
); );
// remove progress bar. // remove progress bar.
$('#import-status-holder').hide(); $('#import-status-holder').hide();
console.log('failedJobImport');
console.log(textStatus);
console.log(error);
} }

View File

@ -57,6 +57,12 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script type="text/javascript"> <script type="text/javascript">
// some useful translations.
var langImportSingleError = '{{ 'import_error_single'|_ }}';
var langImportMultiError = '{{ 'import_error_multi'|_ }}';
var langImportFatalError = '{{ 'import_error_fatal'|_ }}';
var jobKey = '{{ job.key }}'; var jobKey = '{{ job.key }}';
var jobImportUrl = '{{ route('import.json', [job.key]) }}'; var jobImportUrl = '{{ route('import.json', [job.key]) }}';
var jobStartUrl = '{{ route('import.start', [job.key]) }}'; var jobStartUrl = '{{ route('import.start', [job.key]) }}';