def upload_bulk_app_translations(request, domain, app_id): lang = request.POST.get('language') validate = request.POST.get('validate') app = get_app(domain, app_id) try: workbook = get_workbook(request.file) except WorkbookJSONError as e: messages.error(request, str(e)) else: if validate: if not lang: msgs = [(messages.error, _("Please select language to validate."))] else: msgs = validate_bulk_app_translation_upload( app, workbook, request.user.email, lang) else: sheet_name_to_unique_id = get_sheet_name_to_unique_id_map( request.file, lang) msgs = process_bulk_app_translation_upload(app, workbook, sheet_name_to_unique_id, lang=lang) app.save() _add_messages_to_request(request, msgs) # In v2, languages is the default tab on the settings page return HttpResponseRedirect(reverse('app_settings', args=[domain, app_id]))
def upload_bulk_app_translations(request, domain, app_id): lang = request.POST.get('language') validate = request.POST.get('validate') app = get_app(domain, app_id) workbook = None msgs = [] try: workbook = get_workbook(request.file) except WorkbookJSONError as e: messages.error(request, six.text_type(e)) if workbook: if validate: msgs = validate_bulk_app_translation_upload(app, workbook, request.user.email, lang) else: headers = get_bulk_app_sheet_headers(app, lang=lang) msgs = process_bulk_app_translation_upload(app, workbook, headers, lang=lang) app.save() for msg in msgs: # Add the messages to the request object. # msg[0] should be a function like django.contrib.messages.error . # msg[1] should be a string. msg[0](request, msg[1]) # In v2, languages is the default tab on the settings page return HttpResponseRedirect( reverse('app_settings', args=[domain, app_id]) )