mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix #756736 (Tweaks not translated)
This commit is contained in:
parent
e35860a2b2
commit
0e8f01a545
@ -170,8 +170,8 @@ from setup import __appname__, __version__ as version
|
|||||||
# there.
|
# there.
|
||||||
pot_header = '''\
|
pot_header = '''\
|
||||||
# Translation template file..
|
# Translation template file..
|
||||||
# Copyright (C) 2007 Kovid Goyal
|
# Copyright (C) %(year)s Kovid Goyal
|
||||||
# Kovid Goyal <kovid@kovidgoyal.net>, 2007.
|
# Kovid Goyal <kovid@kovidgoyal.net>, %(year)s.
|
||||||
#
|
#
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -185,7 +185,7 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\\n"
|
"Content-Transfer-Encoding: 8bit\\n"
|
||||||
"Generated-By: pygettext.py %%(version)s\\n"
|
"Generated-By: pygettext.py %%(version)s\\n"
|
||||||
|
|
||||||
'''%dict(appname=__appname__, version=version)
|
'''%dict(appname=__appname__, version=version, year=time.strftime('%Y'))
|
||||||
|
|
||||||
|
|
||||||
def usage(code, msg=''):
|
def usage(code, msg=''):
|
||||||
|
@ -26,6 +26,38 @@ class POT(Command):
|
|||||||
ans.append(os.path.abspath(os.path.join(root, name)))
|
ans.append(os.path.abspath(os.path.join(root, name)))
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
|
def get_tweaks_docs(self):
|
||||||
|
path = self.a(self.j(self.SRC, '..', 'resources', 'default_tweaks.py'))
|
||||||
|
with open(path, 'rb') as f:
|
||||||
|
raw = f.read().decode('utf-8')
|
||||||
|
msgs = []
|
||||||
|
lines = list(raw.splitlines())
|
||||||
|
for i, line in enumerate(lines):
|
||||||
|
if line.startswith('#:'):
|
||||||
|
msgs.append((i, line[2:].strip()))
|
||||||
|
j = i
|
||||||
|
block = []
|
||||||
|
while True:
|
||||||
|
j += 1
|
||||||
|
line = lines[j]
|
||||||
|
if not line.startswith('#'):
|
||||||
|
break
|
||||||
|
block.append(line[1:].strip())
|
||||||
|
if block:
|
||||||
|
msgs.append((i+1, '\n'.join(block)))
|
||||||
|
|
||||||
|
ans = []
|
||||||
|
for lineno, msg in msgs:
|
||||||
|
ans.append('#: %s:%d'%(path, lineno))
|
||||||
|
slash = unichr(92)
|
||||||
|
msg = msg.replace(slash, slash*2).replace('"', r'\"').replace('\n',
|
||||||
|
r'\n').replace('\r', r'\r').replace('\t', r'\t')
|
||||||
|
ans.append('msgid "%s"'%msg)
|
||||||
|
ans.append('msgstr ""')
|
||||||
|
ans.append('')
|
||||||
|
|
||||||
|
return '\n'.join(ans)
|
||||||
|
|
||||||
|
|
||||||
def run(self, opts):
|
def run(self, opts):
|
||||||
files = self.source_files()
|
files = self.source_files()
|
||||||
@ -35,10 +67,10 @@ class POT(Command):
|
|||||||
atexit.register(shutil.rmtree, tempdir)
|
atexit.register(shutil.rmtree, tempdir)
|
||||||
pygettext(buf, ['-k', '__', '-p', tempdir]+files)
|
pygettext(buf, ['-k', '__', '-p', tempdir]+files)
|
||||||
src = buf.getvalue()
|
src = buf.getvalue()
|
||||||
|
src += '\n\n' + self.get_tweaks_docs()
|
||||||
pot = os.path.join(self.PATH, __appname__+'.pot')
|
pot = os.path.join(self.PATH, __appname__+'.pot')
|
||||||
f = open(pot, 'wb')
|
with open(pot, 'wb') as f:
|
||||||
f.write(src)
|
f.write(src)
|
||||||
f.close()
|
|
||||||
self.info('Translations template:', os.path.abspath(pot))
|
self.info('Translations template:', os.path.abspath(pot))
|
||||||
return pot
|
return pot
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ class FB2Output(OutputFormatPlugin):
|
|||||||
OptionRecommendation(name='fb2_genre',
|
OptionRecommendation(name='fb2_genre',
|
||||||
recommended_value='antique', level=OptionRecommendation.LOW,
|
recommended_value='antique', level=OptionRecommendation.LOW,
|
||||||
choices=FB2_GENRES,
|
choices=FB2_GENRES,
|
||||||
help=_('Genre for the book. Choices: %s\n\n See: ' % FB2_GENRES) + 'http://www.fictionbook.org/index.php/Eng:FictionBook_2.1_genres ' \
|
help=(_('Genre for the book. Choices: %s\n\n See: ') % FB2_GENRES) + 'http://www.fictionbook.org/index.php/Eng:FictionBook_2.1_genres ' \
|
||||||
+ _('for a complete list with descriptions.')),
|
+ _('for a complete list with descriptions.')),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ from calibre.utils.config import read_raw_tweaks, write_tweaks
|
|||||||
from calibre.gui2.widgets import PythonHighlighter
|
from calibre.gui2.widgets import PythonHighlighter
|
||||||
from calibre import isbytestring
|
from calibre import isbytestring
|
||||||
|
|
||||||
from PyQt4.Qt import QAbstractListModel, Qt, QStyledItemDelegate, QStyle, \
|
from PyQt4.Qt import (QAbstractListModel, Qt, QStyledItemDelegate, QStyle,
|
||||||
QStyleOptionViewItem, QFont, QDialogButtonBox, QDialog, \
|
QStyleOptionViewItem, QFont, QDialogButtonBox, QDialog,
|
||||||
QVBoxLayout, QPlainTextEdit, QLabel
|
QVBoxLayout, QPlainTextEdit, QLabel)
|
||||||
|
|
||||||
class Delegate(QStyledItemDelegate): # {{{
|
class Delegate(QStyledItemDelegate): # {{{
|
||||||
def __init__(self, view):
|
def __init__(self, view):
|
||||||
@ -35,8 +35,9 @@ class Delegate(QStyledItemDelegate): # {{{
|
|||||||
class Tweak(object): # {{{
|
class Tweak(object): # {{{
|
||||||
|
|
||||||
def __init__(self, name, doc, var_names, defaults, custom):
|
def __init__(self, name, doc, var_names, defaults, custom):
|
||||||
self.name = name
|
translate = __builtins__['_']
|
||||||
self.doc = doc.strip()
|
self.name = translate(name)
|
||||||
|
self.doc = translate(doc.strip())
|
||||||
self.var_names = var_names
|
self.var_names = var_names
|
||||||
self.default_values = {}
|
self.default_values = {}
|
||||||
for x in var_names:
|
for x in var_names:
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user