mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-05 08:40:13 -04:00
Mark various CLI strings for translation
This commit is contained in:
parent
5693efad98
commit
8b6a6802b7
@ -10,7 +10,7 @@ del init_calibre
|
||||
from sphinx.util.console import bold
|
||||
|
||||
sys.path.append(os.path.abspath('../../../'))
|
||||
from calibre.linux import entry_points
|
||||
from calibre.linux import entry_points, cli_index_strings
|
||||
from epub import EPUBHelpBuilder
|
||||
from latex import LaTeXHelpBuilder
|
||||
|
||||
@ -34,9 +34,7 @@ Command Line Interface
|
||||
.. image:: ../../images/cli.png
|
||||
|
||||
.. note::
|
||||
On OS X, the command line tools are inside the |app| bundle, for example,
|
||||
if you installed calibre in :file:`/Applications` the command line tools
|
||||
are in :file:`/Applications/calibre.app/Contents/MacOS/calibre`.
|
||||
%s
|
||||
|
||||
Documented Commands
|
||||
--------------------
|
||||
@ -51,8 +49,7 @@ Undocumented Commands
|
||||
|
||||
{undocumented}
|
||||
|
||||
You can see usage for undocumented commands by executing them without arguments
|
||||
in a terminal.
|
||||
%s
|
||||
'''
|
||||
|
||||
CLI_PREAMBLE='''\
|
||||
@ -114,20 +111,12 @@ def generate_calibredb_help(preamble, app):
|
||||
update_cli_doc('calibredb', raw, app)
|
||||
|
||||
def generate_ebook_convert_help(preamble, app):
|
||||
from calibre.ebooks.conversion.cli import create_option_parser
|
||||
from calibre.ebooks.conversion.cli import create_option_parser, manual_index_strings
|
||||
from calibre.customize.ui import input_format_plugins, output_format_plugins
|
||||
from calibre.utils.logging import default_log
|
||||
preamble = re.sub(r'http.*\.html', ':ref:`conversion`', preamble)
|
||||
raw = preamble + textwrap.dedent('''
|
||||
The options and default values for the options change depending on both the
|
||||
input and output formats, so you should always check with::
|
||||
|
||||
ebook-convert myfile.input_format myfile.output_format -h
|
||||
|
||||
Below are the options that are common to all conversion, followed by the
|
||||
options specific to every input and output format
|
||||
|
||||
''')
|
||||
raw = preamble + '\n\n' + manual_index_strings() % 'ebook-convert myfile.input_format myfile.output_format -h'
|
||||
parser, plumber = create_option_parser(['ebook-convert',
|
||||
'dummyi.mobi', 'dummyo.epub', '-h'], default_log)
|
||||
groups = [(None, None, parser.option_list)]
|
||||
@ -225,7 +214,7 @@ def cli_docs(app):
|
||||
documented = [' '*4 + c[0] for c in documented_cmds]
|
||||
undocumented = [' * ' + c for c in undocumented_cmds]
|
||||
|
||||
raw = CLI_INDEX.format(documented='\n'.join(documented),
|
||||
raw = (CLI_INDEX % cli_index_strings()).format(documented='\n'.join(documented),
|
||||
undocumented='\n'.join(undocumented))
|
||||
if not os.path.exists('cli'):
|
||||
os.makedirs('cli')
|
||||
|
@ -29,51 +29,51 @@ You can also use %prog to run standalone scripts. To do that use it like this:
|
||||
|
||||
Everything after the -- is passed to the script.
|
||||
'''))
|
||||
parser.add_option('-c', '--command', help='Run python code.')
|
||||
parser.add_option('-e', '--exec-file', help='Run the python code in file.')
|
||||
parser.add_option('-f', '--subset-font', help='Subset the specified font')
|
||||
parser.add_option('-c', '--command', help=_('Run python code.'))
|
||||
parser.add_option('-e', '--exec-file', help=_('Run the python code in file.'))
|
||||
parser.add_option('-f', '--subset-font', help=_('Subset the specified font'))
|
||||
parser.add_option('-d', '--debug-device-driver', default=False, action='store_true',
|
||||
help='Debug device detection')
|
||||
help=_('Debug device detection'))
|
||||
parser.add_option('-g', '--gui', default=False, action='store_true',
|
||||
help='Run the GUI with debugging enabled. Debug output is '
|
||||
'printed to stdout and stderr.')
|
||||
help=_('Run the GUI with debugging enabled. Debug output is '
|
||||
'printed to stdout and stderr.'))
|
||||
parser.add_option('--gui-debug', default=None,
|
||||
help='Run the GUI with a debug console, logging to the'
|
||||
help=_('Run the GUI with a debug console, logging to the'
|
||||
' specified path. For internal use only, use the -g'
|
||||
' option to run the GUI in debug mode',)
|
||||
' option to run the GUI in debug mode'))
|
||||
parser.add_option('--show-gui-debug', default=None,
|
||||
help='Display the specified log file. For internal use'
|
||||
' only.',)
|
||||
help=_('Display the specified log file. For internal use'
|
||||
' only.'))
|
||||
parser.add_option('-w', '--viewer', default=False, action='store_true',
|
||||
help='Run the ebook viewer',)
|
||||
help=_('Run the ebook viewer in debug mode'))
|
||||
parser.add_option('--paths', default=False, action='store_true',
|
||||
help='Output the paths necessary to setup the calibre environment')
|
||||
help=_('Output the paths necessary to setup the calibre environment'))
|
||||
parser.add_option('--add-simple-plugin', default=None,
|
||||
help='Add a simple plugin (i.e. a plugin that consists of only a '
|
||||
help=_('Add a simple plugin (i.e. a plugin that consists of only a '
|
||||
'.py file), by specifying the path to the py file containing the '
|
||||
'plugin code.')
|
||||
'plugin code.'))
|
||||
parser.add_option('--reinitialize-db', default=None,
|
||||
help='Re-initialize the sqlite calibre database at the '
|
||||
'specified path. Useful to recover from db corruption.')
|
||||
parser.add_option('-p', '--py-console', help='Run python console',
|
||||
help=_('Re-initialize the sqlite calibre database at the '
|
||||
'specified path. Useful to recover from db corruption.'))
|
||||
parser.add_option('-p', '--py-console', help=_('Run python console'),
|
||||
default=False, action='store_true')
|
||||
parser.add_option('-m', '--inspect-mobi', action='store_true',
|
||||
default=False,
|
||||
help='Inspect the MOBI file(s) at the specified path(s)')
|
||||
help=_('Inspect the MOBI file(s) at the specified path(s)'))
|
||||
parser.add_option('-t', '--edit-book', action='store_true',
|
||||
help='Launch the calibre Edit Book tool in debug mode.')
|
||||
help=_('Launch the calibre Edit Book tool in debug mode.'))
|
||||
parser.add_option('-x', '--explode-book', default=None,
|
||||
help='Explode the book (exports the book as a collection of HTML '
|
||||
help=_('Explode the book (exports the book as a collection of HTML '
|
||||
'files and metadata, which you can edit using standard HTML '
|
||||
'editing tools, and then rebuilds the file from the edited HTML. '
|
||||
'Makes no additional changes to the HTML, unlike a full calibre '
|
||||
'conversion).')
|
||||
'conversion).'))
|
||||
parser.add_option('-s', '--shutdown-running-calibre', default=False,
|
||||
action='store_true',
|
||||
help=_('Cause a running calibre instance, if any, to be'
|
||||
' shutdown. Note that if there are running jobs, they '
|
||||
'will be silently aborted, so use with care.'))
|
||||
parser.add_option('--test-build', help='Test binary modules in build',
|
||||
parser.add_option('--test-build', help=_('Test binary modules in build'),
|
||||
action='store_true', default=False)
|
||||
parser.add_option('-r', '--run-plugin', help=_(
|
||||
'Run a plugin that provides a command line interface. For example:\n'
|
||||
|
@ -370,6 +370,17 @@ def main(args=sys.argv):
|
||||
|
||||
return 0
|
||||
|
||||
def manual_index_strings():
|
||||
return _('''\
|
||||
The options and default values for the options change depending on both the
|
||||
input and output formats, so you should always check with::
|
||||
|
||||
%s
|
||||
|
||||
Below are the options that are common to all conversion, followed by the
|
||||
options specific to every input and output format.''')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
|
@ -139,7 +139,7 @@ def option_parser():
|
||||
parser.add_option('--dont-output-resources', default=True, action='store_false',
|
||||
help=_('Do not save embedded image and font files to disk'),
|
||||
dest='output_resources')
|
||||
parser.add_option('--verbose', default=False, action='store_true', dest='verbose')
|
||||
parser.add_option('--verbose', default=False, action='store_true', dest='verbose', help=_('Be more verbose'))
|
||||
return parser
|
||||
|
||||
def main(args=sys.argv, logger=None):
|
||||
|
@ -7,7 +7,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import sys, textwrap
|
||||
import sys
|
||||
from io import BytesIO
|
||||
from threading import Event
|
||||
|
||||
@ -21,24 +21,23 @@ from calibre.ebooks.metadata.sources.identify import identify
|
||||
from calibre.ebooks.metadata.sources.covers import download_cover
|
||||
|
||||
def option_parser():
|
||||
parser = OptionParser(textwrap.dedent(
|
||||
'''\
|
||||
%prog [options]
|
||||
parser = OptionParser(_('''\
|
||||
%prog [options]
|
||||
|
||||
Fetch book metadata from online sources. You must specify at least one
|
||||
of title, authors or ISBN.
|
||||
'''
|
||||
Fetch book metadata from online sources. You must specify at least one
|
||||
of title, authors or ISBN.
|
||||
'''
|
||||
))
|
||||
parser.add_option('-t', '--title', help='Book title')
|
||||
parser.add_option('-a', '--authors', help='Book author(s)')
|
||||
parser.add_option('-i', '--isbn', help='Book ISBN')
|
||||
parser.add_option('-t', '--title', help=_('Book title'))
|
||||
parser.add_option('-a', '--authors', help=_('Book author(s)'))
|
||||
parser.add_option('-i', '--isbn', help=_('Book ISBN'))
|
||||
parser.add_option('-v', '--verbose', default=False, action='store_true',
|
||||
help='Print the log to the console (stderr)')
|
||||
parser.add_option('-o', '--opf', help='Output the metadata in OPF format instead of human readable text.', action='store_true', default=False)
|
||||
help=_('Print the log to the console (stderr)'))
|
||||
parser.add_option('-o', '--opf', help=_('Output the metadata in OPF format instead of human readable text.'), action='store_true', default=False)
|
||||
parser.add_option('-c', '--cover',
|
||||
help='Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.')
|
||||
help=_('Specify a filename. The cover, if available, will be saved to it. Without this option, no cover will be downloaded.'))
|
||||
parser.add_option('-d', '--timeout', default='30',
|
||||
help='Timeout in seconds. Default is 30')
|
||||
help=_('Timeout in seconds. Default is 30'))
|
||||
|
||||
return parser
|
||||
|
||||
|
@ -861,7 +861,7 @@ def load_builtin_fonts():
|
||||
def setup_gui_option_parser(parser):
|
||||
if islinux:
|
||||
parser.add_option('--detach', default=False, action='store_true',
|
||||
help='Detach from the controlling terminal, if any (linux only)')
|
||||
help=_('Detach from the controlling terminal, if any (linux only)'))
|
||||
|
||||
def detach_gui():
|
||||
if islinux and not DEBUG:
|
||||
|
@ -266,21 +266,21 @@ def file_renderer(stream, opts, parent=None, logger=None):
|
||||
|
||||
def option_parser():
|
||||
from calibre.gui2.main_window import option_parser
|
||||
parser = option_parser('''\
|
||||
parser = option_parser(_('''\
|
||||
%prog [options] book.lrf
|
||||
|
||||
Read the LRF ebook book.lrf
|
||||
''')
|
||||
'''))
|
||||
parser.add_option('--verbose', default=False, action='store_true', dest='verbose',
|
||||
help='Print more information about the rendering process')
|
||||
parser.add_option('--visual-debug', help='Turn on visual aids to debugging the rendering engine',
|
||||
help=_('Print more information about the rendering process'))
|
||||
parser.add_option('--visual-debug', help=_('Turn on visual aids to debugging the rendering engine'),
|
||||
default=False, action='store_true', dest='visual_debug')
|
||||
parser.add_option('--disable-hyphenation', dest='hyphenate', default=True, action='store_false',
|
||||
help='Disable hyphenation. Should significantly speed up rendering.')
|
||||
help=_('Disable hyphenation. Should significantly speed up rendering.'))
|
||||
parser.add_option('--white-background', dest='white_background', default=False, action='store_true',
|
||||
help='By default the background is off white as I find this easier on the eyes. Use this option to make the background pure white.')
|
||||
help=_('By default the background is off white as I find this easier on the eyes. Use this option to make the background pure white.'))
|
||||
parser.add_option('--profile', dest='profile', default=False, action='store_true',
|
||||
help='Profile the LRF renderer')
|
||||
help=_('Profile the LRF renderer'))
|
||||
return parser
|
||||
|
||||
def normalize_settings(parser, opts):
|
||||
|
@ -25,12 +25,12 @@ class AbortInit(Exception):
|
||||
pass
|
||||
|
||||
def option_parser():
|
||||
parser = _option_parser('''\
|
||||
parser = _option_parser(_('''\
|
||||
%prog [opts] [path_to_ebook]
|
||||
|
||||
Launch the main calibre Graphical User Interface and optionally add the ebook at
|
||||
path_to_ebook to the database.
|
||||
''')
|
||||
'''))
|
||||
parser.add_option('--with-library', default=None, action='store',
|
||||
help=_('Use the library located at the specified path.'))
|
||||
parser.add_option('--start-in-tray', default=False, action='store_true',
|
||||
|
@ -32,7 +32,7 @@ def server_config(defaults=None):
|
||||
c.add_opt('username', ['--username'], default='calibre',
|
||||
help=_('Username for access. By default, it is: %default'))
|
||||
c.add_opt('develop', ['--develop'], default=False,
|
||||
help='Development mode. Server automatically restarts on file changes and serves code files (html, css, js) from the file system instead of calibre\'s resource system.')
|
||||
help=_('Development mode. Server automatically restarts on file changes and serves code files (html, css, js) from the file system instead of calibre\'s resource system.'))
|
||||
c.add_opt('max_cover', ['--max-cover'], default='600x800',
|
||||
help=_('The maximum size for displayed covers. Default is %default.'))
|
||||
c.add_opt('max_opds_items', ['--max-opds-items'], default=30,
|
||||
|
@ -54,7 +54,7 @@ The OPDS interface is advertised via BonJour automatically.
|
||||
parser.add_option('--pidfile', default=None,
|
||||
help=_('Write process PID to the specified file'))
|
||||
parser.add_option('--daemonize', default=False, action='store_true',
|
||||
help='Run process in background as a daemon. No effect on windows.')
|
||||
help=_('Run process in background as a daemon. No effect on windows.'))
|
||||
parser.add_option('--restriction', '--virtual-library', default=None,
|
||||
help=_('Specifies a virtual library to be used for this invocation. '
|
||||
'This option overrides any per-library settings specified'
|
||||
|
@ -1100,6 +1100,13 @@ def main():
|
||||
PostInstall(opts)
|
||||
return 0
|
||||
|
||||
def cli_index_strings():
|
||||
return _('On OS X, the command line tools are inside the |app| bundle, for example,'
|
||||
' if you installed calibre in :file:`/Applications` the command line tools'
|
||||
' are in :file:`/Applications/calibre.app/Contents/MacOS/calibre`.'), _(
|
||||
'You can see usage for undocumented commands by executing them without arguments in a terminal.')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
|
||||
|
@ -149,52 +149,51 @@ def option_parser():
|
||||
OptionParser
|
||||
except ImportError:
|
||||
from optparse import OptionParser
|
||||
import textwrap
|
||||
parser = OptionParser(textwrap.dedent('''\
|
||||
%prog [options] [from to text]
|
||||
parser = OptionParser(_('''\
|
||||
%prog [options] [from to text]
|
||||
|
||||
Send mail using the SMTP protocol. %prog has two modes of operation. In the
|
||||
compose mode you specify from to and text and these are used to build and
|
||||
send an email message. In the filter mode, %prog reads a complete email
|
||||
message from STDIN and sends it.
|
||||
Send mail using the SMTP protocol. %prog has two modes of operation. In the
|
||||
compose mode you specify from to and text and these are used to build and
|
||||
send an email message. In the filter mode, %prog reads a complete email
|
||||
message from STDIN and sends it.
|
||||
|
||||
text is the body of the email message.
|
||||
If text is not specified, a complete email message is read from STDIN.
|
||||
from is the email address of the sender and to is the email address
|
||||
of the recipient. When a complete email is read from STDIN, from and to
|
||||
are only used in the SMTP negotiation, the message headers are not modified.
|
||||
'''))
|
||||
text is the body of the email message.
|
||||
If text is not specified, a complete email message is read from STDIN.
|
||||
from is the email address of the sender and to is the email address
|
||||
of the recipient. When a complete email is read from STDIN, from and to
|
||||
are only used in the SMTP negotiation, the message headers are not modified.
|
||||
'''))
|
||||
c=parser.add_option_group('COMPOSE MAIL',
|
||||
'Options to compose an email. Ignored if text is not specified').add_option
|
||||
c('-a', '--attachment', help='File to attach to the email')
|
||||
c('-s', '--subject', help='Subject of the email')
|
||||
_('Options to compose an email. Ignored if text is not specified')).add_option
|
||||
c('-a', '--attachment', help=_('File to attach to the email'))
|
||||
c('-s', '--subject', help=_('Subject of the email'))
|
||||
|
||||
parser.add_option('-l', '--localhost',
|
||||
help=('Host name of localhost. Used when connecting '
|
||||
help=_('Host name of localhost. Used when connecting '
|
||||
'to SMTP server.'))
|
||||
r=parser.add_option_group('SMTP RELAY',
|
||||
'Options to use an SMTP relay server to send mail. '
|
||||
_('Options to use an SMTP relay server to send mail. '
|
||||
'calibre will try to send the email directly unless --relay is '
|
||||
'specified.').add_option
|
||||
r('-r', '--relay', help=('An SMTP relay server to use to send mail.'))
|
||||
'specified.')).add_option
|
||||
r('-r', '--relay', help=_('An SMTP relay server to use to send mail.'))
|
||||
r('-p', '--port', default=-1,
|
||||
help='Port to connect to on relay server. Default is to use 465 if '
|
||||
'encryption method is SSL and 25 otherwise.')
|
||||
r('-u', '--username', help='Username for relay')
|
||||
r('-p', '--password', help='Password for relay')
|
||||
help=_('Port to connect to on relay server. Default is to use 465 if '
|
||||
'encryption method is SSL and 25 otherwise.'))
|
||||
r('-u', '--username', help=_('Username for relay'))
|
||||
r('-p', '--password', help=_('Password for relay'))
|
||||
r('-e', '--encryption-method', default='TLS',
|
||||
choices=['TLS', 'SSL', 'NONE'],
|
||||
help='Encryption method to use when connecting to relay. Choices are '
|
||||
'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure')
|
||||
parser.add_option('-o', '--outbox', help='Path to maildir folder to store '
|
||||
'failed email messages in.')
|
||||
help=_('Encryption method to use when connecting to relay. Choices are '
|
||||
'TLS, SSL and NONE. Default is TLS. WARNING: Choosing NONE is highly insecure'))
|
||||
parser.add_option('-o', '--outbox', help=_('Path to maildir folder to store '
|
||||
'failed email messages in.'))
|
||||
parser.add_option('-f', '--fork', default=False, action='store_true',
|
||||
help='Fork and deliver message in background. '
|
||||
help=_('Fork and deliver message in background. '
|
||||
'If you use this option, you should also use --outbox '
|
||||
'to handle delivery failures.')
|
||||
parser.add_option('-t', '--timeout', help='Timeout for connection')
|
||||
'to handle delivery failures.'))
|
||||
parser.add_option('-t', '--timeout', help=_('Timeout for connection'))
|
||||
parser.add_option('-v', '--verbose', default=0, action='count',
|
||||
help='Be more verbose')
|
||||
help=_('Be more verbose'))
|
||||
return parser
|
||||
|
||||
def extract_email_address(raw):
|
||||
|
Loading…
x
Reference in New Issue
Block a user