diff --git a/cps/about.py b/cps/about.py index 31e843b9..7b6cc71a 100644 --- a/cps/about.py +++ b/cps/about.py @@ -81,4 +81,4 @@ def stats(): categories = calibre_db.session.query(db.Tags).count() series = calibre_db.session.query(db.Series).count() return render_title_template('stats.html', bookcounter=counter, authorcounter=authors, versions=collect_stats(), - categorycounter=categories, seriecounter=series, title=_(u"Statistics"), page="stat") + categorycounter=categories, seriecounter=series, title=_("Statistics"), page="stat") diff --git a/cps/admin.py b/cps/admin.py index b415f412..3fd83d18 100644 --- a/cps/admin.py +++ b/cps/admin.py @@ -145,9 +145,9 @@ def shutdown(): ub.dispose() if task == 0: - show_text['text'] = _(u'Server restarted, please reload page') + show_text['text'] = _(u'Server restarted, please reload page.') else: - show_text['text'] = _(u'Performing shutdown of server, please close window') + show_text['text'] = _(u'Performing Server shutdown, please close window.') # stop gevent/tornado server web_server.stop(task == 0) return json.dumps(show_text) @@ -155,7 +155,7 @@ def shutdown(): if task == 2: log.warning("reconnecting to calibre database") calibre_db.reconnect_db(config, ub.app_DB_path) - show_text['text'] = _(u'Reconnect successful') + show_text['text'] = _(u'Success! Database Reconnected') return json.dumps(show_text) show_text['text'] = _(u'Unknown command') @@ -169,7 +169,7 @@ def queue_metadata_backup(): show_text = {} log.warning("Queuing all books for metadata backup") helper.set_all_metadata_dirty() - show_text['text'] = _(u'Books successfully queued for Metadata Backup') + show_text['text'] = _(u'Success! Books queued for Metadata Backup') return json.dumps(show_text) @@ -227,7 +227,7 @@ def admin(): return render_title_template("admin.html", allUser=all_user, email=email_settings, config=config, commit=commit, feature_support=feature_support, schedule_time=schedule_time, schedule_duration=schedule_duration, - title=_(u"Admin page"), page="admin") + title=_("Admin page"), page="admin") @admi.route("/admin/dbconfig", methods=["GET", "POST"]) @@ -247,7 +247,7 @@ def configuration(): config=config, provider=oauthblueprints, feature_support=feature_support, - title=_(u"Basic Configuration"), page="config") + title=_("Basic Configuration"), page="config") @admi.route("/admin/ajaxconfig", methods=["POST"]) @@ -285,7 +285,7 @@ def view_configuration(): restrictColumns=restrict_columns, languages=languages, translations=translations, - title=_(u"UI Configuration"), page="uiconfig") + title=_("UI Configuration"), page="uiconfig") @admi.route("/admin/usertable") @@ -319,7 +319,7 @@ def edit_user_table(): all_roles=constants.ALL_ROLES, kobo_support=kobo_support, sidebar_settings=constants.sidebar_settings, - title=_(u"Edit Users"), + title=_("Edit Users"), page="usertable") @@ -490,7 +490,7 @@ def edit_list_user(param): ub.User.id != user.id).count(): return Response( json.dumps([{'type': "danger", - 'message': _(u"No admin user remaining, can't remove admin role", + 'message': _("No admin user remaining, can't remove admin role", nick=user.name)}]), mimetype='application/json') user.role &= ~value else: @@ -567,13 +567,13 @@ def update_view_configuration(): calibre_db.update_title_sort(config) if not check_valid_read_column(to_save.get("config_read_column", "0")): - flash(_(u"Invalid Read Column"), category="error") + flash(_("Invalid Read Column"), category="error") log.debug("Invalid Read column") return view_configuration() _config_int(to_save, "config_read_column") if not check_valid_restricted_column(to_save.get("config_restricted_column", "0")): - flash(_(u"Invalid Restricted Column"), category="error") + flash(_("Invalid Restricted Column"), category="error") log.debug("Invalid Restricted Column") return view_configuration() _config_int(to_save, "config_restricted_column") @@ -593,7 +593,7 @@ def update_view_configuration(): config.config_default_show |= constants.DETAIL_RANDOM config.save() - flash(_(u"Calibre-Web configuration updated"), category="success") + flash(_("Calibre-Web configuration updated"), category="success") log.debug("Calibre-Web configuration updated") before_request() @@ -1256,7 +1256,7 @@ def new_user(): content.default_language = config.config_default_language return render_title_template("user_edit.html", new_user=1, content=content, config=config, translations=translations, - languages=languages, title=_(u"Add new user"), page="newuser", + languages=languages, title=_("Add New User"), page="newuser", kobo_support=kobo_support, registered_oauth=oauth_check) @@ -1265,7 +1265,7 @@ def new_user(): @admin_required def edit_mailsettings(): content = config.get_mail_settings() - return render_title_template("email_edit.html", content=content, title=_(u"Edit E-mail Server Settings"), + return render_title_template("email_edit.html", content=content, title=_("Edit Email Server Settings"), page="mailset", feature_support=feature_support) @@ -1284,7 +1284,7 @@ def update_mailsettings(): elif to_save.get("gmail"): try: config.mail_gmail_token = services.gmail.setup_gmail(config.mail_gmail_token) - flash(_(u"Gmail Account Verification Successful"), category="success") + flash(_("Success! Gmail Account Verified."), category="success") except Exception as ex: flash(str(ex), category="error") log.error(ex) @@ -1303,24 +1303,24 @@ def update_mailsettings(): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return edit_mailsettings() except Exception as e: - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return edit_mailsettings() if to_save.get("test"): if current_user.email: result = send_test_mail(current_user.email, current_user.name) if result is None: - flash(_(u"Test e-mail queued for sending to %(email)s, please check Tasks for result", + flash(_("Test e-mail queued for sending to %(email)s, please check Tasks for result", email=current_user.email), category="info") else: - flash(_(u"There was an error sending the Test e-mail: %(res)s", res=result), category="error") + flash(_("There was an error sending the Test e-mail: %(res)s", res=result), category="error") else: - flash(_(u"Please configure your e-mail address first..."), category="error") + flash(_("Please configure your e-mail address first..."), category="error") else: - flash(_(u"E-mail server settings updated"), category="success") + flash(_("Email Server Settings updated"), category="success") return edit_mailsettings() @@ -1343,7 +1343,7 @@ def edit_scheduledtasks(): config=content, starttime=time_field, duration=duration_field, - title=_(u"Edit Scheduled Tasks Settings")) + title=_("Edit Scheduled Tasks Settings")) @admi.route("/admin/scheduledtasks", methods=["POST"]) @@ -1355,12 +1355,12 @@ def update_scheduledtasks(): if 0 <= int(to_save.get("schedule_start_time")) <= 23: _config_int(to_save, "schedule_start_time") else: - flash(_(u"Invalid start time for task specified"), category="error") + flash(_("Invalid start time for task specified"), category="error") error = True if 0 < int(to_save.get("schedule_duration")) <= 60: _config_int(to_save, "schedule_duration") else: - flash(_(u"Invalid duration for task specified"), category="error") + flash(_("Invalid duration for task specified"), category="error") error = True _config_checkbox(to_save, "schedule_generate_book_covers") _config_checkbox(to_save, "schedule_generate_series_covers") @@ -1369,7 +1369,7 @@ def update_scheduledtasks(): if not error: try: config.save() - flash(_(u"Scheduled tasks settings updated"), category="success") + flash(_("Scheduled tasks settings updated"), category="success") # Cancel any running tasks schedule.end_scheduled_tasks() @@ -1379,7 +1379,7 @@ def update_scheduledtasks(): except IntegrityError: ub.session.rollback() log.error("An unknown error occurred while saving scheduled tasks settings") - flash(_(u"An unknown error occurred. Please try again later."), category="error") + flash(_("Oops! An unknown error occurred. Please try again later."), category="error") except OperationalError: ub.session.rollback() log.error("Settings DB is not Writeable") @@ -1394,7 +1394,7 @@ def update_scheduledtasks(): def edit_user(user_id): content = ub.session.query(ub.User).filter(ub.User.id == int(user_id)).first() # type: ub.User if not content or (not config.config_anonbrowse and content.name == "Guest"): - flash(_(u"User not found"), category="error") + flash(_("User not found"), category="error") return redirect(url_for('admin.admin')) languages = calibre_db.speaking_language(return_all_languages=True) translations = get_available_locale() @@ -1413,7 +1413,7 @@ def edit_user(user_id): registered_oauth=oauth_check, mail_configured=config.get_mail_server_configured(), kobo_support=kobo_support, - title=_(u"Edit User %(nick)s", nick=content.name), + title=_("Edit User %(nick)s", nick=content.name), page="edituser") @@ -1424,14 +1424,14 @@ def reset_user_password(user_id): if current_user is not None and current_user.is_authenticated: ret, message = reset_password(user_id) if ret == 1: - log.debug(u"Password for user %s reset", message) - flash(_(u"Password for user %(user)s reset", user=message), category="success") + log.debug("Password for user %s reset", message) + flash(_("Success! Password for user %(user)s reset", user=message), category="success") elif ret == 0: - log.error(u"An unknown error occurred. Please try again later.") - flash(_(u"An unknown error occurred. Please try again later."), category="error") + log.error("An unknown error occurred. Please try again later.") + flash(_("Oops! An unknown error occurred. Please try again later."), category="error") else: - log.error(u"Please configure the SMTP mail settings first...") - flash(_(u"Please configure the SMTP mail settings first..."), category="error") + log.error("Please configure the SMTP mail settings.") + flash(_("Oops! Please configure the SMTP mail settings."), category="error") return redirect(url_for('admin.admin')) @@ -1442,7 +1442,7 @@ def view_logfile(): logfiles = {0: logger.get_logfile(config.config_logfile), 1: logger.get_accesslogfile(config.config_access_logfile)} return render_title_template("logviewer.html", - title=_(u"Logfile viewer"), + title=_("Logfile viewer"), accesslog_enable=config.config_access_log, log_enable=bool(config.config_logfile != logger.LOG_TO_STDOUT), logfiles=logfiles, @@ -1492,7 +1492,7 @@ def download_debug(): @admin_required def get_update_status(): if feature_support['updater']: - log.info(u"Update status requested") + log.info("Update status requested") return updater_thread.get_available_updates(request.method) else: return '' @@ -1687,7 +1687,7 @@ def _db_configuration_update_helper(): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - _db_configuration_result(_(u"Database error: %(error)s.", error=e.orig), gdrive_error) + _db_configuration_result(_("Oops! Database Error: %(error)s.", error=e.orig), gdrive_error) try: metadata_db = os.path.join(to_save['config_calibre_dir'], "metadata.db") if config.config_use_google_drive and is_gdrive_ready() and not os.path.exists(metadata_db): @@ -1719,7 +1719,7 @@ def _db_configuration_update_helper(): _config_string(to_save, "config_calibre_dir") calibre_db.update_config(config) if not os.access(os.path.join(config.config_calibre_dir, "metadata.db"), os.W_OK): - flash(_(u"DB is not Writeable"), category="warning") + flash(_("DB is not Writeable"), category="warning") config.save() return _db_configuration_result(None, gdrive_error) @@ -1805,7 +1805,7 @@ def _configuration_update_helper(): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - _configuration_result(_(u"Database error: %(error)s.", error=e.orig)) + _configuration_result(_("Oops! Database Error: %(error)s.", error=e.orig)) config.save() if reboot_required: @@ -1821,7 +1821,7 @@ def _configuration_result(error_flash=None, reboot=False): config.load() resp['result'] = [{'type': "danger", 'message': error_flash}] else: - resp['result'] = [{'type': "success", 'message': _(u"Calibre-Web configuration updated")}] + resp['result'] = [{'type': "success", 'message': _("Calibre-Web configuration updated")}] resp['reboot'] = reboot resp['config_upload'] = config.config_upload_formats return Response(json.dumps(resp), mimetype='application/json') @@ -1852,7 +1852,7 @@ def _db_configuration_result(error_flash=None, gdrive_error=None): gdriveError=gdrive_error, gdrivefolders=gdrivefolders, feature_support=feature_support, - title=_(u"Database Configuration"), page="dbconfig") + title=_("Database Configuration"), page="dbconfig") def _handle_new_user(to_save, content, languages, translations, kobo_support): @@ -1868,7 +1868,7 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support): try: if not to_save["name"] or not to_save["email"] or not to_save["password"]: log.info("Missing entries on new user") - raise Exception(_(u"Please fill out all fields!")) + raise Exception(_("Oops! Please complete all fields.")) content.email = check_email(to_save["email"]) # Query username, if not existing, change content.name = check_username(to_save["name"]) @@ -1876,13 +1876,13 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support): content.kindle_mail = valid_email(to_save["kindle_mail"]) if config.config_public_reg and not check_valid_domain(content.email): log.info("E-mail: {} for new user is not from valid domain".format(content.email)) - raise Exception(_(u"E-mail is not from valid domain")) + raise Exception(_("E-mail is not from valid domain")) except Exception as ex: flash(str(ex), category="error") return render_title_template("user_edit.html", new_user=1, content=content, config=config, translations=translations, - languages=languages, title=_(u"Add new user"), page="newuser", + languages=languages, title=_("Add new user"), page="newuser", kobo_support=kobo_support, registered_oauth=oauth_check) try: content.allowed_tags = config.config_allowed_tags @@ -1893,17 +1893,17 @@ def _handle_new_user(to_save, content, languages, translations, kobo_support): content.kobo_only_shelves_sync = to_save.get("kobo_only_shelves_sync", 0) == "on" ub.session.add(content) ub.session.commit() - flash(_(u"User '%(user)s' created", user=content.name), category="success") + flash(_("User '%(user)s' created", user=content.name), category="success") log.debug("User {} created".format(content.name)) return redirect(url_for('admin.admin')) except IntegrityError: ub.session.rollback() log.error("Found an existing account for {} or {}".format(content.name, content.email)) - flash(_("Found an existing account for this e-mail address or name."), category="error") + flash(_("Oops! An account already exists for this Email. or name."), category="error") except OperationalError as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") def _delete_user(content): @@ -1989,7 +1989,7 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support): try: new_email = valid_email(to_save.get("email", content.email)) if not new_email: - raise Exception(_(u"E-Mail Address can't be empty and has to be a valid E-Mail")) + raise Exception(_("Email can't be empty and has to be a valid Email")) if new_email != content.email: content.email = check_email(new_email) # Query username, if not existing, change @@ -2011,19 +2011,19 @@ def _handle_edit_user(to_save, content, languages, translations, kobo_support): content=content, config=config, registered_oauth=oauth_check, - title=_(u"Edit User %(nick)s", nick=content.name), + title=_("Edit User %(nick)s", nick=content.name), page="edituser") try: ub.session_commit() - flash(_(u"User '%(nick)s' updated", nick=content.name), category="success") + flash(_("User '%(nick)s' updated", nick=content.name), category="success") except IntegrityError as ex: ub.session.rollback() log.error("An unknown error occurred while changing user: {}".format(str(ex))) - flash(_(u"An unknown error occurred. Please try again later."), category="error") + flash(_("Oops! An unknown error occurred. Please try again later."), category="error") except OperationalError as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return "" diff --git a/cps/editbooks.py b/cps/editbooks.py index 3580d667..dee9b600 100755 --- a/cps/editbooks.py +++ b/cps/editbooks.py @@ -107,7 +107,7 @@ def edit_book(book_id): book = calibre_db.get_filtered_book(book_id, allow_show_archived=True) # Book not found if not book: - flash(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"), + flash(_("Oops! Selected book is unavailable. File does not exist or is not accessible"), category="error") return redirect(url_for("web.index")) @@ -151,7 +151,7 @@ def edit_book(book_id): if to_save.get("cover_url", None): if not current_user.role_upload(): edit_error = True - flash(_(u"User has no rights to upload cover"), category="error") + flash(_("User has no rights to upload cover"), category="error") if to_save["cover_url"].endswith('/static/generic_cover.jpg'): book.has_cover = 0 else: @@ -226,7 +226,7 @@ def edit_book(book_id): except (OperationalError, IntegrityError, StaleDataError, InterfaceError) as e: log.error_or_exception("Database error: {}".format(e)) calibre_db.session.rollback() - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return redirect(url_for('web.show_book', book_id=book.id)) except Exception as ex: log.error_or_exception(ex) @@ -288,7 +288,7 @@ def upload(): if error: flash(error, category="error") link = '{}'.format(url_for('web.show_book', book_id=book_id), escape(title)) - upload_text = N_(u"File %(file)s uploaded", file=link) + upload_text = N_("File %(file)s uploaded", file=link) WorkerThread.add(current_user.name, TaskUpload(upload_text, escape(title))) helper.add_book_to_thumbnail_cache(book_id) @@ -302,7 +302,7 @@ def upload(): except (OperationalError, IntegrityError, StaleDataError) as e: calibre_db.session.rollback() log.error_or_exception("Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') @@ -315,7 +315,7 @@ def convert_bookformat(book_id): book_format_to = request.form.get('book_format_to', None) if (book_format_from is None) or (book_format_to is None): - flash(_(u"Source or destination format for conversion missing"), category="error") + flash(_("Source or destination format for conversion missing"), category="error") return redirect(url_for('edit-book.show_edit_book', book_id=book_id)) log.info('converting: book id: %s from: %s to: %s', book_id, book_format_from, book_format_to) @@ -323,11 +323,11 @@ def convert_bookformat(book_id): book_format_to.upper(), current_user.name) if rtn is None: - flash(_(u"Book successfully queued for converting to %(book_format)s", + flash(_("Book successfully queued for converting to %(book_format)s", book_format=book_format_to), category="success") else: - flash(_(u"There was an error converting this book: %(res)s", res=rtn), category="error") + flash(_("There was an error converting this book: %(res)s", res=rtn), category="error") return redirect(url_for('edit-book.show_edit_book', book_id=book_id)) @@ -632,7 +632,7 @@ def prepare_authors_on_upload(title, authr): entry = calibre_db.check_exists_book(authr, title) if entry: log.info("Uploaded book probably exists in library") - flash(_(u"Uploaded book probably exists in the library, consider to change before upload new: ") + flash(_("Uploaded book probably exists in the library, consider to change before upload new: ") + Markup(render_title_template('book_exists_flash.html', entry=entry)), category="warning") input_authors, renamed = prepare_authors(authr) @@ -687,7 +687,7 @@ def create_book_on_upload(modify_date, meta): modify_date |= edit_book_languages(meta.languages, db_book, upload_mode=True, invalid=invalid) if invalid: for lang in invalid: - flash(_(u"'%(langname)s' is not a valid language", langname=lang), category="warning") + flash(_("'%(langname)s' is not a valid language", langname=lang), category="warning") # handle tags modify_date |= edit_book_tags(meta.tags, db_book) @@ -737,7 +737,7 @@ def file_handling_on_upload(requested_file): meta = uploader.upload(requested_file, config.config_rarfile_location) except (IOError, OSError): log.error("File %s could not saved to temp dir", requested_file.filename) - flash(_(u"File %(filename)s could not saved to temp dir", + flash(_("File %(filename)s could not saved to temp dir", filename=requested_file.filename), category="error") return None, Response(json.dumps({"location": url_for("web.index")}), mimetype='application/json') return meta, None @@ -757,7 +757,7 @@ def move_coverfile(meta, db_book): os.unlink(meta.cover) except OSError as e: log.error("Failed to move cover file %s: %s", new_cover_path, e) - flash(_(u"Failed to Move Cover File %(file)s: %(error)s", file=new_cover_path, + flash(_("Failed to Move Cover File %(file)s: %(error)s", file=new_cover_path, error=e), category="error") @@ -892,7 +892,7 @@ def render_edit_book(book_id): cc = calibre_db.session.query(db.CustomColumns).filter(db.CustomColumns.datatype.notin_(db.cc_exceptions)).all() book = calibre_db.get_filtered_book(book_id, allow_show_archived=True) if not book: - flash(_(u"Oops! Selected book title is unavailable. File does not exist or is not accessible"), + flash(_("Oops! Selected book is unavailable. File does not exist or is not accessible"), category="error") return redirect(url_for("web.index")) @@ -927,7 +927,7 @@ def render_edit_book(book_id): if kepub_possible: allowed_conversion_formats.append('kepub') return render_title_template('book_edit.html', book=book, authors=author_names, cc=cc, - title=_(u"edit metadata"), page="editbook", + title=_("edit metadata"), page="editbook", conversion_formats=allowed_conversion_formats, config=config, source_formats=valid_source_formats) @@ -1012,7 +1012,7 @@ def edit_book_languages(languages, book, upload_mode=False, invalid=None): if isinstance(invalid, list): invalid.append(lang) else: - raise ValueError(_(u"'%(langname)s' is not a valid language", langname=lang)) + raise ValueError(_("'%(langname)s' is not a valid language", langname=lang)) # ToDo: Not working correct if upload_mode and len(input_l) == 1: # If the language of the file is excluded from the users view, it's not imported, to allow the user to view @@ -1154,7 +1154,7 @@ def upload_single_file(file_request, book, book_id): # check for empty request if requested_file.filename != '': if not current_user.role_upload(): - flash(_(u"User has no rights to upload additional file formats"), category="error") + flash(_("User has no rights to upload additional file formats"), category="error") return False if '.' in requested_file.filename: file_ext = requested_file.filename.rsplit('.', 1)[-1].lower() @@ -1175,12 +1175,12 @@ def upload_single_file(file_request, book, book_id): try: os.makedirs(filepath) except OSError: - flash(_(u"Failed to create path %(path)s (Permission denied).", path=filepath), category="error") + flash(_("Failed to create path %(path)s (Permission denied).", path=filepath), category="error") return False try: requested_file.save(saved_filename) except OSError: - flash(_(u"Failed to store file %(file)s.", file=saved_filename), category="error") + flash(_("Failed to store file %(file)s.", file=saved_filename), category="error") return False file_size = os.path.getsize(saved_filename) @@ -1198,12 +1198,12 @@ def upload_single_file(file_request, book, book_id): except (OperationalError, IntegrityError, StaleDataError) as e: calibre_db.session.rollback() log.error_or_exception("Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return False # return redirect(url_for('web.show_book', book_id=book.id)) # Queue uploader info link = '{}'.format(url_for('web.show_book', book_id=book.id), escape(book.title)) - upload_text = N_(u"File format %(ext)s added to %(book)s", ext=file_ext.upper(), book=link) + upload_text = N_("File format %(ext)s added to %(book)s", ext=file_ext.upper(), book=link) WorkerThread.add(current_user.name, TaskUpload(upload_text, escape(book.title))) return uploader.process( @@ -1218,7 +1218,7 @@ def upload_cover(cover_request, book): # check for empty request if requested_file.filename != '': if not current_user.role_upload(): - flash(_(u"User has no rights to upload cover"), category="error") + flash(_("User has no rights to upload cover"), category="error") return False ret, message = helper.save_cover(requested_file, book.path) if ret is True: diff --git a/cps/helper.py b/cps/helper.py old mode 100755 new mode 100644 index 212ce142..bf119a00 --- a/cps/helper.py +++ b/cps/helper.py @@ -77,25 +77,25 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format, book = calibre_db.get_book(book_id) data = calibre_db.get_book_format(book.id, old_book_format) if not data: - error_message = _(u"%(format)s format not found for book id: %(book)d", format=old_book_format, book=book_id) + error_message = _("%(format)s format not found for book id: %(book)d", format=old_book_format, book=book_id) log.error("convert_book_format: %s", error_message) return error_message file_path = os.path.join(calibre_path, book.path, data.name) if config.config_use_google_drive: if not gd.getFileFromEbooksFolder(book.path, data.name + "." + old_book_format.lower()): - error_message = _(u"%(format)s not found on Google Drive: %(fn)s", + error_message = _("%(format)s not found on Google Drive: %(fn)s", format=old_book_format, fn=data.name + "." + old_book_format.lower()) return error_message else: if not os.path.exists(file_path + "." + old_book_format.lower()): - error_message = _(u"%(format)s not found: %(fn)s", + error_message = _("%(format)s not found: %(fn)s", format=old_book_format, fn=data.name + "." + old_book_format.lower()) return error_message # read settings and append converter task to queue if ereader_mail: settings = config.get_mail_settings() - settings['subject'] = _('Send to E-Reader') # pretranslate Subject for e-mail - settings['body'] = _(u'This e-mail has been sent via Calibre-Web.') + settings['subject'] = _('Send to eReader') # pretranslate Subject for Email + settings['body'] = _(u'This Email has been sent via Calibre-Web.') else: settings = dict() link = '{}'.format(url_for('web.show_book', book_id=book.id), escape(book.title)) # prevent xss @@ -111,30 +111,30 @@ def convert_book_format(book_id, calibre_path, old_book_format, new_book_format, # Texts are not lazy translated as they are supposed to get send out as is def send_test_mail(ereader_mail, user_name): - WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web test e-mail'), None, None, - config.get_mail_settings(), ereader_mail, N_(u"Test e-mail"), - _(u'This e-mail has been sent via Calibre-Web.'))) + WorkerThread.add(user_name, TaskEmail(_(u'Calibre-Web Test Email'), None, None, + config.get_mail_settings(), ereader_mail, N_("Test Email"), + _(u'This Email has been sent via Calibre-Web.'))) return # Send registration email or password reset email, depending on parameter resend (False means welcome email) def send_registration_mail(e_mail, user_name, default_password, resend=False): - txt = "Hello %s!\r\n" % user_name + txt = "Hi %s!\r\n" % user_name if not resend: - txt += "Your new account at Calibre-Web has been created. Thanks for joining us!\r\n" - txt += "Please log in to your account using the following information:\r\n" - txt += "User name: %s\r\n" % user_name + txt += "Your account at Calibre-Web has been created.\r\n" + txt += "Please log in using the following information:\r\n" + txt += "Username: %s\r\n" % user_name txt += "Password: %s\r\n" % default_password - txt += "Don't forget to change your password after first login.\r\n" - txt += "Sincerely\r\n\r\n" - txt += "Your Calibre-Web team" + txt += "Don't forget to change your password after your first login.\r\n" + txt += "Regards,\r\n\r\n" + txt += "Calibre-Web" WorkerThread.add(None, TaskEmail( subject=_(u'Get Started with Calibre-Web'), filepath=None, attachment=None, settings=config.get_mail_settings(), recipient=e_mail, - task_message=N_(u"Registration e-mail for user: %(name)s", name=user_name), + task_message=N_("Registration Email for user: %(name)s", name=user_name), text=txt )) return @@ -145,13 +145,13 @@ def check_send_to_ereader_with_converter(formats): if 'MOBI' in formats and 'EPUB' not in formats: book_formats.append({'format': 'Epub', 'convert': 1, - 'text': _('Convert %(orig)s to %(format)s and send to E-Reader', + 'text': _('Convert %(orig)s to %(format)s and send to eReader', orig='Mobi', format='Epub')}) if 'AZW3' in formats and 'EPUB' not in formats: book_formats.append({'format': 'Epub', 'convert': 2, - 'text': _('Convert %(orig)s to %(format)s and send to E-Reader', + 'text': _('Convert %(orig)s to %(format)s and send to eReader', orig='Azw3', format='Epub')}) return book_formats @@ -159,7 +159,7 @@ def check_send_to_ereader_with_converter(formats): def check_send_to_ereader(entry): """ - returns all available book formats for sending to E-Reader + returns all available book formats for sending to eReader """ formats = list() book_formats = list() @@ -170,19 +170,19 @@ def check_send_to_ereader(entry): if 'EPUB' in formats: book_formats.append({'format': 'Epub', 'convert': 0, - 'text': _('Send %(format)s to E-Reader', format='Epub')}) + 'text': _('Send %(format)s to eReader', format='Epub')}) if 'MOBI' in formats: book_formats.append({'format': 'Mobi', 'convert': 0, - 'text': _('Send %(format)s to E-Reader', format='Mobi')}) + 'text': _('Send %(format)s to eReader', format='Mobi')}) if 'PDF' in formats: book_formats.append({'format': 'Pdf', 'convert': 0, - 'text': _('Send %(format)s to E-Reader', format='Pdf')}) + 'text': _('Send %(format)s to eReader', format='Pdf')}) if 'AZW' in formats: book_formats.append({'format': 'Azw', 'convert': 0, - 'text': _('Send %(format)s to E-Reader', format='Azw')}) + 'text': _('Send %(format)s to eReader', format='Azw')}) if config.config_converterpath: book_formats.extend(check_send_to_ereader_with_converter(formats)) return book_formats @@ -204,9 +204,9 @@ def check_read_formats(entry): # Files are processed in the following order/priority: -# 1: If Mobi file is existing, it's directly send to E-Reader email, -# 2: If Epub file is existing, it's converted and send to E-Reader email, -# 3: If Pdf file is existing, it's directly send to E-Reader email +# 1: If Mobi file is existing, it's directly send to eReader email, +# 2: If Epub file is existing, it's converted and send to eReader email, +# 3: If Pdf file is existing, it's directly send to eReader email def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id): """Send email with attachments""" book = calibre_db.get_book(book_id) @@ -222,12 +222,12 @@ def send_mail(book_id, book_format, convert, ereader_mail, calibrepath, user_id) if entry.format.upper() == book_format.upper(): converted_file_name = entry.name + '.' + book_format.lower() link = '{}'.format(url_for('web.show_book', book_id=book_id), escape(book.title)) - email_text = N_(u"%(book)s send to E-Reader", book=link) - WorkerThread.add(user_id, TaskEmail(_(u"Send to E-Reader"), book.path, converted_file_name, + email_text = N_("%(book)s send to eReader", book=link) + WorkerThread.add(user_id, TaskEmail(_("Send to eReader"), book.path, converted_file_name, config.get_mail_settings(), ereader_mail, - email_text, _(u'This e-mail has been sent via Calibre-Web.'))) + email_text, _(u'This Email has been sent via Calibre-Web.'))) return - return _(u"The requested file could not be read. Maybe wrong permissions?") + return _("The requested file could not be read. Maybe wrong permissions?") def get_valid_filename(value, replace_whitespace=True, chars=128): @@ -341,7 +341,7 @@ def edit_book_read_status(book_id, read_status=None): return "Custom Column No.{} does not exist in calibre database".format(config.config_read_column) except (OperationalError, InvalidRequestError) as ex: calibre_db.session.rollback() - log.error(u"Read status could not set: {}".format(ex)) + log.error("Read status could not set: {}".format(ex)) return _("Read status could not set: {}".format(ex.orig)) return "" @@ -640,16 +640,16 @@ def uniq(inpt): def check_email(email): email = valid_email(email) if ub.session.query(ub.User).filter(func.lower(ub.User.email) == email.lower()).first(): - log.error(u"Found an existing account for this e-mail address") - raise Exception(_(u"Found an existing account for this e-mail address")) + log.error("Found an existing account for this Email address") + raise Exception(_("Found an existing account for this Email address")) return email def check_username(username): username = username.strip() if ub.session.query(ub.User).filter(func.lower(ub.User.name) == username.lower()).scalar(): - log.error(u"This username is already taken") - raise Exception(_(u"This username is already taken")) + log.error("This username is already taken") + raise Exception(_("This username is already taken")) return username @@ -660,8 +660,8 @@ def valid_email(email): # Regex according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#validation if not re.search(r"^[\w.!#$%&'*+\\/=?^_`{|}~-]+@[\w](?:[\w-]{0,61}[\w])?(?:\.[\w](?:[\w-]{0,61}[\w])?)*$", email): - log.error(u"Invalid e-mail address format") - raise Exception(_(u"Invalid e-mail address format")) + log.error("Invalid Email address format") + raise Exception(_("Invalid Email address format")) return email # ################################# External interface ################################# @@ -837,8 +837,8 @@ def save_cover_from_filestorage(filepath, saved_filename, img): try: os.makedirs(filepath) except OSError: - log.error(u"Failed to create path for cover") - return False, _(u"Failed to create path for cover") + log.error("Failed to create path for cover") + return False, _("Failed to create path for cover") try: # upload of jgp file without wand if isinstance(img, requests.Response): @@ -853,8 +853,8 @@ def save_cover_from_filestorage(filepath, saved_filename, img): # upload of jpg/png... from hdd img.save(os.path.join(filepath, saved_filename)) except (IOError, OSError): - log.error(u"Cover-file is not a valid image file, or could not be stored") - return False, _(u"Cover-file is not a valid image file, or could not be stored") + log.error("Cover-file is not a valid image file, or could not be stored") + return False, _("Cover-file is not a valid image file, or could not be stored") return True, None diff --git a/cps/kobo.py b/cps/kobo.py index 8ab1e47b..9df1acbc 100644 --- a/cps/kobo.py +++ b/cps/kobo.py @@ -356,7 +356,7 @@ def HandleMetadataRequest(book_uuid): log.info("Kobo library metadata request received for book %s" % book_uuid) book = calibre_db.get_book_by_uuid(book_uuid) if not book or not book.data: - log.info(u"Book %s not found in database", book_uuid) + log.info("Book %s not found in database", book_uuid) return redirect_or_proxy_request() metadata = get_metadata(book) @@ -759,7 +759,7 @@ def create_kobo_tag(shelf): for book_shelf in shelf.books: book = calibre_db.get_book(book_shelf.book_id) if not book: - log.info(u"Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id) + log.info("Book (id: %s) in BookShelf (id: %s) not found in book database", book_shelf.book_id, shelf.id) continue tag["Items"].append( { @@ -776,7 +776,7 @@ def create_kobo_tag(shelf): def HandleStateRequest(book_uuid): book = calibre_db.get_book_by_uuid(book_uuid) if not book or not book.data: - log.info(u"Book %s not found in database", book_uuid) + log.info("Book %s not found in database", book_uuid) return redirect_or_proxy_request() kobo_reading_state = get_or_create_reading_state(book.id) @@ -951,7 +951,7 @@ def HandleBookDeletionRequest(book_uuid): log.info("Kobo book delete request received for book %s" % book_uuid) book = calibre_db.get_book_by_uuid(book_uuid) if not book: - log.info(u"Book %s not found in database", book_uuid) + log.info("Book %s not found in database", book_uuid) return redirect_or_proxy_request() book_id = book.id diff --git a/cps/kobo_auth.py b/cps/kobo_auth.py index ea9b71b1..82c140ff 100644 --- a/cps/kobo_auth.py +++ b/cps/kobo_auth.py @@ -112,7 +112,7 @@ def generate_auth_token(user_id): return render_title_template( "generate_kobo_auth_url.html", - title=_(u"Kobo Setup"), + title=_("Kobo Setup"), auth_token=auth_token.auth_token, warning = warning ) diff --git a/cps/oauth_bb.py b/cps/oauth_bb.py index d9a60c0e..389191b9 100644 --- a/cps/oauth_bb.py +++ b/cps/oauth_bb.py @@ -74,7 +74,7 @@ def register_user_with_oauth(user=None): if len(all_oauth.keys()) == 0: return if user is None: - flash(_(u"Register with %(provider)s", provider=", ".join(list(all_oauth.values()))), category="success") + flash(_("Register with %(provider)s", provider=", ".join(list(all_oauth.values()))), category="success") else: for oauth_key in all_oauth.keys(): # Find this OAuth token in the database, or create it @@ -134,8 +134,8 @@ def bind_oauth_or_register(provider_id, provider_user_id, redirect_url, provider # already bind with user, just login if oauth_entry.user: login_user(oauth_entry.user) - log.debug(u"You are now logged in as: '%s'", oauth_entry.user.name) - flash(_(u"you are now logged in as: '%(nickname)s'", nickname= oauth_entry.user.name), + log.debug("You are now logged in as: '%s'", oauth_entry.user.name) + flash(_("Success! You are now logged in as: %(nickname)s", nickname= oauth_entry.user.name), category="success") return redirect(url_for('web.index')) else: @@ -145,21 +145,21 @@ def bind_oauth_or_register(provider_id, provider_user_id, redirect_url, provider try: ub.session.add(oauth_entry) ub.session.commit() - flash(_(u"Link to %(oauth)s Succeeded", oauth=provider_name), category="success") + flash(_("Link to %(oauth)s Succeeded", oauth=provider_name), category="success") log.info("Link to {} Succeeded".format(provider_name)) return redirect(url_for('web.profile')) except Exception as ex: log.error_or_exception(ex) ub.session.rollback() else: - flash(_(u"Login failed, No User Linked With OAuth Account"), category="error") + flash(_("Login failed, No User Linked With OAuth Account"), category="error") log.info('Login failed, No User Linked With OAuth Account') return redirect(url_for('web.login')) # return redirect(url_for('web.login')) # if config.config_public_reg: # return redirect(url_for('web.register')) # else: - # flash(_(u"Public registration is not enabled"), category="error") + # flash(_("Public registration is not enabled"), category="error") # return redirect(url_for(redirect_url)) except (NoResultFound, AttributeError): return redirect(url_for(redirect_url)) @@ -194,15 +194,15 @@ def unlink_oauth(provider): ub.session.delete(oauth_entry) ub.session.commit() logout_oauth_user() - flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success") + flash(_("Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success") log.info("Unlink to {} Succeeded".format(oauth_check[provider])) except Exception as ex: log.error_or_exception(ex) ub.session.rollback() - flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error") + flash(_("Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error") except NoResultFound: log.warning("oauth %s for user %d not found", provider, current_user.id) - flash(_(u"Not Linked to %(oauth)s", oauth=provider), category="error") + flash(_("Not Linked to %(oauth)s", oauth=provider), category="error") return redirect(url_for('web.profile')) def generate_oauth_blueprints(): @@ -258,13 +258,13 @@ if ub.oauth_support: @oauth_authorized.connect_via(oauthblueprints[0]['blueprint']) def github_logged_in(blueprint, token): if not token: - flash(_(u"Failed to log in with GitHub."), category="error") + flash(_("Failed to log in with GitHub."), category="error") log.error("Failed to log in with GitHub") return False resp = blueprint.session.get("/user") if not resp.ok: - flash(_(u"Failed to fetch user info from GitHub."), category="error") + flash(_("Failed to fetch user info from GitHub."), category="error") log.error("Failed to fetch user info from GitHub") return False @@ -276,13 +276,13 @@ if ub.oauth_support: @oauth_authorized.connect_via(oauthblueprints[1]['blueprint']) def google_logged_in(blueprint, token): if not token: - flash(_(u"Failed to log in with Google."), category="error") + flash(_("Failed to log in with Google."), category="error") log.error("Failed to log in with Google") return False resp = blueprint.session.get("/oauth2/v2/userinfo") if not resp.ok: - flash(_(u"Failed to fetch user info from Google."), category="error") + flash(_("Failed to fetch user info from Google."), category="error") log.error("Failed to fetch user info from Google") return False @@ -329,10 +329,10 @@ def github_login(): if account_info.ok: account_info_json = account_info.json() return bind_oauth_or_register(oauthblueprints[0]['id'], account_info_json['id'], 'github.login', 'github') - flash(_(u"GitHub Oauth error, please retry later."), category="error") + flash(_("GitHub Oauth error, please retry later."), category="error") log.error("GitHub Oauth error, please retry later") except (InvalidGrantError, TokenExpiredError) as e: - flash(_(u"GitHub Oauth error: {}").format(e), category="error") + flash(_("GitHub Oauth error: {}").format(e), category="error") log.error(e) return redirect(url_for('web.login')) @@ -353,10 +353,10 @@ def google_login(): if resp.ok: account_info_json = resp.json() return bind_oauth_or_register(oauthblueprints[1]['id'], account_info_json['id'], 'google.login', 'google') - flash(_(u"Google Oauth error, please retry later."), category="error") + flash(_("Google Oauth error, please retry later."), category="error") log.error("Google Oauth error, please retry later") except (InvalidGrantError, TokenExpiredError) as e: - flash(_(u"Google Oauth error: {}").format(e), category="error") + flash(_("Google Oauth error: {}").format(e), category="error") log.error(e) return redirect(url_for('web.login')) diff --git a/cps/remotelogin.py b/cps/remotelogin.py index 037979ea..ee434670 100644 --- a/cps/remotelogin.py +++ b/cps/remotelogin.py @@ -58,8 +58,8 @@ def remote_login(): ub.session.add(auth_token) ub.session_commit() verify_url = url_for('remotelogin.verify_token', token=auth_token.auth_token, _external=true) - log.debug(u"Remot Login request with token: %s", auth_token.auth_token) - return render_title_template('remote_login.html', title=_(u"Login"), token=auth_token.auth_token, + log.debug("Remot Login request with token: %s", auth_token.auth_token) + return render_title_template('remote_login.html', title=_("Login"), token=auth_token.auth_token, verify_url=verify_url, page="remotelogin") @@ -71,8 +71,8 @@ def verify_token(token): # Token not found if auth_token is None: - flash(_(u"Token not found"), category="error") - log.error(u"Remote Login token not found") + flash(_("Token not found"), category="error") + log.error("Remote Login token not found") return redirect(url_for('web.index')) # Token expired @@ -80,8 +80,8 @@ def verify_token(token): ub.session.delete(auth_token) ub.session_commit() - flash(_(u"Token has expired"), category="error") - log.error(u"Remote Login token expired") + flash(_("Token has expired"), category="error") + log.error("Remote Login token expired") return redirect(url_for('web.index')) # Update token with user information @@ -89,8 +89,8 @@ def verify_token(token): auth_token.verified = True ub.session_commit() - flash(_(u"Success! Please return to your device"), category="success") - log.debug(u"Remote Login token for userid %s verified", auth_token.user_id) + flash(_("Success! Please return to your device"), category="success") + log.debug("Remote Login token for userid %s verified", auth_token.user_id) return redirect(url_for('web.index')) @@ -105,7 +105,7 @@ def token_verified(): # Token not found if auth_token is None: data['status'] = 'error' - data['message'] = _(u"Token not found") + data['message'] = _("Token not found") # Token expired elif datetime.now() > auth_token.expiration: @@ -113,7 +113,7 @@ def token_verified(): ub.session_commit() data['status'] = 'error' - data['message'] = _(u"Token has expired") + data['message'] = _("Token has expired") elif not auth_token.verified: data['status'] = 'not_verified' @@ -126,8 +126,8 @@ def token_verified(): ub.session_commit("User {} logged in via remotelogin, token deleted".format(user.name)) data['status'] = 'success' - log.debug(u"Remote Login for userid %s succeeded", user.id) - flash(_(u"you are now logged in as: '%(nickname)s'", nickname=user.name), category="success") + log.debug("Remote Login for userid %s succeeded", user.id) + flash(_("Success! You are now logged in as: %(nickname)s", nickname=user.name), category="success") response = make_response(json.dumps(data, ensure_ascii=False)) response.headers["Content-Type"] = "application/json; charset=utf-8" diff --git a/cps/render_template.py b/cps/render_template.py index 04a50bbb..74462f9f 100644 --- a/cps/render_template.py +++ b/cps/render_template.py @@ -59,7 +59,7 @@ def get_sidebar_config(kwargs=None): "show_text": _('Show Top Rated Books'), "config_show": True}) sidebar.append({"glyph": "glyphicon-eye-open", "text": _('Read Books'), "link": 'web.books_list', "id": "read", "visibility": constants.SIDEBAR_READ_AND_UNREAD, 'public': (not g.user.is_anonymous), - "page": "read", "show_text": _('Show read and unread'), "config_show": content}) + "page": "read", "show_text": _('Show Read and Unread'), "config_show": content}) sidebar.append( {"glyph": "glyphicon-eye-close", "text": _('Unread Books'), "link": 'web.books_list', "id": "unread", "visibility": constants.SIDEBAR_READ_AND_UNREAD, 'public': (not g.user.is_anonymous), "page": "unread", @@ -69,31 +69,31 @@ def get_sidebar_config(kwargs=None): "show_text": _('Show Random Books'), "config_show": True}) sidebar.append({"glyph": "glyphicon-inbox", "text": _('Categories'), "link": 'web.category_list', "id": "cat", "visibility": constants.SIDEBAR_CATEGORY, 'public': True, "page": "category", - "show_text": _('Show category selection'), "config_show": True}) + "show_text": _('Show Category Section'), "config_show": True}) sidebar.append({"glyph": "glyphicon-bookmark", "text": _('Series'), "link": 'web.series_list', "id": "serie", "visibility": constants.SIDEBAR_SERIES, 'public': True, "page": "series", - "show_text": _('Show series selection'), "config_show": True}) + "show_text": _('Show Series Section'), "config_show": True}) sidebar.append({"glyph": "glyphicon-user", "text": _('Authors'), "link": 'web.author_list', "id": "author", "visibility": constants.SIDEBAR_AUTHOR, 'public': True, "page": "author", - "show_text": _('Show author selection'), "config_show": True}) + "show_text": _('Show Author Section'), "config_show": True}) sidebar.append( {"glyph": "glyphicon-text-size", "text": _('Publishers'), "link": 'web.publisher_list', "id": "publisher", "visibility": constants.SIDEBAR_PUBLISHER, 'public': True, "page": "publisher", - "show_text": _('Show publisher selection'), "config_show":True}) + "show_text": _('Show Publisher Section'), "config_show":True}) sidebar.append({"glyph": "glyphicon-flag", "text": _('Languages'), "link": 'web.language_overview', "id": "lang", "visibility": constants.SIDEBAR_LANGUAGE, 'public': (g.user.filter_language() == 'all'), "page": "language", - "show_text": _('Show language selection'), "config_show": True}) + "show_text": _('Show Language Section'), "config_show": True}) sidebar.append({"glyph": "glyphicon-star-empty", "text": _('Ratings'), "link": 'web.ratings_list', "id": "rate", "visibility": constants.SIDEBAR_RATING, 'public': True, - "page": "rating", "show_text": _('Show ratings selection'), "config_show": True}) + "page": "rating", "show_text": _('Show Ratings Section'), "config_show": True}) sidebar.append({"glyph": "glyphicon-file", "text": _('File formats'), "link": 'web.formats_list', "id": "format", "visibility": constants.SIDEBAR_FORMAT, 'public': True, - "page": "format", "show_text": _('Show file formats selection'), "config_show": True}) + "page": "format", "show_text": _('Show File Formats Section'), "config_show": True}) sidebar.append( {"glyph": "glyphicon-trash", "text": _('Archived Books'), "link": 'web.books_list', "id": "archived", "visibility": constants.SIDEBAR_ARCHIVED, 'public': (not g.user.is_anonymous), "page": "archived", - "show_text": _('Show archived books'), "config_show": content}) + "show_text": _('Show Archived Books'), "config_show": content}) if not simple: sidebar.append( {"glyph": "glyphicon-th-list", "text": _('Books List'), "link": 'web.books_table', "id": "list", diff --git a/cps/search.py b/cps/search.py index 17d54b4e..3effeb7b 100644 --- a/cps/search.py +++ b/cps/search.py @@ -45,7 +45,7 @@ def simple_search(): return render_title_template('search.html', searchterm="", result_count=0, - title=_(u"Search"), + title=_("Search"), page="search") @@ -185,14 +185,14 @@ def extend_search_term(searchterm, searchterm.extend((author_name.replace('|', ','), book_title, publisher)) if pub_start: try: - searchterm.extend([_(u"Published after ") + + searchterm.extend([_("Published after ") + format_date(datetime.strptime(pub_start, "%Y-%m-%d"), format='medium')]) except ValueError: pub_start = u"" if pub_end: try: - searchterm.extend([_(u"Published before ") + + searchterm.extend([_("Published before ") + format_date(datetime.strptime(pub_end, "%Y-%m-%d"), format='medium')]) except ValueError: @@ -214,11 +214,11 @@ def extend_search_term(searchterm, language_names = calibre_db.speaking_language(language_names) searchterm.extend(language.name for language in language_names) if rating_high: - searchterm.extend([_(u"Rating <= %(rating)s", rating=rating_high)]) + searchterm.extend([_("Rating <= %(rating)s", rating=rating_high)]) if rating_low: - searchterm.extend([_(u"Rating >= %(rating)s", rating=rating_low)]) + searchterm.extend([_("Rating >= %(rating)s", rating=rating_low)]) if read_status: - searchterm.extend([_(u"Read Status = %(status)s", status=read_status)]) + searchterm.extend([_("Read Status = %(status)s", status=read_status)]) searchterm.extend(ext for ext in tags['include_extension']) searchterm.extend(ext for ext in tags['exclude_extension']) # handle custom columns @@ -279,7 +279,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): )]) cc_present = True elif term.get('custom_column_' + str(c.id)): - search_term.extend([(u"{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) + search_term.extend([("{}: {}".format(c.name, term.get('custom_column_' + str(c.id))))]) cc_present = True if any(tags.values()) or author_name or book_title or publisher or pub_start or pub_end or rating_low \ @@ -339,7 +339,7 @@ def render_adv_search_results(term, offset=None, order=None, limit=None): pagination=pagination, entries=entries, result_count=result_count, - title=_(u"Advanced Search"), page="advsearch", + title=_("Advanced Search"), page="advsearch", order=order[1]) @@ -371,7 +371,7 @@ def render_prepare_search_form(cc): else: languages = None return render_title_template('search_form.html', tags=tags, languages=languages, extensions=extensions, - series=series,shelves=shelves, title=_(u"Advanced Search"), cc=cc, page="advsearch") + series=series,shelves=shelves, title=_("Advanced Search"), cc=cc, page="advsearch") def render_search_results(term, offset=None, order=None, limit=None): @@ -389,7 +389,7 @@ def render_search_results(term, offset=None, order=None, limit=None): adv_searchterm=term, entries=entries, result_count=result_count, - title=_(u"Search"), + title=_("Search"), page="search", order=order[1]) diff --git a/cps/shelf.py b/cps/shelf.py index 9ddc0d1a..04f7a6a6 100644 --- a/cps/shelf.py +++ b/cps/shelf.py @@ -46,13 +46,13 @@ def add_to_shelf(shelf_id, book_id): if shelf is None: log.error("Invalid shelf specified: %s", shelf_id) if not xhr: - flash(_(u"Invalid shelf specified"), category="error") + flash(_("Invalid shelf specified"), category="error") return redirect(url_for('web.index')) return "Invalid shelf specified", 400 if not check_shelf_edit_permissions(shelf): if not xhr: - flash(_(u"Sorry you are not allowed to add a book to that shelf"), category="error") + flash(_("Sorry you are not allowed to add a book to that shelf"), category="error") return redirect(url_for('web.index')) return "Sorry you are not allowed to add a book to the that shelf", 403 @@ -61,7 +61,7 @@ def add_to_shelf(shelf_id, book_id): if book_in_shelf: log.error("Book %s is already part of %s", book_id, shelf) if not xhr: - flash(_(u"Book is already part of the shelf: %(shelfname)s", shelfname=shelf.name), category="error") + flash(_("Book is already part of the shelf: %(shelfname)s", shelfname=shelf.name), category="error") return redirect(url_for('web.index')) return "Book is already part of the shelf: %s" % shelf.name, 400 @@ -79,14 +79,14 @@ def add_to_shelf(shelf_id, book_id): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") if "HTTP_REFERER" in request.environ: return redirect(request.environ["HTTP_REFERER"]) else: return redirect(url_for('web.index')) if not xhr: log.debug("Book has been added to shelf: {}".format(shelf.name)) - flash(_(u"Book has been added to shelf: %(sname)s", sname=shelf.name), category="success") + flash(_("Book has been added to shelf: %(sname)s", sname=shelf.name), category="success") if "HTTP_REFERER" in request.environ: return redirect(request.environ["HTTP_REFERER"]) else: @@ -100,12 +100,12 @@ def search_to_shelf(shelf_id): shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() if shelf is None: log.error("Invalid shelf specified: {}".format(shelf_id)) - flash(_(u"Invalid shelf specified"), category="error") + flash(_("Invalid shelf specified"), category="error") return redirect(url_for('web.index')) if not check_shelf_edit_permissions(shelf): log.warning("You are not allowed to add a book to the shelf".format(shelf.name)) - flash(_(u"You are not allowed to add a book to the shelf"), category="error") + flash(_("You are not allowed to add a book to the shelf"), category="error") return redirect(url_for('web.index')) if current_user.id in ub.searched_ids and ub.searched_ids[current_user.id]: @@ -123,7 +123,7 @@ def search_to_shelf(shelf_id): if not books_for_shelf: log.error("Books are already part of {}".format(shelf.name)) - flash(_(u"Books are already part of the shelf: %(name)s", name=shelf.name), category="error") + flash(_("Books are already part of the shelf: %(name)s", name=shelf.name), category="error") return redirect(url_for('web.index')) maxOrder = ub.session.query(func.max(ub.BookShelf.order)).filter(ub.BookShelf.shelf == shelf_id).first()[0] or 0 @@ -135,14 +135,14 @@ def search_to_shelf(shelf_id): try: ub.session.merge(shelf) ub.session.commit() - flash(_(u"Books have been added to shelf: %(sname)s", sname=shelf.name), category="success") + flash(_("Books have been added to shelf: %(sname)s", sname=shelf.name), category="success") except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") else: log.error("Could not add books to shelf: {}".format(shelf.name)) - flash(_(u"Could not add books to shelf: %(sname)s", sname=shelf.name), category="error") + flash(_("Could not add books to shelf: %(sname)s", sname=shelf.name), category="error") return redirect(url_for('web.index')) @@ -182,13 +182,13 @@ def remove_from_shelf(shelf_id, book_id): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") if "HTTP_REFERER" in request.environ: return redirect(request.environ["HTTP_REFERER"]) else: return redirect(url_for('web.index')) if not xhr: - flash(_(u"Book has been removed from shelf: %(sname)s", sname=shelf.name), category="success") + flash(_("Book has been removed from shelf: %(sname)s", sname=shelf.name), category="success") if "HTTP_REFERER" in request.environ: return redirect(request.environ["HTTP_REFERER"]) else: @@ -197,7 +197,7 @@ def remove_from_shelf(shelf_id, book_id): else: if not xhr: log.warning("You are not allowed to remove a book from shelf: {}".format(shelf.name)) - flash(_(u"Sorry you are not allowed to remove a book from this shelf"), + flash(_("Sorry you are not allowed to remove a book from this shelf"), category="error") return redirect(url_for('web.index')) return "Sorry you are not allowed to remove a book from this shelf", 403 @@ -207,7 +207,7 @@ def remove_from_shelf(shelf_id, book_id): @login_required def create_shelf(): shelf = ub.Shelf() - return create_edit_shelf(shelf, page_title=_(u"Create a Shelf"), page="shelfcreate") + return create_edit_shelf(shelf, page_title=_("Create a Shelf"), page="shelfcreate") @shelf.route("/shelf/edit/", methods=["GET", "POST"]) @@ -215,9 +215,9 @@ def create_shelf(): def edit_shelf(shelf_id): shelf = ub.session.query(ub.Shelf).filter(ub.Shelf.id == shelf_id).first() if not check_shelf_edit_permissions(shelf): - flash(_(u"Sorry you are not allowed to edit this shelf"), category="error") + flash(_("Sorry you are not allowed to edit this shelf"), category="error") return redirect(url_for('web.index')) - return create_edit_shelf(shelf, page_title=_(u"Edit a shelf"), page="shelfedit", shelf_id=shelf_id) + return create_edit_shelf(shelf, page_title=_("Edit a shelf"), page="shelfedit", shelf_id=shelf_id) @shelf.route("/shelf/delete/", methods=["POST"]) @@ -232,7 +232,7 @@ def delete_shelf(shelf_id): except InvalidRequestError as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return redirect(url_for('web.index')) @@ -269,7 +269,7 @@ def order_shelf(shelf_id): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") result = list() if shelf: @@ -278,7 +278,7 @@ def order_shelf(shelf_id): .add_columns(calibre_db.common_filters().label("visible")) \ .filter(ub.BookShelf.shelf == shelf_id).order_by(ub.BookShelf.order.asc()).all() return render_title_template('shelf_order.html', entries=result, - title=_(u"Change order of Shelf: '%(name)s'", name=shelf.name), + title=_("Change order of Shelf: '%(name)s'", name=shelf.name), shelf=shelf, page="shelforder") else: abort(404) @@ -310,7 +310,7 @@ def create_edit_shelf(shelf, page_title, page, shelf_id=False): if request.method == "POST": to_save = request.form.to_dict() if not current_user.role_edit_shelfs() and to_save.get("is_public") == "on": - flash(_(u"Sorry you are not allowed to create a public shelf"), category="error") + flash(_("Sorry you are not allowed to create a public shelf"), category="error") return redirect(url_for('web.index')) is_public = 1 if to_save.get("is_public") == "on" else 0 if config.config_kobo_sync: @@ -327,24 +327,24 @@ def create_edit_shelf(shelf, page_title, page, shelf_id=False): shelf.user_id = int(current_user.id) ub.session.add(shelf) shelf_action = "created" - flash_text = _(u"Shelf %(title)s created", title=shelf_title) + flash_text = _("Shelf %(title)s created", title=shelf_title) else: shelf_action = "changed" - flash_text = _(u"Shelf %(title)s changed", title=shelf_title) + flash_text = _("Shelf %(title)s changed", title=shelf_title) try: ub.session.commit() - log.info(u"Shelf {} {}".format(shelf_title, shelf_action)) + log.info("Shelf {} {}".format(shelf_title, shelf_action)) flash(flash_text, category="success") return redirect(url_for('shelf.show_shelf', shelf_id=shelf.id)) except (OperationalError, InvalidRequestError) as ex: ub.session.rollback() log.error_or_exception(ex) log.error_or_exception("Settings Database error: {}".format(ex)) - flash(_(u"Database error: %(error)s.", error=ex.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=ex.orig), category="error") except Exception as ex: ub.session.rollback() log.error_or_exception(ex) - flash(_(u"There was an error"), category="error") + flash(_("There was an error"), category="error") return render_title_template('shelf_edit.html', shelf=shelf, title=page_title, @@ -366,7 +366,7 @@ def check_shelf_is_unique(title, is_public, shelf_id=False): if not is_shelf_name_unique: log.error("A public shelf with the name '{}' already exists.".format(title)) - flash(_(u"A public shelf with the name '%(title)s' already exists.", title=title), + flash(_("A public shelf with the name '%(title)s' already exists.", title=title), category="error") else: is_shelf_name_unique = ub.session.query(ub.Shelf) \ @@ -377,7 +377,7 @@ def check_shelf_is_unique(title, is_public, shelf_id=False): if not is_shelf_name_unique: log.error("A private shelf with the name '{}' already exists.".format(title)) - flash(_(u"A private shelf with the name '%(title)s' already exists.", title=title), + flash(_("A private shelf with the name '%(title)s' already exists.", title=title), category="error") return is_shelf_name_unique @@ -454,14 +454,14 @@ def render_show_shelf(shelf_type, shelf_id, page_no, sort_param): except (OperationalError, InvalidRequestError) as e: ub.session.rollback() log.error_or_exception("Settings Database error: {}".format(e)) - flash(_(u"Database error: %(error)s.", error=e.orig), category="error") + flash(_("Oops! Database Error: %(error)s.", error=e.orig), category="error") return render_title_template(page, entries=result, pagination=pagination, - title=_(u"Shelf: '%(name)s'", name=shelf.name), + title=_("Shelf: '%(name)s'", name=shelf.name), shelf=shelf, page="shelf") else: - flash(_(u"Error opening shelf. Shelf does not exist or is not accessible"), category="error") + flash(_("Error opening shelf. Shelf does not exist or is not accessible"), category="error") return redirect(url_for("web.index")) diff --git a/cps/static/js/caliBlur.js b/cps/static/js/caliBlur.js index d9309aeb..ec394d0b 100755 --- a/cps/static/js/caliBlur.js +++ b/cps/static/js/caliBlur.js @@ -655,7 +655,7 @@ $("#sendbtn").attr({ $("#sendbtn2").attr({ "data-toggle-two": "tooltip", - "title": $("#sendbtn2").text(), // "Send to E-Reader", + "title": $("#sendbtn2").text(), // "Send to eReader", "data-placement": "bottom", "data-viewport": ".btn-toolbar" }) diff --git a/cps/tasks/convert.py b/cps/tasks/convert.py index 48fd528e..8f2f924a 100755 --- a/cps/tasks/convert.py +++ b/cps/tasks/convert.py @@ -70,7 +70,7 @@ class TaskConvert(CalibreTask): df.GetContentFile(datafile) worker_db.session.close() else: - error_message = _(u"%(format)s not found on Google Drive: %(fn)s", + error_message = _("%(format)s not found on Google Drive: %(fn)s", format=self.settings['old_book_format'], fn=data.name + "." + self.settings['old_book_format'].lower()) worker_db.session.close() @@ -89,7 +89,7 @@ class TaskConvert(CalibreTask): # if we're sending to E-Reader after converting, create a one-off task and run it immediately # todo: figure out how to incorporate this into the progress try: - EmailText = N_(u"%(book)s send to E-Reader", book=escape(self.title)) + EmailText = N_("%(book)s send to E-Reader", book=escape(self.title)) worker_thread.add(self.user, TaskEmail(self.settings['subject'], self.results["path"], filename, @@ -133,7 +133,7 @@ class TaskConvert(CalibreTask): local_db.session.rollback() log.error("Database error: %s", e) local_db.session.close() - self._handleError(N_("Database error: %(error)s.", error=e)) + self._handleError(N_("Oops! Database Error: %(error)s.", error=e)) return self._handleSuccess() local_db.session.close() @@ -150,7 +150,7 @@ class TaskConvert(CalibreTask): else: # check if calibre converter-executable is existing if not os.path.exists(config.config_converterpath): - self._handleError(N_(u"Calibre ebook-convert %(tool)s not found", tool=config.config_converterpath)) + self._handleError(N_("Calibre ebook-convert %(tool)s not found", tool=config.config_converterpath)) return check, error_message = self._convert_calibre(file_path, format_old_ext, format_new_ext) @@ -199,7 +199,7 @@ class TaskConvert(CalibreTask): try: p = process_open(command, quotes) except OSError as e: - return 1, N_(u"Kepubify-converter failed: %(error)s", error=e) + return 1, N_("Kepubify-converter failed: %(error)s", error=e) self.progress = 0.01 while True: nextline = p.stdout.readlines() @@ -220,7 +220,7 @@ class TaskConvert(CalibreTask): copyfile(converted_file[0], (file_path + format_new_ext)) os.unlink(converted_file[0]) else: - return 1, N_(u"Converted file not found or more than one file in folder %(folder)s", + return 1, N_("Converted file not found or more than one file in folder %(folder)s", folder=os.path.dirname(file_path)) return check, None @@ -244,7 +244,7 @@ class TaskConvert(CalibreTask): p = process_open(command, quotes, newlines=False) except OSError as e: - return 1, N_(u"Ebook-converter failed: %(error)s", error=e) + return 1, N_("Ebook-converter failed: %(error)s", error=e) while p.poll() is None: nextline = p.stdout.readline() diff --git a/cps/tasks/mail.py b/cps/tasks/mail.py index 139e6bff..6d6ab937 100755 --- a/cps/tasks/mail.py +++ b/cps/tasks/mail.py @@ -152,7 +152,7 @@ class TaskEmail(CalibreTask): main_type, sub_type = content_type.split('/', 1) message.add_attachment(data, maintype=main_type, subtype=sub_type, filename=self.attachment) else: - self._handleError(u"Attachment not found") + self._handleError("Attachment not found") return return message diff --git a/cps/tasks_status.py b/cps/tasks_status.py index e5f91975..35350f68 100644 --- a/cps/tasks_status.py +++ b/cps/tasks_status.py @@ -45,7 +45,7 @@ def get_tasks_status(): # if current user admin, show all email, otherwise only own emails tasks = WorkerThread.get_instance().tasks answer = render_task_status(tasks) - return render_title_template('tasks.html', entries=answer, title=_(u"Tasks"), page="tasks") + return render_title_template('tasks.html', entries=answer, title=_("Tasks"), page="tasks") # helper function to apply localize status information in tasklist entries diff --git a/cps/templates/admin.html b/cps/templates/admin.html old mode 100755 new mode 100644 index 4d6eff95..1199b21f --- a/cps/templates/admin.html +++ b/cps/templates/admin.html @@ -11,8 +11,8 @@ - - + + @@ -59,7 +59,7 @@
-

