mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
IGN:More translatable phrases in Mobipocket output
This commit is contained in:
commit
5da7a6af7e
2
setup.py
2
setup.py
@ -121,7 +121,7 @@ if __name__ == '__main__':
|
||||
buf = cStringIO.StringIO()
|
||||
print 'Creating translations template'
|
||||
tempdir = tempfile.mkdtemp()
|
||||
pygettext(buf, ['-p', tempdir]+files)
|
||||
pygettext(buf, ['-k', '__', '-p', tempdir]+files)
|
||||
src = buf.getvalue()
|
||||
pot = os.path.join(tempdir, 'calibre.pot')
|
||||
f = open(pot, 'wb')
|
||||
|
@ -535,27 +535,36 @@ class Spine(object):
|
||||
|
||||
class Guide(object):
|
||||
class Reference(object):
|
||||
_TYPES_TITLES = [('cover', 'Cover'), ('title-page', 'Title Page'),
|
||||
('toc', 'Table of Contents'), ('index', 'Index'),
|
||||
('glossary', 'Glossary'), ('acknowledgements', 'Acknowledgements'),
|
||||
('bibliography', 'Bibliography'), ('colophon', 'Colophon'),
|
||||
('copyright-page', 'Copyright'), ('dedication', 'Dedication'),
|
||||
('epigraph', 'Epigraph'), ('foreword', 'Foreword'),
|
||||
('loi', 'List of Illustrations'), ('lot', 'List of Tables'),
|
||||
('notes', 'Notes'), ('preface', 'Preface'),
|
||||
('text', 'Main Text')]
|
||||
_TYPES_TITLES = [('cover', __('Cover')),
|
||||
('title-page', __('Title Page')),
|
||||
('toc', __('Table of Contents')),
|
||||
('index', __('Index')),
|
||||
('glossary', __('Glossary')),
|
||||
('acknowledgements', __('Acknowledgements')),
|
||||
('bibliography', __('Bibliography')),
|
||||
('colophon', __('Colophon')),
|
||||
('copyright-page', __('Copyright')),
|
||||
('dedication', __('Dedication')),
|
||||
('epigraph', __('Epigraph')),
|
||||
('foreword', __('Foreword')),
|
||||
('loi', __('List of Illustrations')),
|
||||
('lot', __('List of Tables')),
|
||||
('notes', __('Notes')),
|
||||
('preface', __('Preface')),
|
||||
('text', __('Main Text'))]
|
||||
TYPES = set(t for t, _ in _TYPES_TITLES)
|
||||
TITLES = dict(_TYPES_TITLES)
|
||||
ORDER = dict((t, i) for (t, _), i in izip(_TYPES_TITLES, count(0)))
|
||||
|
||||
def __init__(self, type, title, href):
|
||||
def __init__(self, oeb, type, title, href):
|
||||
self.oeb = oeb
|
||||
if type.lower() in self.TYPES:
|
||||
type = type.lower()
|
||||
elif type not in self.TYPES and \
|
||||
not type.startswith('other.'):
|
||||
type = 'other.' + type
|
||||
if not title:
|
||||
title = self.TITLES.get(type, None)
|
||||
if not title and type in self.TITLES:
|
||||
title = oeb.translate(self.TITLES[type])
|
||||
self.type = type
|
||||
self.title = title
|
||||
self.href = urlnormalize(href)
|
||||
@ -575,12 +584,20 @@ class Guide(object):
|
||||
return NotImplemented
|
||||
return cmp(self._order, other._order)
|
||||
|
||||
def item():
|
||||
def fget(self):
|
||||
path, frag = urldefrag(self.href)
|
||||
hrefs = self.oeb.manifest.hrefs
|
||||
return hrefs.get(path, None)
|
||||
return property(fget=fget)
|
||||
item = item()
|
||||
|
||||
def __init__(self, oeb):
|
||||
self.oeb = oeb
|
||||
self.refs = {}
|
||||
|
||||
def add(self, type, title, href):
|
||||
ref = self.Reference(type, title, href)
|
||||
ref = self.Reference(self.oeb, type, title, href)
|
||||
self.refs[type] = ref
|
||||
return ref
|
||||
|
||||
|
@ -13,6 +13,10 @@ from calibre.ebooks.oeb.base import XML, XHTML, XHTML_NS
|
||||
from calibre.ebooks.oeb.base import XHTML_MIME, CSS_MIME
|
||||
from calibre.ebooks.oeb.base import element
|
||||
|
||||
__all__ = ['HTMLTOCAdder']
|
||||
|
||||
DEFAULT_TITLE = __('Table of Contents')
|
||||
|
||||
STYLE_CSS = {
|
||||
'nested': """
|
||||
.calibre_toc_header {
|
||||
@ -52,7 +56,7 @@ class HTMLTOCAdder(object):
|
||||
if 'toc' in oeb.guide:
|
||||
return
|
||||
oeb.logger.info('Generating in-line TOC...')
|
||||
title = self.title or oeb.translate('Table of Contents')
|
||||
title = self.title or oeb.translate(DEFAULT_TITLE)
|
||||
style = self.style
|
||||
if style not in STYLE_CSS:
|
||||
oeb.logger.error('Unknown TOC style %r' % style)
|
||||
|
@ -13,6 +13,10 @@ from gettext import GNUTranslations
|
||||
import __builtin__
|
||||
__builtin__.__dict__['_'] = lambda s: s
|
||||
|
||||
# For strings which belong in the translation tables, but which shouldn't be
|
||||
# immediately translated to the environment language
|
||||
__builtin__.__dict__['__'] = lambda s: s
|
||||
|
||||
from calibre.constants import iswindows, preferred_encoding, plugins
|
||||
from calibre.utils.config import prefs
|
||||
from calibre.translations.msgfmt import make
|
||||
|
Loading…
x
Reference in New Issue
Block a user