1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-21 05:31:30 +02:00

Removed gettext related functions

This commit is contained in:
2020-05-03 19:00:20 +02:00
parent 35445cb736
commit 212cb56d42
92 changed files with 1505 additions and 1605 deletions
+11 -9
View File
@@ -1458,12 +1458,13 @@ class AZW3Container(Container):
with open(pathtoazw3, 'rb') as stream:
raw = stream.read(3)
if raw == b'TPZ':
raise InvalidMobi(_('This is not a MOBI file. It is a Topaz file.'))
raise InvalidMobi('This is not a MOBI file. It is a Topaz '
'file.')
try:
header = MetadataHeader(stream, default_log)
except MobiError:
raise InvalidMobi(_('This is not a MOBI file.'))
raise InvalidMobi('This is not a MOBI file.')
if header.encryption_type != 0:
raise DRMError()
@@ -1471,15 +1472,16 @@ class AZW3Container(Container):
kf8_type = header.kf8_type
if kf8_type is None:
raise InvalidMobi(_('This MOBI file does not contain a KF8 format '
'book. KF8 is the new format from Amazon. calibre can '
'only edit MOBI files that contain KF8 books. Older '
'MOBI files without KF8 are not editable.'))
raise InvalidMobi('This MOBI file does not contain a KF8 '
'format book. KF8 is the new format from '
'Amazon. calibre can only edit MOBI files '
'that contain KF8 books. Older MOBI files '
'without KF8 are not editable.')
if kf8_type == 'joint':
raise InvalidMobi(_('This MOBI file contains both KF8 and '
'older Mobi6 data. calibre can only edit MOBI files '
'that contain only KF8 data.'))
raise InvalidMobi('This MOBI file contains both KF8 and older '
'Mobi6 data. calibre can only edit MOBI '
'files that contain only KF8 data.')
try:
opf_path, obfuscated_fonts = fork_job(
+8 -9
View File
@@ -167,20 +167,19 @@ def remove_unused_css(container, report=None, remove_unused_classes=False, merge
num_changes = num_of_removed_rules + num_merged + num_of_removed_classes
if num_changes > 0:
if num_of_removed_rules > 0:
report(ngettext('Removed one unused CSS style rule', 'Removed {} unused CSS style rules',
num_of_removed_rules).format(num_of_removed_rules))
report('Removed {} unused CSS style '
'rules'.format(num_of_removed_rules))
if num_of_removed_classes > 0:
report(ngettext('Removed one unused class from the HTML', 'Removed {} unused classes from the HTML',
num_of_removed_classes).format(num_of_removed_classes))
report('Removed {} unused classes from the HTML'
.format(num_of_removed_classes))
if num_merged > 0:
report(ngettext('Merged one CSS style rule', 'Merged {} CSS style rules',
num_merged).format(num_merged))
report('Merged {} CSS style rules'.format(num_merged))
if num_of_removed_rules == 0:
report(_('No unused CSS style rules found'))
report('No unused CSS style rules found')
if remove_unused_classes and num_of_removed_classes == 0:
report(_('No unused class attributes found'))
report('No unused class attributes found')
if merge_rules and num_merged == 0:
report(_('No style rules that could be merged found'))
report('No style rules that could be merged found')
return num_changes > 0
+2 -1
View File
@@ -13,7 +13,8 @@ class InvalidBook(ValueError):
class DRMError(_DRMError):
def __init__(self):
super(DRMError, self).__init__(_('This file is locked with DRM. It cannot be edited.'))
super(DRMError, self).__init__('This file is locked with DRM. It '
'cannot be edited.')
class MalformedMarkup(ValueError):
+2 -2
View File
@@ -157,7 +157,7 @@ def smarten_punctuation(container, report):
newhtml = smarten_punctuation(html, container.log)
if newhtml != html:
changed = True
report(_('Smartened punctuation in: %s')%name)
report('Smartened punctuation in: %s' % name)
newhtml = strip_encoding_declarations(newhtml)
f.seek(0)
f.truncate()
@@ -171,7 +171,7 @@ def smarten_punctuation(container, report):
container.dirty(name)
smartened = True
if not smartened:
report(_('No punctuation that could be smartened found'))
report('No punctuation that could be smartened found')
return smartened
+4 -3
View File
@@ -194,8 +194,9 @@ def split(container, name, loc_or_xpath, before=True, totals=None):
try:
split_point = node_from_loc(root, loc_or_xpath, totals=totals)
except MalformedMarkup:
raise MalformedMarkup(_('The file %s has malformed markup. Try running the Fix HTML tool'
' before splitting') % name)
raise MalformedMarkup('The file %s has malformed markup. Try '
'running the Fix HTML tool before '
'splitting' % name)
container.replace(name, root)
if in_table(split_point):
raise AbortError('Cannot split inside tables')
@@ -269,7 +270,7 @@ def multisplit(container, name, xpath, before=True):
root = container.parsed(name)
nodes = root.xpath(xpath, namespaces=XPNSMAP)
if not nodes:
raise AbortError(_('The expression %s did not match any nodes') % xpath)
raise AbortError('The expression %s did not match any nodes' % xpath)
for split_point in nodes:
if in_table(split_point):
raise AbortError('Cannot split inside tables')
+13 -12
View File
@@ -240,17 +240,17 @@ def verify_toc_destinations(container, toc):
name = item.dest
if not name:
item.dest_exists = False
item.dest_error = _('No file named %s exists')%name
item.dest_error = 'No file named %s exists' % name
continue
try:
root = container.parsed(name)
except KeyError:
item.dest_exists = False
item.dest_error = _('No file named %s exists')%name
item.dest_error = 'No file named %s exists' % name
continue
if not hasattr(root, 'xpath'):
item.dest_exists = False
item.dest_error = _('No HTML file named %s exists')%name
item.dest_error = 'No HTML file named %s exists' % name
continue
if not item.frag:
item.dest_exists = True
@@ -259,9 +259,8 @@ def verify_toc_destinations(container, toc):
anchor_map[name] = frozenset(anchor_xpath(root))
item.dest_exists = item.frag in anchor_map[name]
if not item.dest_exists:
item.dest_error = _(
'The anchor %(a)s does not exist in file %(f)s')%dict(
a=item.frag, f=name)
item.dest_error = ('The anchor %(a)s does not exist in file '
'%(f)s' % dict(a=item.frag, f=name))
def find_existing_ncx_toc(container):
@@ -370,7 +369,7 @@ def elem_to_toc_text(elem):
text = re.sub(r'\s+', ' ', text.strip())
text = text[:1000].strip()
if not text:
text = _('(Untitled)')
text = '(Untitled)'
return text
@@ -533,8 +532,9 @@ def from_files(container):
text = find_text(body[0])
if not text:
text = name.rpartition('/')[-1]
if i == 0 and text.rpartition('.')[0].lower() in {'titlepage', 'cover'}:
text = _('Cover')
if i == 0 and text.rpartition('.')[0].lower() in {'titlepage',
'cover'}:
text = 'Cover'
toc.add(text, name)
return toc
@@ -563,8 +563,9 @@ def add_id(container, name, loc, totals=None):
try:
node = node_from_loc(root, loc, totals=totals)
except MalformedMarkup:
raise MalformedMarkup(_('The file %s has malformed markup. Try running the Fix HTML tool'
' before editing.') % name)
raise MalformedMarkup('The file %s has malformed markup. Try '
'running the Fix HTML tool before '
'editing.' % name)
container.replace(name, root)
if not node.get('id'):
@@ -641,7 +642,7 @@ def commit_ncx_toc(container, toc, lang=None, uid=None):
if m:
uid = xml2text(m[0])
title = _('Table of Contents')
title = 'Table of Contents'
m = container.opf_xpath('//dc:title')
if m:
x = xml2text(m[0]).strip()