Fix #756736 (Tweaks not translated)

This commit is contained in:
Kovid Goyal 2011-04-10 15:43:48 -06:00
parent e35860a2b2
commit 0e8f01a545
5 changed files with 751 additions and 346 deletions

View File

@ -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=''):

View File

@ -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

View File

@ -28,7 +28,7 @@ class FB2Output(OutputFormatPlugin):
'sf_horror', # Horror & mystic 'sf_horror', # Horror & mystic
'sf_humor', # Humor 'sf_humor', # Humor
'sf_fantasy', # Fantasy 'sf_fantasy', # Fantasy
'sf', # Science Fiction 'sf', # Science Fiction
# Detectives & Thrillers # Detectives & Thrillers
'det_classic', # Classical detectives 'det_classic', # Classical detectives
'det_police', # Police Stories 'det_police', # Police Stories
@ -41,20 +41,20 @@ class FB2Output(OutputFormatPlugin):
'det_maniac', # Maniacs 'det_maniac', # Maniacs
'det_hard', # Hard#boiled 'det_hard', # Hard#boiled
'thriller', # Thrillers 'thriller', # Thrillers
'detective', # Detectives 'detective', # Detectives
# Prose # Prose
'prose_classic', # Classics prose 'prose_classic', # Classics prose
'prose_history', # Historical prose 'prose_history', # Historical prose
'prose_contemporary', # Contemporary prose 'prose_contemporary', # Contemporary prose
'prose_counter', # Counterculture 'prose_counter', # Counterculture
'prose_rus_classic', # Russial classics prose 'prose_rus_classic', # Russial classics prose
'prose_su_classics', # Soviet classics prose 'prose_su_classics', # Soviet classics prose
# Romance # Romance
'love_contemporary', # Contemporary Romance 'love_contemporary', # Contemporary Romance
'love_history', # Historical Romance 'love_history', # Historical Romance
'love_detective', # Detective Romance 'love_detective', # Detective Romance
'love_short', # Short Romance 'love_short', # Short Romance
'love_erotica', # Erotica 'love_erotica', # Erotica
# Adventure # Adventure
'adv_western', # Western 'adv_western', # Western
'adv_history', # History 'adv_history', # History
@ -62,7 +62,7 @@ class FB2Output(OutputFormatPlugin):
'adv_maritime', # Maritime Fiction 'adv_maritime', # Maritime Fiction
'adv_geo', # Travel & geography 'adv_geo', # Travel & geography
'adv_animal', # Nature & animals 'adv_animal', # Nature & animals
'adventure', # Other 'adventure', # Other
# Children's # Children's
'child_tale', # Fairy Tales 'child_tale', # Fairy Tales
'child_verse', # Verses 'child_verse', # Verses
@ -71,17 +71,17 @@ class FB2Output(OutputFormatPlugin):
'child_det', # Detectives & Thrillers 'child_det', # Detectives & Thrillers
'child_adv', # Adventures 'child_adv', # Adventures
'child_education', # Educational 'child_education', # Educational
'children', # Other 'children', # Other
# Poetry & Dramaturgy # Poetry & Dramaturgy
'poetry', # Poetry 'poetry', # Poetry
'dramaturgy', # Dramaturgy 'dramaturgy', # Dramaturgy
# Antique literature # Antique literature
'antique_ant', # Antique 'antique_ant', # Antique
'antique_european', # European 'antique_european', # European
'antique_russian', # Old russian 'antique_russian', # Old russian
'antique_east', # Old east 'antique_east', # Old east
'antique_myths', # Myths. Legends. Epos 'antique_myths', # Myths. Legends. Epos
'antique', # Other 'antique', # Other
# Scientific#educational # Scientific#educational
'sci_history', # History 'sci_history', # History
'sci_psychology', # Psychology 'sci_psychology', # Psychology
@ -98,7 +98,7 @@ class FB2Output(OutputFormatPlugin):
'sci_chem', # Chemistry 'sci_chem', # Chemistry
'sci_biology', # Biology 'sci_biology', # Biology
'sci_tech', # Technical 'sci_tech', # Technical
'science', # Other 'science', # Other
# Computers & Internet # Computers & Internet
'comp_www', # Internet 'comp_www', # Internet
'comp_programming', # Programming 'comp_programming', # Programming
@ -106,29 +106,29 @@ class FB2Output(OutputFormatPlugin):
'comp_soft', # Software 'comp_soft', # Software
'comp_db', # Databases 'comp_db', # Databases
'comp_osnet', # OS & Networking 'comp_osnet', # OS & Networking
'computers', # Other 'computers', # Other
# Reference # Reference
'ref_encyc', # Encyclopedias 'ref_encyc', # Encyclopedias
'ref_dict', # Dictionaries 'ref_dict', # Dictionaries
'ref_ref', # Reference 'ref_ref', # Reference
'ref_guide', # Guidebooks 'ref_guide', # Guidebooks
'reference', # Other 'reference', # Other
# Nonfiction # Nonfiction
'nonf_biography', # Biography & Memoirs 'nonf_biography', # Biography & Memoirs
'nonf_publicism', # Publicism 'nonf_publicism', # Publicism
'nonf_criticism', # Criticism 'nonf_criticism', # Criticism
'design', # Art & design 'design', # Art & design
'nonfiction', # Other 'nonfiction', # Other
# Religion & Inspiration # Religion & Inspiration
'religion_rel', # Religion 'religion_rel', # Religion
'religion_esoterics', # Esoterics 'religion_esoterics', # Esoterics
'religion_self', # Self#improvement 'religion_self', # Self#improvement
'religion', # Other 'religion', # Other
# Humor # Humor
'humor_anecdote', # Anecdote (funny stories) 'humor_anecdote', # Anecdote (funny stories)
'humor_prose', # Prose 'humor_prose', # Prose
'humor_verse', # Verses 'humor_verse', # Verses
'humor', # Other 'humor', # Other
# Home & Family # Home & Family
'home_cooking', # Cooking 'home_cooking', # Cooking
'home_pets', # Pets 'home_pets', # Pets
@ -155,14 +155,14 @@ 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.')),
]) ])
def convert(self, oeb_book, output_path, input_plugin, opts, log): def convert(self, oeb_book, output_path, input_plugin, opts, log):
from calibre.ebooks.oeb.transforms.jacket import linearize_jacket from calibre.ebooks.oeb.transforms.jacket import linearize_jacket
from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable from calibre.ebooks.oeb.transforms.rasterize import SVGRasterizer, Unavailable
try: try:
rasterizer = SVGRasterizer() rasterizer = SVGRasterizer()
rasterizer(oeb_book, opts) rasterizer(oeb_book, opts)

View File

@ -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