{{_('E-mail Server Settings')}}

+

{{_('Email Server Settings')}}

{% if config.get_mail_server_configured() %} {% if email.mail_server_type == 0 %}
@@ -80,24 +80,24 @@
{{email.mail_login}}
-
{{_('From E-mail')}}
+
{{_('From Email')}}
{{email.mail_from}}
{% else %}
-
{{_('E-Mail Service')}}
+
{{_('Email Service')}}
{{_('Gmail via Oauth2')}}
-
{{_('From E-mail')}}
+
{{_('From Email')}}
{{email.mail_gmail_token['email']}}
{% endif %} {% endif %} - {{_('Edit E-mail Server Settings')}} + {{_('Edit Email Server Settings')}}
@@ -167,15 +167,15 @@

{{_('Scheduled Tasks')}}

-
{{_('Time at which tasks start to run')}}
+
{{_('Start Time')}}
{{schedule_time}}
-
{{_('Maximum tasks duration')}}
+
{{_('Maximum Duration')}}
{{schedule_duration}}
-
{{_('Generate book cover thumbnails')}}
+
{{_('Generate Thumbnails')}}
{{ display_bool_setting(config.schedule_generate_book_covers) }}
-
{{_('Reconnect to Calibre Library')}}
+
{{_('Reconnect Calibre Database')}}
{{ display_bool_setting(config.schedule_reconnect) }}
{{_('Edit Scheduled Tasks Settings')}} {% if config.schedule_generate_book_covers %} - {{_('Refresh Thumbnail Cover Cache')}} + {{_('Refresh Thumbnail Cache')}} {% endif %} @@ -224,7 +224,7 @@ - +
{{_('Username')}}{{_('E-mail Address')}}{{_('Send to E-Reader E-mail Address')}}{{_('Email')}}{{_('Send to eReader Email')}} {{_('Downloads')}}
{{commit}} {{_('Current version')}}{{_('Current Version')}}
diff --git a/cps/templates/config_edit.html b/cps/templates/config_edit.html index f61ca9a5..815fb162 100644 --- a/cps/templates/config_edit.html +++ b/cps/templates/config_edit.html @@ -124,7 +124,7 @@
- +
diff --git a/cps/templates/detail.html b/cps/templates/detail.html old mode 100755 new mode 100644 index 50151603..d6c8f42f --- a/cps/templates/detail.html +++ b/cps/templates/detail.html @@ -10,7 +10,7 @@