Translation of UI (german and english)

Bugfix for feeds
    - removed categories related and up
    - load new books now working
    - category random now working
login page is free of non accessible elements
boolean custom column is vivible in UI
books with only with certain languages can be shown
book shelfs can be deleted from UI
Anonymous user view is more resticted
Added browse of series in sidebar
Dependencys in vendor folder are updated to newer versions (licencs files are now present)
Bugfix editing Authors names
Made upload on windows working
This commit is contained in:
OzzieIsaacs 2016-11-09 19:24:33 +01:00
parent a6b6700a73
commit bbf6d9b026
1690 changed files with 149106 additions and 35697 deletions

View File

@ -52,23 +52,26 @@ books_languages_link = Table('books_languages_link', Base.metadata,
cc = conn.execute("SELECT id, datatype FROM custom_columns")
cc_ids = []
cc_exceptions = ['bool', 'datetime', 'int', 'comments', 'float', 'composite','series' ]
cc_exceptions = [ 'datetime', 'int', 'comments', 'float', 'composite','series' ]
books_custom_column_links = {}
cc_classes = {}
for row in cc:
if row.datatype not in cc_exceptions:
books_custom_column_links[row.id] = Table('books_custom_column_' + str(row.id) + '_link', Base.metadata,
Column('book', Integer, ForeignKey('books.id'), primary_key=True),
Column('value', Integer, ForeignKey('custom_column_' + str(row.id) + '.id'), primary_key=True)
)
#books_custom_column_links[row.id]=
cc_ids.append(row.id)
cc_classes = {}
for id in cc_ids:
ccdict={'__tablename__':'custom_column_' + str(id),
'id':Column(Integer, primary_key=True),
'value':Column(String)}
cc_classes[id] = type('Custom_Column_' + str(id), (Base,), ccdict)
cc_ids.append([row.id,row.datatype])
if row.datatype == 'bool':
ccdict = {'__tablename__': 'custom_column_' + str(row.id),
'id': Column(Integer, primary_key=True),
'book': Column(Integer,ForeignKey('books.id')),
'value': Column(Boolean)}
else:
ccdict={'__tablename__':'custom_column_' + str(row.id),
'id':Column(Integer, primary_key=True),
'value':Column(String)}
cc_classes[row.id] = type('Custom_Column_' + str(row.id), (Base,), ccdict)
class Comments(Base):
__tablename__ = 'comments'
@ -182,6 +185,7 @@ class Books(Base):
last_modified = Column(String)
path = Column(String)
has_cover = Column(Integer)
uuid = Column(String)
authors = relationship('Authors', secondary=books_authors_link, backref='books')
tags = relationship('Tags', secondary=books_tags_link, backref='books')
@ -205,7 +209,10 @@ class Books(Base):
def __repr__(self):
return u"<Books('{0},{1}{2}{3}{4}{5}{6}{7}{8}')>".format(self.title, self.sort, self.author_sort, self.timestamp, self.pubdate, self.series_index, self.last_modified ,self.path, self.has_cover)
for id in cc_ids:
setattr(Books, 'custom_column_' + str(id), relationship(cc_classes[id], secondary=books_custom_column_links[id], backref='books'))
if id[1] == 'bool':
setattr(Books, 'custom_column_' + str(id[0]), relationship(cc_classes[id[0]], primaryjoin=(Books.id==cc_classes[id[0]].book), backref='books'))
else:
setattr(Books, 'custom_column_' + str(id[0]), relationship(cc_classes[id[0]], secondary=books_custom_column_links[id[0]], backref='books'))
class Custom_Columns(Base):
__tablename__ = 'custom_columns'

View File

@ -18,6 +18,7 @@ from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email.generator import Generator
from flask_babel import gettext as _
import subprocess
def update_download(book_id, user_id):
@ -72,8 +73,8 @@ def send_mail(book_id, kindle_mail):
msg = MIMEMultipart()
msg['From'] = settings["mail_from"]
msg['To'] = kindle_mail
msg['Subject'] = 'Send to Kindle'
text = 'This email has been sent via calibre web.'
msg['Subject'] = _('Send to Kindle')
text = _('This email has been sent via calibre web.')
msg.attach(MIMEText(text))
use_ssl = settings.get('mail_use_ssl', 0)
@ -95,7 +96,7 @@ def send_mail(book_id, kindle_mail):
formats["pdf"] = os.path.join(config.DB_ROOT, book.path, entry.name + ".pdf")
if len(formats) == 0:
return "Could not find any formats suitable for sending by email"
return _("Could not find any formats suitable for sending by email")
if 'mobi' in formats:
msg.attach(get_attachment(formats['mobi']))
@ -104,13 +105,13 @@ def send_mail(book_id, kindle_mail):
if filepath is not None:
msg.attach(get_attachment(filepath))
elif filepath is None:
return "Could not convert epub to mobi"
return _("Could not convert epub to mobi")
elif 'pdf' in formats:
msg.attach(get_attachment(formats['pdf']))
elif 'pdf' in formats:
msg.attach(get_attachment(formats['pdf']))
else:
return "Could not find any formats suitable for sending by email"
return _("Could not find any formats suitable for sending by email")
# convert MIME message to string
fp = StringIO()
@ -134,7 +135,7 @@ def send_mail(book_id, kindle_mail):
mailserver.quit()
except (socket.error, smtplib.SMTPRecipientsRefused, smtplib.SMTPException), e:
app.logger.error(traceback.print_exc())
return "Failed to send mail: %s" % str(e)
return _("Failed to send mail: %s" % str(e))
return None
@ -154,8 +155,8 @@ def get_attachment(file_path):
return attachment
except IOError:
traceback.print_exc()
message = ('The requested file could not be read. Maybe wrong '
'permissions?')
message = (_('The requested file could not be read. Maybe wrong '\
'permissions?'))
return None
def get_valid_filename(value, replace_whitespace=True):

View File

@ -6,6 +6,7 @@
}
body{background:#f2f2f2}body h2{font-weight:normal;color:#444}
body { margin-bottom: 40px;}
a{color: #45b29d}a:hover{color: #444;}
.navigation .nav-head{text-transform:uppercase;color:#999;margin:20px 0}.navigation .nav-head:nth-child(1n+2){border-top:1px solid #ccc;padding-top:20px}
.navigation li a{color:#444;text-decoration:none;display:block;padding:10px}.navigation li a:hover{background:rgba(153,153,153,0.4);border-radius:5px}

View File

@ -131,3 +131,49 @@
}
)
});
var languages = new Bloodhound({
name: 'languages',
datumTokenizer: function(datum) {
return [datum.name];
},
queryTokenizer: function(query) {
return [query];
},
remote: {
url: '/get_languages_json?q=',
replace: function(url, query) {
url_query = url+encodeURIComponent(query);
return url_query;
}
}
});
function language_source(query, cb) {
var bh_adapter = languages.ttAdapter();
var tokens = query.split(",");
var current_language = tokens[tokens.length-1].trim();
tokens.splice(tokens.length-1, 1); // remove last element
var prefix = "";
for (var i = 0; i < tokens.length; i++) {
var tag = tokens[i].trim();
prefix += tag + ", ";
}
prefixed_source(prefix, current_language, cb, bh_adapter);
}
var promise = languages.initialize();
promise.done(function(){
$("#languages").typeahead(
{
highlight: true, minLength: 0,
hint: true
}, {
name: 'languages', displayKey: 'name',
source: language_source
}
)
});

View File

@ -1,11 +0,0 @@
{% extends "layout.html" %}
{% block body %}
<div class="discover">
<h1>{{title}}</h1>
<ul class="list-unstyled">
{% for entry in entries %}
<li><a href="{{url_for('author', name=entry.name)}}">{{entry.sort}}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}

View File

@ -1,11 +0,0 @@
{% extends "layout.html" %}
{% block body %}
<div class="discover">
<h1>{{title}}</h1>
<ul class="list-unstyled">
{% for entry in entries %}
<li><a href="{{url_for('category', name=entry.name)}}">{{entry.name}}</a></li>
{% endfor %}
</ul>
</div>
{% endblock %}

View File

@ -35,13 +35,13 @@
{% endif %}
{% if entry.series|length > 0 %}
<p>Book {{entry.series_index}} of <a href="{{url_for('series', name=entry.series[0].name)}}">{{entry.series[0].name}}</a></p>
<p>{{_('Book')}} {{entry.series_index}} {{_('of')}} <a href="{{url_for('series', name=entry.series[0].name)}}">{{entry.series[0].name}}</a></p>
{% endif %}
{% if entry.languages.__len__() > 0 %}
<div class="languages">
<p>
<span class="label label-default">language: {{entry.languages[0].lang_code}}</span>
<span class="label label-default">{{_('language')}}: {% for language in entry.languages %} {{language.language_name}}{% if not loop.last %},{% endif %}{% endfor %} </span>
</p>
</div>
{% endif %}
@ -69,7 +69,15 @@
{% if c.datatype == 'rating' %}
{{ '%d' % (column.value / 2) }}
{% else %}
{{ column.value }}
{% if c.datatype == 'bool' %}
{% if column.value == true %}
<span class="glyphicon glyphicon-ok"></span>
{% else %}
<span class="glyphicon glyphicon-remove"></span>
{% endif %}
{% else %}
{{ column.value }}
{% endif %}
{% endif %}
{% endfor %}
<br />
@ -81,18 +89,18 @@
{% if entry.comments|length > 0 %}
<h3>Description:</h3>
<h3>{{_('Description:')}}</h3>
{{entry.comments[0].text|safe}}
{% endif %}
{% if g.user.is_authenticated() %}
{% if g.user.is_authenticated %}
<div class="more-stuff">
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group" aria-label="Download, send to Kindle, reading">
<div class="btn-group" role="group">
<button id="btnGroupDrop1" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-download"></span> Download
<span class="glyphicon glyphicon-download"></span> {{_('Download')}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop1">
@ -102,11 +110,11 @@
</ul>
</div>
{% if g.user.kindle_mail %}
<a href="{{url_for('send_to_kindle', book_id=entry.id)}}" id="sendbtn" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> Send to Kindle</a>
<a href="{{url_for('send_to_kindle', book_id=entry.id)}}" id="sendbtn" class="btn btn-primary" role="button"><span class="glyphicon glyphicon-send"></span> {{_('Send to Kindle')}}</a>
{% endif %}
<div class="btn-group" role="group">
<button id="btnGroupDrop2" type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-eye-open"></span> Read in browser
<span class="glyphicon glyphicon-eye-open"></span> {{_('Read in browser')}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop2">
@ -125,7 +133,7 @@
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group" aria-label="Add to shelves">
<button id="btnGroupDrop2" type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-list"></span> Add to shelf
<span class="glyphicon glyphicon-list"></span> {{_('Add to shelf')}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="btnGroupDrop2">
@ -165,7 +173,7 @@
{% if g.user.role_edit() %}
<div class="btn-toolbar" role="toolbar">
<div class="btn-group" role="group" aria-label="Edit/Delete book">
<a href="{{ url_for('edit_book', book_id=entry.id) }}" class="btn btn-sm btn-warning" role="button"><span class="glyphicon glyphicon-edit"></span> Edit metadata</a>
<a href="{{ url_for('edit_book', book_id=entry.id) }}" class="btn btn-sm btn-warning" role="button"><span class="glyphicon glyphicon-edit"></span> {{_('Edit metadata')}}</a>
<!-- <a href="{{ url_for('edit_book', book_id=entry.id) }}" class="btn btn-sm btn-danger" role="button"><span class="glyphicon glyphicon-trash"></span> Delete</a> -->
</div>
{% endif %}

View File

@ -11,42 +11,55 @@
<div class="col-sm-8">
<form role="form" action="{{ url_for('edit_book', book_id=book.id) }}" method="post">
<div class="form-group">
<label for="book_title">Book Title</label>
<label for="book_title">{{_('Book Title')}}</label>
<input type="text" class="form-control" name="book_title" id="book_title" value="{{book.title}}">
</div>
<div class="form-group">
<label for="bookAuthor">Author</label>
<label for="bookAuthor">{{_('Author')}}</label>
<input type="text" class="form-control typeahead" name="author_name" id="bookAuthor" value="{{' & '.join(authors)}}" autocomplete="off">
</div>
<div class="form-group">
<label for="description">Description</label>
<label for="description">{{_('Description')}}</label>
<textarea class="form-control" name="description" id="description" rows="7">{% if book.comments %}{{book.comments[0].text}}{%endif%}</textarea>
</div>
<div class="form-group">
<label for="tags">Tags</label>
<input type="text" class="form-control" name="tags" id="tags" value="{% for tag in book.tags %}{{tag.name.strip()}}, {% endfor %}">
<label for="tags">{{_('Tags')}}</label>
<input type="text" class="form-control typeahead" name="tags" id="tags" value="{% for tag in book.tags %}{{tag.name.strip()}}, {% endfor %}">
</div>
<div class="form-group">
<label for="series">Series</label>
<input type="text" class="form-control" name="series" id="series" value="{% if book.series %}{{book.series[0].name}}{% endif %}">
<label for="series">{{_('Series')}}</label>
<input type="text" class="form-control typeahead" name="series" id="series" value="{% if book.series %}{{book.series[0].name}}{% endif %}">
</div>
<div class="form-group">
<label for="series_index">Series id</label>
<label for="series_index">{{_('Series id')}}</label>
<input type="text" class="form-control" name="series_index" id="series_index" value="{{book.series_index}}">
</div>
<div class="form-group">
<label for="rating">Rating</label>
<label for="rating">{{_('Rating')}}</label>
<input type="number" min="1" max="5" step="1" class="form-control" name="rating" id="rating" value="{% if book.ratings %}{{book.ratings[0].rating / 2}}{% endif %}">
</div>
<div class="form-group">
<label for="cover_url">Cover URL (jpg)</label>
<label for="cover_url">{{_('Cover URL (jpg)')}}</label>
<input type="text" class="form-control" name="cover_url" id="cover_url" value="">
</div>
<div class="form-group">
<label for="languages">{{_('Language')}}</label>
<input type="text" class="form-control typeahead" name="languages" id="languages" value="{% for language in book.languages %}{{language.language_name.strip()}}, {% endfor %}">
</div>
{% if cc|length > 0 %}
{% for c in cc %}
<div class="form-group">
<label for="{{ 'custom_column_' ~ c.id }}">{{ c.name }}</label>
{% if c.datatype == 'bool' %}
<select name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}" class="form-control">
<option value="None" {% if book['custom_column_' ~ c.id]|length == 0 %} selected {% endif %}></option>
<option value="True" {% if book['custom_column_' ~ c.id]|length > 0 %}{% if book['custom_column_' ~ c.id][0].value ==true %}selected{% endif %}{% endif %} >{{_('Yes')}}</option>
<option value="False" {% if book['custom_column_' ~ c.id]|length > 0 %}{% if book['custom_column_' ~ c.id][0].value ==false %}selected{% endif %}{% endif %}>{{_('No')}}</option>
</select>
{% endif %}
{% if c.datatype in ['text', 'series'] and not c.is_multiple %}
<input type="text" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}"
{% if book['custom_column_' ~ c.id]|length > 0 %}
@ -72,7 +85,7 @@
{% endfor %}
</select>
{% endif %}
{% if c.datatype == 'rating' %}
<input type="number" min="1" max="5" step="1" class="form-control" name="{{ 'custom_column_' ~ c.id }}" id="{{ 'custom_column_' ~ c.id }}"
{% if book['custom_column_' ~ c.id]|length > 0 %}
@ -86,10 +99,10 @@
<div class="checkbox">
<label>
<input name="detail_view" type="checkbox" checked> view book after edit
<input name="detail_view" type="checkbox" checked> {{_('view book after edit')}}
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
</div>
{% endif %}

View File

@ -4,30 +4,30 @@
<h1>{{title}}</h1>
<form role="form" method="POST">
<div class="form-group">
<label for="mail_server">SMTP hostname</label>
<label for="mail_server">{{_('SMTP hostname')}}</label>
<input type="text" class="form-control" name="mail_server" id="mail_server" value="{{content.mail_server}}">
</div>
<div class="form-group">
<label for="mail_port">SMTP port (usually 25 for plain SMTP and 587 for SSL)</label>
<label for="mail_port">{{_('SMTP port (usually 25 for plain SMTP and 587 for SSL)')}}</label>
<input type="text" class="form-control" name="mail_port" id="mail_port" value="{{content.mail_port}}">
</div>
<div class="form-group">
<label for="mail_use_ssl">Server uses SSL (StartTLS)</label>
<label for="mail_use_ssl">{{_('Server uses SSL (StartTLS)')}}</label>
<input type="checkbox" name="mail_use_ssl" id="mail_use_ssl" {% if content.mail_use_ssl %}checked{% endif %}>
</div>
<div class="form-group">
<label for="mail_login">SMTP login</label>
<label for="mail_login">{{_('SMTP login')}}</label>
<input type="text" class="form-control" name="mail_login" id="mail_login" value="{{content.mail_login}}">
</div>
<div class="form-group">
<label for="mail_password">SMTP password</label>
<label for="mail_password">{{_('SMTP password')}}</label>
<input type="password" class="form-control" name="mail_password" id="mail_password" value="{{content.mail_password}}">
</div>
<div class="form-group">
<label for="mail_from">From e-mail</label>
<label for="mail_from">{{_('From e-mail')}}</label>
<input type="text" class="form-control" name="mail_from" id="mail_from" value="{{content.mail_from}}">
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
</div>

View File

@ -7,17 +7,17 @@
<link rel="start"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="related"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<link rel="up"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="next"
title="{{_('Next')}}"
href="{{ next_url }}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="search"
href="{{url_for('feed_osd')}}"
type="application/opensearchdescription+xml"/>
<title>Calibre Web</title>
<updated>2010-01-10T10:03:10Z</updated>
<author>
<name>Calibre Web</name>
<uri>https://github.com/janeczku/calibre-web</uri>
@ -27,7 +27,7 @@
<entry>
<title>{{entry.title}}</title>
<id>{{entry.uuid}}</id>
<updated>{{entry.last_modified}}</updated>
<updated>{{entry.timestamp}}</updated>
<author>
<name>{{entry.authors[0].name}}</name>
<uri>{{entry.authors[0].name}}</uri>
@ -41,18 +41,13 @@
<summary>{% if entry.comments[0] %}{{entry.comments[0].text|striptags}}{% endif %}</summary>
{% if entry.has_cover %}
<link rel="http://opds-spec.org/image"
href="{{ url_for('get_cover', cover_path=entry.path) }}"
href="{{ url_for('feed_get_cover', cover_path=entry.path) }}"
type="image/jpg"/>
<link rel="http://opds-spec.org/image/thumbnail"
href="{{ url_for('get_cover', cover_path=entry.path) }}"
href="{{ url_for('feed_get_cover', cover_path=entry.path) }}"
type="image/jpg"/>
{% endif %}
<link rel="alternate"
href="/opds-catalogs/entries/4571.complete.xml"
type="application/atom+xml;type=entry;profile=opds-catalog"
title="Complete Catalog Entry for Bob, Son of Bob"/>
{% for format in entry.data %}
<link rel="http://opds-spec.org/acquisition"
href="{{ url_for('get_opds_download_link', book_id=entry.id, format=format.format|lower)}}"{% if format.format|lower == "epub" %}
@ -63,4 +58,26 @@
{% endfor %}
</entry>
{% endfor %}
{% for author in authors %}
<entry>
<title>{{author.name}}</title>
<!--content type="text">{{author.name}}</content-->
<id>{{ url_for('feed_author', name=author.name) }}</id>
<link href="{{ url_for('feed_author', name=author.name)}}" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection"/>
</entry>
{% endfor %}
{% for entry in categorys %}
<entry>
<title>{{entry.name}}</title>
<id>{{ url_for('feed_category', name=entry.name) }}</id>
<link href="{{ url_for('feed_category', name=entry.name)}}" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection"/>
</entry>
{% endfor %}
{% for entry in series %}
<entry>
<title>{{entry.name}}</title>
<id>{{ url_for('feed_series', name=entry.name) }}</id>
<link href="{{ url_for('feed_series', name=entry.name)}}" type="application/atom+xml;profile=opds-catalog;kind=navigation" rel="subsection"/>
</entry>
{% endfor %}
</feed>

View File

@ -1,8 +1,8 @@
{% extends "layout.html" %}
{% block body %}
{% if random.count() > 0 %}
{% if g.user.show_random_books() %}
<div class="discover">
<h2>Discover (Random Books)</h2>
<h2>{{_('Discover (Random Books)')}}</h2>
<div class="row">
{% for entry in random %}
@ -31,7 +31,6 @@
{% endif %}
</div>
</div>
<!-- <p><a href="{{ url_for('edit_book', book_id=entry.id) }}">{{entry.authors[0].name}}: {{entry.title}}</a></p> -->
{% endfor %}
</div>
</div>
@ -72,7 +71,6 @@
{% endif %}
</div>
</div>
<!-- <p><a href="{{ url_for('edit_book', book_id=entry.id) }}">{{entry.authors[0].name}}: {{entry.title}}</a></p> -->
{% endfor %}
</div>
</div>

View File

@ -5,19 +5,14 @@
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="start"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="related"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<link rel="up"
title="{{_('Start')}}"
href="{{url_for('feed_index')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<link rel="search"
title="{{_('Search')}}"
href="{{url_for('feed_osd')}}"
type="application/opensearchdescription+xml"/>
<title>Calibre Web</title>
<updated>2010-01-10T10:03:10Z</updated>
<author>
<name>Calibre Web</name>
<uri>https://github.com/janeczku/calibre-web</uri>
@ -25,32 +20,53 @@
<entry>
<title>Hot Books</title>
<title>{{_('Hot Books')}}</title>
<link rel="http://opds-spec.org/sort/popular"
href="{{url_for('feed_hot')}}"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<updated>2010-01-10T10:01:01Z</updated>
<id>urn:uuid:d49e8018-a0e0-499e-9423-7c175fa0c56e</id>
<content type="text">Popular publications from this catalog based on Rating.</content>
<id>{{url_for('feed_hot')}}</id>
<content type="text">{{_('Popular publications from this catalog based on Rating.')}}</content>
</entry>
<entry>
<title>New Books</title>
<link rel="http://opds-spec.org/sort/popular"
<title>{{_('New Books')}}</title>
<link rel="http://opds-spec.org/sort/new"
href="{{url_for('feed_new')}}"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<updated>2010-01-10T10:01:01Z</updated>
<id>urn:uuid:d49e8018-a0e0-499e-9423-7c175fa0c56e</id>
<content type="text">The latest Books</content>
<id>{{url_for('feed_new')}}</id>
<content type="text">{{_('The latest Books')}}</content>
</entry>
<entry>
<title>Random Books</title>
<link rel="http://opds-spec.org/sort/random"
<title>{{_('Random Books')}}</title>
<link rel="http://opds-spec.org/featured"
href="{{url_for('feed_discover')}}"
type="application/atom+xml;profile=opds-catalog;kind=acquisition"/>
<updated>2010-01-10T10:01:01Z</updated>
<id>urn:uuid:d49e8018-a0e0-499e-9423-7c175fa0c56e</id>
<content type="text">Show Random Books</content>
<id>{{url_for('feed_discover')}}</id>
<content type="text">{{_('Show Random Books')}}</content>
</entry>
<entry>
<title>{{_('Authors')}}</title>
<link rel="subsection"
href="{{url_for('feed_authorindex')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<id>{{url_for('feed_authorindex')}}</id>
<content type="text">{{_('Books ordered by Author')}}</content>
</entry>
<entry>
<title>{{_('Category list')}}</title>
<link rel="subsection"
href="{{url_for('feed_categoryindex')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<id>{{url_for('feed_categoryindex')}}</id>
<content type="text">{{_('Books ordered by category')}}</content>
</entry>
<entry>
<title>{{_('Series list')}}</title>
<link rel="subsection"
href="{{url_for('feed_seriesindex')}}"
type="application/atom+xml;profile=opds-catalog;kind=navigation"/>
<id>{{url_for('feed_seriesindex')}}</id>
<content type="text">{{_('Books ordered by series')}}</content>
</entry>
</feed>

View File

@ -0,0 +1,12 @@
{% extends "layout.html" %}
{% block body %}
<h1>{{title}}</h1>
<div class="container">
{% for lang in languages %}
<div class="row">
<div class="col-xs-1" align="left"><span class="badge">{{lang_counter[loop.index0].bookcount}}</span></div>
<div class="col-xs-6"><a href="{{url_for('language', name=lang.lang_code)}}">{{lang.name}}</a></div>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -43,7 +43,7 @@
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="sr-only">{{_('Toggle navigation')}}</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@ -51,41 +51,44 @@
<a class="navbar-brand" href="{{url_for('index')}}">Calibre Web</a>
</div>
<div class="navbar-collapse collapse">
{% if g.user.is_authenticated or g.user.is_anonymous() %}
<ul class="nav navbar-nav ">
<li>
<form class="navbar-form navbar-left" role="search" action="{{url_for('search')}}" method="GET">
<div class="form-group">
<input type="text" class="form-control" name="query" placeholder="Search">
<input type="text" class="form-control" name="query" placeholder="{{_('Search')}}">
</div>
<button type="submit" class="btn btn-default">Go!</button>
<button type="submit" class="btn btn-default">{{_('Go!')}}</button>
</form>
</li>
<li><a href="{{url_for('advanced_search')}}"><span class="glyphicon glyphicon-search"></span> Advanced Search</a></li>
<li><a href="{{url_for('advanced_search')}}"><span class="glyphicon glyphicon-search"></span> {{_('Advanced Search')}}</a></li>
</ul>
{% endif %}
<ul class="nav navbar-nav navbar-right" id="main-nav">
{% if g.user.is_authenticated() %}
{% if g.user.is_authenticated or g.user.is_anonymous() %}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
<li>
<form id="form-upload" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<span class="btn btn-default btn-file">Upload <input id="btn-upload" name="btn-upload" type="file"></span>
</div>
</form>
</li>
{% endif %}
{% if g.allow_upload %}
<li>
<form id="form-upload" class="navbar-form" action="{{ url_for('upload') }}" method="post" enctype="multipart/form-data">
<div class="form-group">
<span class="btn btn-default btn-file">{{_('Upload')}} <input id="btn-upload" name="btn-upload" type="file"></span>
</div>
</form>
</li>
{% endif %}
{% endif %}
{% if g.user.role_admin() %}
<li><a href="{{url_for('user_list')}}"><span class="glyphicon glyphicon-dashboard"></span> Admin</a></li>
<li><a href="{{url_for('user_list')}}"><span class="glyphicon glyphicon-dashboard"></span> {{_('Admin')}}</a></li>
{% endif %}
<li><a href="{{url_for('profile')}}"><span class="glyphicon glyphicon-user"></span> {{g.user.nickname}}</a></li>
<li><a href="{{url_for('logout', next='%s%s' % (request.script_root, request.path))}}"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li>
{% else %}
<li><a href="{{url_for('login', next='%s%s' % (request.script_root, request.path))}}"><span class="glyphicon glyphicon-log-in"></span> Login</a></li>
{% if g.allow_registration %}
<li><a href="{{url_for('register')}}"><span class="glyphicon glyphicon-user"></span> Register</a></li>
{% if not g.user.is_anonymous() %}
<li><a href="{{url_for('logout', next='%s%s' % (request.script_root, request.path))}}"><span class="glyphicon glyphicon-log-out"></span> {{_('Logout')}}</a></li>
{% endif %}
{% endif %}
{% if g.allow_registration and not g.user.is_authenticated %}
<li><a href="{{url_for('login', next='%s%s' % (request.script_root, request.path))}}"><span class="glyphicon glyphicon-log-in"></span> {{_('Login')}}</a></li>
<li><a href="{{url_for('register')}}"><span class="glyphicon glyphicon-user"></span> {{_('Register')}}</a></li>
{% endif %}
</ul>
</div><!--/.nav-collapse -->
</div>
@ -109,30 +112,46 @@
{% endfor %}
<div class="container-fluid">
<div class="row-fluid">
{% if g.user.is_authenticated or g.user.is_anonymous() %}
<div class="col-sm-2">
<nav class="navigation">
<ul class="list-unstyled" id="scnd-nav" intent in-standard-append="nav.navigation" in-mobile-after="#main-nav" in-mobile-class="nav navbar-nav">
<li class="nav-head hidden-xs">Browse</li>
<li><a href="{{url_for('index')}}"><span class="glyphicon glyphicon-book"></span> New Books</a></li>
<li><a href="{{url_for('hot_books')}}"><span class="glyphicon glyphicon-fire"></span> Hot Books</a></li>
<li><a href="{{url_for('discover')}}"><span class="glyphicon glyphicon-random"></span> Discover</a></li>
<li><a href="{{url_for('category_list')}}"><span class="glyphicon glyphicon-inbox"></span> Categories</a></li>
<li><a href="{{url_for('author_list')}}"><span class="glyphicon glyphicon-user"></span> Authors</a></li>
{% if g.user.is_authenticated() %}
<li class="nav-head hidden-xs">Public Shelves</li>
<li class="nav-head hidden-xs">{{_('Browse')}}</li>
<li><a href="{{url_for('index')}}"><span class="glyphicon glyphicon-book"></span> {{_('New Books')}}</a></li>
{% if g.user.show_hot_books() %}
<li><a href="{{url_for('hot_books')}}"><span class="glyphicon glyphicon-fire"></span> {{_('Hot Books')}}</a></li>
{%endif%}
{% if g.user.show_random_books() %}
<li><a href="{{url_for('discover')}}"><span class="glyphicon glyphicon-random"></span> {{_('Discover')}}</a></li>
{%endif%}
{% if g.user.show_category() %}
<li><a href="{{url_for('category_list')}}"><span class="glyphicon glyphicon-inbox"></span> {{_('Categories')}}</a></li>
{%endif%}
{% if g.user.show_series() %}
<li><a href="{{url_for('series_list')}}"><span class="glyphicon glyphicon-bookmark"></span> {{_('Series')}}</a></li>
{%endif%}
<li><a href="{{url_for('author_list')}}"><span class="glyphicon glyphicon-user"></span> {{_('Authors')}}</a></li>
{% if g.user.filter_language() == 'all' and g.user.show_language() %}
<li><a href="{{url_for('language_overview')}}"><span class="glyphicon glyphicon-flag"></span> {{_('Languages')}} </a></li>
{%endif%}
{% if g.user.is_authenticated or g.user.is_anonymous() %}
<li class="nav-head hidden-xs">{{_('Public Shelves')}}</li>
{% for shelf in g.public_shelfes %}
<li><a href="{{url_for('show_shelf', shelf_id=shelf.id)}}"><span class="glyphicon glyphicon-list"></span> {{shelf.name}}</a></li>
{% endfor %}
<li class="nav-head hidden-xs">Your Shelves</li>
<li class="nav-head hidden-xs">{{_('Your Shelves')}}</li>
{% for shelf in g.user.shelf %}
<li><a href="{{url_for('show_shelf', shelf_id=shelf.id)}}"><span class="glyphicon glyphicon-list"></span> {{shelf.name}}</a></li>
{% endfor %}
<li class="create-shelf"><a href="{{url_for('create_shelf')}}">Create a Shelf</a></li>
{% if not g.user.is_anonymous() %}
<li class="create-shelf"><a href="{{url_for('create_shelf')}}">{{_('Create a Shelf')}}</a></li>
{% endif %}
{% endif %}
<li><a href="{{url_for('stats')}}"><span class="glyphicon glyphicon-info-sign"></span> {{_('About')}}</a></li>
</ul>
</nav>
</div>
{% endif %}
<div class="col-sm-10">
{% block body %}{% endblock %}
{% if pagination %}
@ -159,4 +178,4 @@
</div>
{% block js %}{% endblock %}
</body>
</html>
</html>

12
cps/templates/list.html Normal file
View File

@ -0,0 +1,12 @@
{% extends "layout.html" %}
{% block body %}
<h1>{{title}}</h1>
<div class="container">
{% for entry in entries %}
<div class="row">
<div class="col-xs-1" align="left"><span class="badge">{{entry.count}}</span></div>
<div class="col-xs-6"><a href="{{url_for(folder, name=entry[0].name)}}">{{entry[0].name}}</a></div>
</div>
{% endfor %}
</div>
{% endblock %}

View File

@ -1,22 +1,22 @@
{% extends "layout.html" %}
{% block body %}
<div class="well col-sm-6 col-sm-offset-2">
<h2 style="margin-top: 0">Login</h2>
<h2 style="margin-top: 0">{{_('Login')}}</h2>
<form method="POST" role="form">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Username">
<label for="username">{{_('Username')}}</label>
<input type="text" class="form-control" id="username" name="username" placeholder="{{_('Username')}}">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
<label for="password">{{_('Password')}}</label>
<input type="password" class="form-control" id="password" name="password" placeholder="{{_('Password')}}">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="remember_me" checked> Remember me
<input type="checkbox" name="remember_me" checked> {{_('Remember me')}}
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
</div>
{% if error %}

View File

@ -23,9 +23,9 @@
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://example.com/websearch.ico</Image>
-->
<Query role="example" searchTerms="shakespeare hamlet" />
<!--Query role="example" searchTerms="shakespeare hamlet" />
<Query role="example" searchTerms="doyle detective" />
<Query role="example" searchTerms="love stories" />
<Query role="example" searchTerms="love stories" /-->
<Attribution>Search Data Copyright 1971-2012, Project Gutenberg, All Rights Reserved.</Attribution>
<SyndicationRight>open</SyndicationRight>

View File

@ -133,7 +133,7 @@
<h3>Settings</h3>
<div>
<p>
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">Reflow text when sidebars are open.
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">{{_(Reflow text when sidebars are open.)}}
</p>
</div>
<div class="closer icon-cancel-circled"></div>

View File

@ -26,7 +26,7 @@ See https://github.com/adobe-type-tools/cmap-resources
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PDF.js viewer</title>
<title>{{_(PDF.js viewer)}}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/viewer.css') }}">

View File

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Basic txt Reader</title>
<title>{{_(Basic txt Reader)}}</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<meta name="apple-mobile-web-app-capable" content="yes">

View File

@ -1,21 +1,21 @@
{% extends "layout.html" %}
{% block body %}
<div class="well col-sm-6 col-sm-offset-2">
<h2 style="margin-top: 0">Register a new account</h2>
<h2 style="margin-top: 0">{{_('Register a new account')}}</h2>
<form method="POST" role="form">
<div class="form-group required">
<label for="nickname">Username</label>
<input type="text" class="form-control" id="nickname" name="nickname" placeholder="Choose a username" required>
<label for="nickname">{{_('Username')}}</label>
<input type="text" class="form-control" id="nickname" name="nickname" placeholder="{{_('Choose a username')}}" required>
</div>
<div class="form-group required">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Choose a password" required>
<label for="password">{{_('Password')}}</label>
<input type="password" class="form-control" id="password" name="password" placeholder="{{_('Choose a password')}}" required>
</div>
<div class="form-group required">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Your email address" required>
<label for="email">{{_('Email address')}}</label>
<input type="email" class="form-control" id="email" name="email" placeholder="{{_('Your email address')}}" required>
</div>
<button type="submit" class="btn btn-primary">Register</button>
<button type="submit" class="btn btn-primary">{{_('Register')}}</button>
</form>
</div>
{% if error %}

View File

@ -3,10 +3,10 @@
<div class="discover">
{% if entries|length < 1 %}
<h2>No Results for: {{searchterm}}</h2>
<p>Please try a diffrent Search</p>
<h2>{{_('No Results for:')}} {{searchterm}}</h2>
<p>{{_('Please try a diffrent Search')}}</p>
{% else %}
<h2>{{entries|length}} Results for: {{searchterm}}</h2>
<h2>{{entries|length}} {{_('Results for:')}} {{searchterm}}</h2>
{%endif%}
<div class="row">

View File

@ -3,14 +3,14 @@
<div class="col-sm-8">
<form role="form" action="{{ url_for('advanced_search') }}" method="GET">
<div class="form-group">
<label for="book_title">Book Title</label>
<label for="book_title">{{_('Book Title')}}</label>
<input type="text" class="form-control" name="book_title" id="book_title" value="">
</div>
<div class="form-group">
<label for="bookAuthor">Author</label>
<label for="bookAuthor">{{_('Author')}}</label>
<input type="text" class="form-control typeahead" name="author_name" id="bookAuthor" value="" autocomplete="off">
</div>
<label for="Tags">Include Tags</label>
<label for="Tags">{{_('Tags')}}</label>
<div class="form-group">
<div class="btn-toolbar btn-toolbar-lg" data-toggle="buttons">
{% for tag in tags %}
@ -20,7 +20,7 @@
{% endfor %}
</div>
</div>
<label for="Tags">Exclude Tags</label>
<label for="Tags">{{_('Exclude Tags')}}</label>
<div class="form-group">
<div class="btn-toolbar btn-toolbar-lg" data-toggle="buttons">
{% for tag in tags %}
@ -30,7 +30,7 @@
{% endfor %}
</div>
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
</div>
{% endblock %}
@ -39,8 +39,8 @@
<script src="{{ url_for('static', filename='js/typeahead.bundle.js') }}"></script>
<script src="{{ url_for('static', filename='js/edit_books.js') }}"></script>
<script>
$('form').on('change input typeahead:selected', function() {
form = $('form').serialize();
$('form')}}.on('change input typeahead:selected', function() {
form = $('form')}}.serialize();
$.getJSON( "{{ url_for('get_matching_tags') }}", form, function( data ) {
$('.tags_click').each(function() {
if ($.inArray(parseInt($(this).children('input').first().val(), 10), data.tags) == -1 ) {

View File

@ -2,6 +2,9 @@
{% block body %}
<div class="discover">
<h2>{{title}}</h2>
{% if g.user.is_authenticated %}
<a href=" {{ url_for('delete_shelf', shelf_id=shelf.id) }} " class="btn btn-danger">{{ _('Delete this Shelf') }} </a>
{% endif %}
<div class="row">
{% for entry in entries %}

View File

@ -4,15 +4,15 @@
<h1>{{title}}</h1>
<form role="form" method="POST">
<div class="form-group">
<label for="title">Title</label>
<label for="title">{{_('Title')}}</label>
<input type="text" class="form-control" name="title" id="title" value="">
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="is_public"> should the shelf be public?
<input type="checkbox" name="is_public"> {{_('should the shelf be public?')}}
</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
</div>
{% endblock %}

View File

@ -1,6 +1,7 @@
{% extends "layout.html" %}
{% block body %}
<div class="discover">
<h1>{{counter}} Books in this Library</h1>
<h2>{{bookcounter}} {{_('Books in this Library')}}</h2>
<h2>{{authorcounter}} {{_('Authors in this Library')}}</h2>
</div>
{% endblock %}

View File

@ -5,58 +5,96 @@
<form role="form" method="POST" autocomplete="off">
{% if g.user and g.user.role_admin() and new_user %}
<div class="form-group required">
<label for="nickname">Username</label>
<label for="nickname">{{_('Username')}}</label>
<input type="text" class="form-control" name="nickname" id="nickname" value="{{ content.nickname if content.nickname != None }}" autocomplete="off">
</div>
{% endif %}
<div class="form-group">
<label for="email">Email address</label>
<label for="email">{{_('Email address')}}</label>
<input type="email" class="form-control" name="email" id="email" value="{{ content.email if content.email != None }}" autocomplete="off" required>
</div>
{% if g.user and g.user.role_passwd() or g.user.role_admin()%}
<div class="form-group">
<label for="password">Password</label>
<label for="password">{{_('Password')}}</label>
<input type="password" class="form-control" name="password" id="password" value="" autocomplete="off">
</div>
{% endif %}
<div class="form-group">
<label for="kindle_mail">Kindle E-Mail</label>
<label for="kindle_mail">{{_('Kindle E-Mail')}}</label>
<input type="email" class="form-control" name="kindle_mail" id="kindle_mail" value="{{ content.kindle_mail if content.kindle_mail != None }}">
</div>
<div class="form-group">
<label for="locale">{{_('Language')}}</label>
<select name="locale" id="locale" class="form-control">
{% for translation in translations %}
<option value="{{translation.language}}" {% if translation.language == content.locale %}selected{% endif %}>{{ translation.display_name }}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="default_language">{{_('Show books with language')}}</label>
<select name="default_language" id="default_language" class="form-control">
<option value="all" >{{ _('Show all') }}</option>
{% for language in languages %}
<option value="{{ language.lang_code }}" {% if content.default_language == language.lang_code %}selected{% endif %}>{{ language.name }}</option>
{% endfor %}
</select>
</div>
{% if g.user and g.user.role_admin() and not profile %}
<div class="form-group">
<label for="admin_role">Admin user</label>
<input type="checkbox" name="show_random" {% if content.random_books %}checked{% endif %}>
<label for="show_random">{{_('Show random books')}}</label>
</div>
<div class="form-group">
<input type="checkbox" name="show_hot" {% if content.hot_books %}checked{% endif %}>
<label for="show_hot">{{_('Show hot books')}}</label>
</div>
<div class="form-group">
<input type="checkbox" name="show_language" {% if content.language_books %}checked{% endif %}>
<label for="show_language">{{_('Show language selection')}}</label>
</div>
<div class="form-group">
<input type="checkbox" name="show_series" {% if content.series_books %}checked{% endif %}>
<label for="show_series">{{_('Show series selection')}}</label>
</div>
<div class="form-group">
<input type="checkbox" name="show_category" {% if content.category_books %}checked{% endif %}>
<label for="show_category">{{_('Show category selection')}}</label>
</div>
<div class="form-group">
<input type="checkbox" name="admin_role" id="admin_role" {% if content.role_admin() %}checked{% endif %}>
<label for="admin_role">{{_('Admin user')}}</label>
</div>
<div class="form-group">
<label for="download_role">Allow Downloads</label>
<input type="checkbox" name="download_role" id="download_role" {% if content.role_download() %}checked{% endif %}>
<label for="download_role">{{_('Allow Downloads')}}</label>
</div>
<div class="form-group">
<label for="upload_role">Allow Uploads</label>
<input type="checkbox" name="upload_role" id="upload_role" {% if content.role_upload() %}checked{% endif %}>
<label for="upload_role">{{_('Allow Uploads')}}</label>
</div>
<div class="form-group">
<label for="edit_role">Allow Edit</label>
<input type="checkbox" name="edit_role" id="edit_role" {% if content.role_edit() %}checked{% endif %}>
<label for="edit_role">{{_('Allow Edit')}}</label>
</div>
<div class="form-group">
<label for="passwd_role">Allow Changing Password</label>
<input type="checkbox" name="passwd_role" id="passwd_role" {% if content.role_passwd() %}checked{% endif %}>
<label for="passwd_role">{{_('Allow Changing Password')}}</label>
</div>
{% endif %}
{% if g.user and g.user.role_admin() and not profile and not new_user %}
<div class="checkbox">
<label>
<input type="checkbox" name="delete"> Delete this user
<input type="checkbox" name="delete"> {{_('Delete this user')}}
</label>
</div>
{% endif %}
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default">{{_('Submit')}}</button>
</form>
{% if downloads %}
<h2>Recent Downloads</h2>
<h2>{{_('Recent Downloads')}}</h2>
{% for entry in downloads %}
<div class="col-sm-2">
<a class="pull-left" href="{{ url_for('show_book', id=entry.id) }}">

View File

@ -4,15 +4,15 @@
<h2>{{title}}</h2>
<table class="table table-striped">
<tr>
<th>Nickname</th>
<th>Email</th>
<th>Kindle</th>
<th>DLS</th>
<th>Admin</th>
<th>Download</th>
<th>Upload</th>
<th>Edit</th>
<th>Passwd</th>
<th>{{_('Nickname')}}</th>
<th>{{_('Email')}}</th>
<th>{{_('Kindle')}}</th>
<th>{{_('DLS')}}</th>
<th>{{_('Admin')}}</th>
<th>{{_('Download')}}</th>
<th>{{_('Upload')}}</th>
<th>{{_('Edit')}}</th>
<th>{{_('Passwd')}}</th>
</tr>
{% for user in content %}
@ -29,16 +29,16 @@
{% endfor %}
</table>
<div class="btn btn-default"><a href="{{url_for('new_user')}}">Add new user</a></div>
<h2>SMTP mail settings</h2>
<div class="btn btn-default"><a href="{{url_for('new_user')}}">{{_('Add new user')}}</a></div>
<h2>{{_('SMTP mail settings')}}</h2>
<table class="table table-striped">
<tr>
<th>SMTP hostname</th>
<th>SMTP port</th>
<th>SSL</th>
<th>SMTP login</th>
<th>SMTP password</th>
<th>From mail</th>
<th>{{_('SMTP hostname')}}</th>
<th>{{_('SMTP port')}}</th>
<th>{{_('SSL')}}</th>
<th>{{_('SMTP login')}}</th>
<th>{{_('SMTP password')}}</th>
<th>{{_('From mail')}}</th>
</tr>
<tr>
<td>{{email.mail_server}}</td>
@ -50,7 +50,7 @@
</table>
<div class="btn btn-default"><a href="{{url_for('edit_mailsettings')}}">Change SMTP settings</a></div>
<div class="btn btn-default"><a href="{{url_for('edit_mailsettings')}}">{{_('Change SMTP settings')}}</a></div>
</div>
{% endblock %}

Binary file not shown.

View File

@ -0,0 +1,673 @@
# German translations for PROJECT.
# Copyright (C) 2016 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
#
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2016-11-09 18:52+0100\n"
"PO-Revision-Date: 2016-07-12 19:54+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: de\n"
"Language-Team: de <LL@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"
#: cps/helper.py:76 cps/templates/detail.html:113
msgid "Send to Kindle"
msgstr "An Kindle senden"
#: cps/helper.py:77
msgid "This email has been sent via calibre web."
msgstr "Die E-Mail wurde via calibre-web versendet"
#: cps/helper.py:99 cps/helper.py:114
msgid "Could not find any formats suitable for sending by email"
msgstr "Konnte keine Formate finden welche für das versenden per E-Mail geeignet sind"
#: cps/helper.py:108
msgid "Could not convert epub to mobi"
msgstr "Konnte .epub nicht nach .mobi convertieren"
#: cps/helper.py:138
#, python-format
msgid "Failed to send mail: %s"
msgstr "E-Mail: %s konnte nicht gesendet werden"
#: cps/helper.py:158
msgid "The requested file could not be read. Maybe wrong permissions?"
msgstr "Die angeforderte Datei konnte nicht gelesen werden. Falsche Dateirechte?"
#: cps/web.py:633
msgid "Latest Books"
msgstr "Letzte Bücher"
#: cps/web.py:655
msgid "Hot Books (most downloaded)"
msgstr "Beliebte Bücher (die meisten Downloads)"
#: cps/templates/index.xml:41 cps/web.py:662
msgid "Random Books"
msgstr "Zufällige Bücher"
#: cps/web.py:673
msgid "Author list"
msgstr "Autorenliste"
#: cps/web.py:689
#, python-format
msgid "Author: %(nam)s"
msgstr "Autor: %(nam)s"
#: cps/templates/index.xml:65 cps/web.py:700
msgid "Series list"
msgstr "Liste Serien"
#: cps/web.py:708
#, python-format
msgid "Series: %(serie)s"
msgstr "Serie: %(serie)s"
#: cps/web.py:710 cps/web.py:790 cps/web.py:908 cps/web.py:1518
msgid "Error opening eBook. File does not exist or file is not accessible:"
msgstr ""
"Buch öffnen fehlgeschlagen. Datei existiert nicht, oder ist nicht "
"zugänglich."
#: cps/web.py:736
msgid "Available languages"
msgstr "Verfügbare Sprachen"
#: cps/web.py:748
#, python-format
msgid "Language: %(name)s"
msgstr "Sprache: %(name)s"
#: cps/templates/index.xml:57 cps/web.py:759
msgid "Category list"
msgstr "Kategorieliste"
#: cps/web.py:766
#, python-format
msgid "Category: %(name)s"
msgstr "Kategorie: %(name)s"
#: cps/web.py:804
msgid "Statistics"
msgstr "Statistiken"
#: cps/web.py:892 cps/web.py:899 cps/web.py:906
msgid "Read a Book"
msgstr "Lese ein Buch"
#: cps/web.py:945 cps/web.py:1173
msgid "Please fill out all fields!"
msgstr "Bitte alle Felder ausfüllen!"
#: cps/web.py:961
msgid "An unknown error occured. Please try again later."
msgstr "Es ist ein unbekannter Fehler aufgetreten. Bitte später erneut versuchen."
#: cps/web.py:966
msgid "This username or email address is already in use."
msgstr "Der Benutzername oder die E-Mailadresse ist in bereits in Benutzung."
#: cps/web.py:969
msgid "register"
msgstr "Registieren"
#: cps/web.py:984
#, python-format
msgid "you are now logged in as: '%(nickname)s'"
msgstr "Du bist nun eingeloggt als '%(nickname)s'"
#: cps/web.py:987
msgid "Wrong Username or Password"
msgstr "Flascher Benutzername oder Passwort"
#: cps/web.py:989
msgid "login"
msgstr "Login"
#: cps/web.py:1005
msgid "Please configure the SMTP mail settings first..."
msgstr "Bitte zuerst die SMTP Mail Einstellung konfigurieren ..."
#: cps/web.py:1009
#, python-format
msgid "Book successfully send to %(kindlemail)s"
msgstr "Buch erfolgreich versandt an %(kindlemail)s"
#: cps/web.py:1012
#, python-format
msgid "There was an error sending this book: %(res)s"
msgstr "Beim Senden des Buchs trat ein Fehler auf: %(res)s"
#: cps/web.py:1014
msgid "Please configure your kindle email address first..."
msgstr "Bitte die Kindle E-Mail Adresse zuuerst konfigurieren..."
#: cps/web.py:1029
#, python-format
msgid "Book has been added to shelf: %(sname)s"
msgstr "Das Buch wurde dem Bücherregal: %(sname)s hinzugefügt"
#: cps/web.py:1048
#, python-format
msgid "Book has been removed from shelf: %(sname)s"
msgstr "Das Buch wurde aus dem Bücherregal: %(sname)s entfernt"
#: cps/web.py:1064
#, python-format
msgid "A shelf with the name '%(title)s' already exists."
msgstr "Es existiert bereits ein Bücheregal mit dem Titel '%(title)s'"
#: cps/web.py:1069
#, python-format
msgid "Shelf %(title)s created"
msgstr "Bücherregal %(title)s erzeugt"
#: cps/web.py:1071
msgid "There was an error"
msgstr "Es trat ein Fehler auf"
#: cps/web.py:1072 cps/web.py:1074
msgid "create a shelf"
msgstr "Bücherregal erzeugen"
#: cps/web.py:1090
#, python-format
msgid "successfully deleted shelf %(name)s"
msgstr "Bücherregal %(name)s erfolgreich gelöscht"
#: cps/web.py:1107
#, python-format
msgid "Shelf: '%(name)s'"
msgstr "Bücherregal: '%(name)s'"
#: cps/web.py:1144
msgid "Found an existing account for this email address."
msgstr "Es existiert ein Benutzerkonto für diese E-Mailadresse"
#: cps/web.py:1145 cps/web.py:1147
#, python-format
msgid "%(name)s's profile"
msgstr "%(name)s's Profil"
#: cps/web.py:1146
msgid "Profile updated"
msgstr "Profil aktualisiert"
#: cps/web.py:1155
msgid "User list"
msgstr "Benutzerliste"
#: cps/templates/user_list.html:32 cps/web.py:1174
msgid "Add new user"
msgstr "Neuen Benutzer hinzufügen"
#: cps/web.py:1207
#, python-format
msgid "User '%(user)s' created"
msgstr "Benutzer '%(user)s' angelegt"
#: cps/web.py:1211
msgid "Found an existing account for this email address or nickname."
msgstr ""
"Es existiert ein Benutzerkonto für diese Emailadresse oder den "
"Benutzernamen"
#: cps/web.py:1232
msgid "Mail settings updated"
msgstr "E-Mail Einstellungen aktualisiert"
#: cps/web.py:1235
msgid "Edit mail settings"
msgstr "E-Mail Einstellungen editieren"
#: cps/web.py:1257
#, python-format
msgid "User '%(nick)s' deleted"
msgstr "Benutzer '%(nick)s' gelöscht"
#: cps/web.py:1312
#, python-format
msgid "User '%(nick)s' updated"
msgstr "Benutzer '%(nick)s' aktualisiert"
#: cps/web.py:1315
msgid "An unknown error occured."
msgstr "Es ist ein unbekanter Fehler aufgetreten"
#: cps/web.py:1316
#, python-format
msgid "Edit User %(nick)s"
msgstr "Benutzer %(nick)s bearbeiten"
#: cps/web.py:1550
#, python-format
msgid "Failed to create path %s (Permission denied)."
msgstr ""
#: cps/web.py:1555
#, python-format
msgid "Failed to store file %s (Permission denied)."
msgstr ""
#: cps/web.py:1560
#, python-format
msgid "Failed to delete file %s (Permission denied)."
msgstr ""
#: cps/templates/detail.html:38
msgid "Book"
msgstr "Buch"
#: cps/templates/detail.html:38
msgid "of"
msgstr "von"
#: cps/templates/detail.html:44
msgid "language"
msgstr "Sprache"
#: cps/templates/detail.html:92
msgid "Description:"
msgstr "Beschreibung"
#: cps/templates/detail.html:103 cps/templates/user_list.html:12
msgid "Download"
msgstr "Download"
#: cps/templates/detail.html:117
msgid "Read in browser"
msgstr "Im Browser lesen"
#: cps/templates/detail.html:136
msgid "Add to shelf"
msgstr "Zu Bücherregal hinzufügen"
#: cps/templates/detail.html:176
msgid "Edit metadata"
msgstr "Metadaten bearbeiten"
#: cps/templates/edit_book.html:14 cps/templates/search_form.html:6
msgid "Book Title"
msgstr "Buchtitel"
#: cps/templates/edit_book.html:18 cps/templates/search_form.html:10
msgid "Author"
msgstr "Autor"
#: cps/templates/edit_book.html:22
msgid "Description"
msgstr "Beschreibung"
#: cps/templates/edit_book.html:26 cps/templates/search_form.html:13
msgid "Tags"
msgstr "Tags"
#: cps/templates/edit_book.html:31 cps/templates/layout.html:131
msgid "Series"
msgstr "Serien"
#: cps/templates/edit_book.html:35
msgid "Series id"
msgstr "Serien ID"
#: cps/templates/edit_book.html:39
msgid "Rating"
msgstr "Bewertung"
#: cps/templates/edit_book.html:43
msgid "Cover URL (jpg)"
msgstr "Cover URL (jpg)"
#: cps/templates/edit_book.html:48 cps/templates/user_edit.html:27
msgid "Language"
msgstr "Sprache"
#: cps/templates/edit_book.html:59
msgid "Yes"
msgstr "Ja"
#: cps/templates/edit_book.html:60
msgid "No"
msgstr "Nein"
#: cps/templates/edit_book.html:102
msgid "view book after edit"
msgstr "Buch nach Bearbeitung ansehen"
#: cps/templates/edit_book.html:105 cps/templates/email_edit.html:30
#: cps/templates/login.html:19 cps/templates/search_form.html:33
#: cps/templates/shelf_edit.html:15 cps/templates/user_edit.html:93
msgid "Submit"
msgstr "Abschicken"
#: cps/templates/email_edit.html:7 cps/templates/user_list.html:36
msgid "SMTP hostname"
msgstr "SMTP Hostname"
#: cps/templates/email_edit.html:11
msgid "SMTP port (usually 25 for plain SMTP and 587 for SSL)"
msgstr "SMTP Port (normalerweise 25 für unverschlüsseltes SMTP und 587 für SSL)"
#: cps/templates/email_edit.html:15
msgid "Server uses SSL (StartTLS)"
msgstr "Server benutzt SSL (StartTLS)"
#: cps/templates/email_edit.html:19 cps/templates/user_list.html:39
msgid "SMTP login"
msgstr "SMTP Login"
#: cps/templates/email_edit.html:23 cps/templates/user_list.html:40
msgid "SMTP password"
msgstr "SMTP Passwort"
#: cps/templates/email_edit.html:27
msgid "From e-mail"
msgstr "Absenderadresse"
#: cps/templates/feed.xml:14
msgid "Next"
msgstr "Nächste"
#: cps/templates/index.html:5
msgid "Discover (Random Books)"
msgstr "Entdecke (Zufälliges Buch)"
#: cps/templates/index.xml:8
msgid "Start"
msgstr "Start"
#: cps/templates/index.xml:12 cps/templates/layout.html:59
msgid "Search"
msgstr "Suche"
#: cps/templates/index.xml:23 cps/templates/layout.html:122
msgid "Hot Books"
msgstr "Beliebte Bücher"
#: cps/templates/index.xml:28
msgid "Popular publications from this catalog based on Rating."
msgstr "Beliebte Veröffentlichungen dieses Katalogs basierend auf Bewertungen"
#: cps/templates/index.xml:32 cps/templates/layout.html:120
msgid "New Books"
msgstr "Neue Bücher"
#: cps/templates/index.xml:37
msgid "The latest Books"
msgstr "Die neuesten Bücher"
#: cps/templates/index.xml:46
msgid "Show Random Books"
msgstr "Zeige zufällige Bücher"
#: cps/templates/index.xml:49 cps/templates/layout.html:133
msgid "Authors"
msgstr "Autoren"
#: cps/templates/index.xml:54
msgid "Books ordered by Author"
msgstr "Bücher nach Autoren sortiert"
#: cps/templates/index.xml:62
msgid "Books ordered by category"
msgstr "Bücher nach Kategorien sortiert"
#: cps/templates/index.xml:70
msgid "Books ordered by series"
msgstr ""
#: cps/templates/layout.html:46
msgid "Toggle navigation"
msgstr "Nagivation umschalten"
#: cps/templates/layout.html:61
msgid "Go!"
msgstr "Los!"
#: cps/templates/layout.html:64
msgid "Advanced Search"
msgstr "Erweiterte Suche"
#: cps/templates/layout.html:74 cps/templates/user_list.html:13
msgid "Upload"
msgstr "Hochladen"
#: cps/templates/layout.html:81 cps/templates/user_list.html:11
msgid "Admin"
msgstr "Admin"
#: cps/templates/layout.html:85
msgid "Logout"
msgstr "Logout"
#: cps/templates/layout.html:89 cps/templates/login.html:4
msgid "Login"
msgstr "Login"
#: cps/templates/layout.html:90 cps/templates/register.html:18
msgid "Register"
msgstr "Registrieren"
#: cps/templates/layout.html:119
msgid "Browse"
msgstr "Browsen"
#: cps/templates/layout.html:125
msgid "Discover"
msgstr "Entdecke"
#: cps/templates/layout.html:128
msgid "Categories"
msgstr "Kategorien"
#: cps/templates/layout.html:135
msgid "Languages"
msgstr "Sprachen"
#: cps/templates/layout.html:138
msgid "Public Shelves"
msgstr "Öffentiche Bücherregale"
#: cps/templates/layout.html:142
msgid "Your Shelves"
msgstr "Deine Bücherregale"
#: cps/templates/layout.html:147
msgid "Create a Shelf"
msgstr "Bücherregal erzeugen"
#: cps/templates/layout.html:150
msgid "About"
msgstr "Über"
#: cps/templates/login.html:7 cps/templates/login.html:8
#: cps/templates/register.html:7 cps/templates/user_edit.html:8
msgid "Username"
msgstr "Benutzername"
#: cps/templates/login.html:11 cps/templates/login.html:12
#: cps/templates/register.html:11 cps/templates/user_edit.html:18
msgid "Password"
msgstr "Passwort"
#: cps/templates/login.html:16
msgid "Remember me"
msgstr "Merken"
#: cps/templates/register.html:4
msgid "Register a new account"
msgstr "Neues Benutzerkonto erzeugen"
#: cps/templates/register.html:8
msgid "Choose a username"
msgstr "Wähle einen Benutzernamen"
#: cps/templates/register.html:12
msgid "Choose a password"
msgstr "Wähle ein Passwort"
#: cps/templates/register.html:15 cps/templates/user_edit.html:13
msgid "Email address"
msgstr "E-Mail Adresse"
#: cps/templates/register.html:16
msgid "Your email address"
msgstr "Deine E-Mail Adresse"
#: cps/templates/search.html:6
msgid "No Results for:"
msgstr "Keine Ergebnisse für:"
#: cps/templates/search.html:7
msgid "Please try a diffrent Search"
msgstr "Versuche eine andere Suche"
#: cps/templates/search.html:9
msgid "Results for:"
msgstr "Ergebnisse für:"
#: cps/templates/search_form.html:23
msgid "Exclude Tags"
msgstr "Tags ausschließen"
#: cps/templates/shelf.html:6
msgid "Delete this Shelf"
msgstr "Lösche dieses Bücherregal"
#: cps/templates/shelf_edit.html:7
msgid "Title"
msgstr "Titel"
#: cps/templates/shelf_edit.html:12
msgid "should the shelf be public?"
msgstr "Soll das Bücherregal öffentlich sein?"
#: cps/templates/stats.html:4
msgid "Books in this Library"
msgstr "Bücher in dieser Bibliothek"
#: cps/templates/stats.html:5
msgid "Authors in this Library"
msgstr "Autoren in dieser Bibliothek"
#: cps/templates/stats.html:6
msgid "Version"
msgstr "Version"
#: cps/templates/user_edit.html:23
msgid "Kindle E-Mail"
msgstr "Kindle E-Mail"
#: cps/templates/user_edit.html:35
msgid "Show books with language"
msgstr "Zeige nur Bücher mit dieser Sprache"
#: cps/templates/user_edit.html:37
msgid "Show all"
msgstr "Zeige alle"
#: cps/templates/user_edit.html:46
msgid "Show random books"
msgstr "Zeige Zufällige Bücher"
#: cps/templates/user_edit.html:50
msgid "Show hot books"
msgstr "Zeige Auswahl Beliebte Bücher"
#: cps/templates/user_edit.html:54
msgid "Show language selection"
msgstr "Zeige Sprachauswahl"
#: cps/templates/user_edit.html:58
msgid "Show series selection"
msgstr "Zeige Auswahl Serien"
#: cps/templates/user_edit.html:62
msgid "Show category selection"
msgstr "Zeige Kategorie Auswahl"
#: cps/templates/user_edit.html:67
msgid "Admin user"
msgstr "Admin Benutzer"
#: cps/templates/user_edit.html:71
msgid "Allow Downloads"
msgstr "Downloads erlauben"
#: cps/templates/user_edit.html:75
msgid "Allow Uploads"
msgstr "Uploads erlauben"
#: cps/templates/user_edit.html:79
msgid "Allow Edit"
msgstr "Bearbeiten erlauben"
#: cps/templates/user_edit.html:83
msgid "Allow Changing Password"
msgstr "Passwort ändern erlauben"
#: cps/templates/user_edit.html:89
msgid "Delete this user"
msgstr "Benutzer löschen"
#: cps/templates/user_edit.html:97
msgid "Recent Downloads"
msgstr "Letzte Downloads"
#: cps/templates/user_list.html:7
msgid "Nickname"
msgstr "Benutzername"
#: cps/templates/user_list.html:8
msgid "Email"
msgstr "E-Mail"
#: cps/templates/user_list.html:9
msgid "Kindle"
msgstr "Kindle"
#: cps/templates/user_list.html:10
msgid "DLS"
msgstr "DLS"
#: cps/templates/user_list.html:14
msgid "Edit"
msgstr "Editieren"
#: cps/templates/user_list.html:15
msgid "Passwd"
msgstr "Passwort"
#: cps/templates/user_list.html:33
msgid "SMTP mail settings"
msgstr "SMTP Mail Einstellungen"
#: cps/templates/user_list.html:37
msgid "SMTP port"
msgstr "SMTP Port"
#: cps/templates/user_list.html:38
msgid "SSL"
msgstr "SSL"
#: cps/templates/user_list.html:41
msgid "From mail"
msgstr "Absenderadresse"
#: cps/templates/user_list.html:53
msgid "Change SMTP settings"
msgstr "SMTP Einstellungen ändern"
msgid "Latin"
msgstr "Latein"

View File

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
from sqlalchemy import *
from sqlalchemy import exc
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import *
import os
@ -32,6 +33,13 @@ class User(Base):
shelf = relationship('Shelf', backref = 'user', lazy = 'dynamic')
whislist = relationship('Whislist', backref = 'user', lazy = 'dynamic')
downloads = relationship('Downloads', backref= 'user', lazy = 'dynamic')
locale = Column(String(2), default="en")
random_books = Column(Integer, default=1)
language_books = Column(Integer, default=1)
series_books = Column(Integer, default=1)
category_books = Column(Integer, default=1)
hot_books = Column(Integer, default=1)
default_language = Column(String(3), default="all")
def is_authenticated(self):
return True
@ -70,6 +78,25 @@ class User(Base):
def get_id(self):
return unicode(self.id)
def filter_language(self):
return self.default_language
def show_random_books(self):
return self.random_books
def show_language(self):
return self.language_books
def show_hot_books(self):
return self.hot_books
def show_series(self):
return self.series_books
def show_category(self):
return self.category_books
def __repr__(self):
return '<User %r>' % (self.nickname)
@ -147,6 +174,28 @@ class Settings(Base):
#return '<Smtp %r>' % (self.mail_server)
pass
def migrate_Database():
try:
session.query(exists().where(User.random_books)).scalar()
session.commit()
except exc.OperationalError: # Database is not compatible, some rows are missing
conn=engine.connect()
conn.execute("ALTER TABLE user ADD column random_books INTEGER DEFAULT 1")
conn.execute("ALTER TABLE user ADD column locale String(2) DEFAULT 'en'")
conn.execute("ALTER TABLE user ADD column default_language String(3) DEFAULT 'all'")
session.commit()
try:
session.query(exists().where(User.language_books)).scalar()
session.commit()
except exc.OperationalError: # Database is not compatible, some rows are missing
conn = engine.connect()
conn.execute("ALTER TABLE user ADD column language_books INTEGER DEFAULT 1")
conn.execute("ALTER TABLE user ADD column series_books INTEGER DEFAULT 1")
conn.execute("ALTER TABLE user ADD column category_books INTEGER DEFAULT 1")
conn.execute("ALTER TABLE user ADD column hot_books INTEGER DEFAULT 1")
session.commit()
def create_default_config():
settings = Settings()
settings.mail_server = "mail.example.com"
@ -200,4 +249,6 @@ if not os.path.exists(dbpath):
create_admin_user()
except Exception:
pass
else:
migrate_Database()

1086
cps/web.py

File diff suppressed because it is too large Load Diff

665
messages.pot Normal file
View File

@ -0,0 +1,665 @@
# Translations template for PROJECT.
# Copyright (C) 2016 ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2016.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2016-11-09 18:52+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.3.4\n"
#: cps/helper.py:76 cps/templates/detail.html:113
msgid "Send to Kindle"
msgstr ""
#: cps/helper.py:77
msgid "This email has been sent via calibre web."
msgstr ""
#: cps/helper.py:99 cps/helper.py:114
msgid "Could not find any formats suitable for sending by email"
msgstr ""
#: cps/helper.py:108
msgid "Could not convert epub to mobi"
msgstr ""
#: cps/helper.py:138
#, python-format
msgid "Failed to send mail: %s"
msgstr ""
#: cps/helper.py:158
msgid "The requested file could not be read. Maybe wrong permissions?"
msgstr ""
#: cps/web.py:633
msgid "Latest Books"
msgstr ""
#: cps/web.py:655
msgid "Hot Books (most downloaded)"
msgstr ""
#: cps/templates/index.xml:41 cps/web.py:662
msgid "Random Books"
msgstr ""
#: cps/web.py:673
msgid "Author list"
msgstr ""
#: cps/web.py:689
#, python-format
msgid "Author: %(nam)s"
msgstr ""
#: cps/templates/index.xml:65 cps/web.py:700
msgid "Series list"
msgstr ""
#: cps/web.py:708
#, python-format
msgid "Series: %(serie)s"
msgstr ""
#: cps/web.py:710 cps/web.py:790 cps/web.py:908 cps/web.py:1518
msgid "Error opening eBook. File does not exist or file is not accessible:"
msgstr ""
#: cps/web.py:736
msgid "Available languages"
msgstr ""
#: cps/web.py:748
#, python-format
msgid "Language: %(name)s"
msgstr ""
#: cps/templates/index.xml:57 cps/web.py:759
msgid "Category list"
msgstr ""
#: cps/web.py:766
#, python-format
msgid "Category: %(name)s"
msgstr ""
#: cps/web.py:804
msgid "Statistics"
msgstr ""
#: cps/web.py:892 cps/web.py:899 cps/web.py:906
msgid "Read a Book"
msgstr ""
#: cps/web.py:945 cps/web.py:1173
msgid "Please fill out all fields!"
msgstr ""
#: cps/web.py:961
msgid "An unknown error occured. Please try again later."
msgstr ""
#: cps/web.py:966
msgid "This username or email address is already in use."
msgstr ""
#: cps/web.py:969
msgid "register"
msgstr ""
#: cps/web.py:984
#, python-format
msgid "you are now logged in as: '%(nickname)s'"
msgstr ""
#: cps/web.py:987
msgid "Wrong Username or Password"
msgstr ""
#: cps/web.py:989
msgid "login"
msgstr ""
#: cps/web.py:1005
msgid "Please configure the SMTP mail settings first..."
msgstr ""
#: cps/web.py:1009
#, python-format
msgid "Book successfully send to %(kindlemail)s"
msgstr ""
#: cps/web.py:1012
#, python-format
msgid "There was an error sending this book: %(res)s"
msgstr ""
#: cps/web.py:1014
msgid "Please configure your kindle email address first..."
msgstr ""
#: cps/web.py:1029
#, python-format
msgid "Book has been added to shelf: %(sname)s"
msgstr ""
#: cps/web.py:1048
#, python-format
msgid "Book has been removed from shelf: %(sname)s"
msgstr ""
#: cps/web.py:1064
#, python-format
msgid "A shelf with the name '%(title)s' already exists."
msgstr ""
#: cps/web.py:1069
#, python-format
msgid "Shelf %(title)s created"
msgstr ""
#: cps/web.py:1071
msgid "There was an error"
msgstr ""
#: cps/web.py:1072 cps/web.py:1074
msgid "create a shelf"
msgstr ""
#: cps/web.py:1090
#, python-format
msgid "successfully deleted shelf %(name)s"
msgstr ""
#: cps/web.py:1107
#, python-format
msgid "Shelf: '%(name)s'"
msgstr ""
#: cps/web.py:1144
msgid "Found an existing account for this email address."
msgstr ""
#: cps/web.py:1145 cps/web.py:1147
#, python-format
msgid "%(name)s's profile"
msgstr ""
#: cps/web.py:1146
msgid "Profile updated"
msgstr ""
#: cps/web.py:1155
msgid "User list"
msgstr ""
#: cps/templates/user_list.html:32 cps/web.py:1174
msgid "Add new user"
msgstr ""
#: cps/web.py:1207
#, python-format
msgid "User '%(user)s' created"
msgstr ""
#: cps/web.py:1211
msgid "Found an existing account for this email address or nickname."
msgstr ""
#: cps/web.py:1232
msgid "Mail settings updated"
msgstr ""
#: cps/web.py:1235
msgid "Edit mail settings"
msgstr ""
#: cps/web.py:1257
#, python-format
msgid "User '%(nick)s' deleted"
msgstr ""
#: cps/web.py:1312
#, python-format
msgid "User '%(nick)s' updated"
msgstr ""
#: cps/web.py:1315
msgid "An unknown error occured."
msgstr ""
#: cps/web.py:1316
#, python-format
msgid "Edit User %(nick)s"
msgstr ""
#: cps/web.py:1550
#, python-format
msgid "Failed to create path %s (Permission denied)."
msgstr ""
#: cps/web.py:1555
#, python-format
msgid "Failed to store file %s (Permission denied)."
msgstr ""
#: cps/web.py:1560
#, python-format
msgid "Failed to delete file %s (Permission denied)."
msgstr ""
#: cps/templates/detail.html:38
msgid "Book"
msgstr ""
#: cps/templates/detail.html:38
msgid "of"
msgstr ""
#: cps/templates/detail.html:44
msgid "language"
msgstr ""
#: cps/templates/detail.html:92
msgid "Description:"
msgstr ""
#: cps/templates/detail.html:103 cps/templates/user_list.html:12
msgid "Download"
msgstr ""
#: cps/templates/detail.html:117
msgid "Read in browser"
msgstr ""
#: cps/templates/detail.html:136
msgid "Add to shelf"
msgstr ""
#: cps/templates/detail.html:176
msgid "Edit metadata"
msgstr ""
#: cps/templates/edit_book.html:14 cps/templates/search_form.html:6
msgid "Book Title"
msgstr ""
#: cps/templates/edit_book.html:18 cps/templates/search_form.html:10
msgid "Author"
msgstr ""
#: cps/templates/edit_book.html:22
msgid "Description"
msgstr ""
#: cps/templates/edit_book.html:26 cps/templates/search_form.html:13
msgid "Tags"
msgstr ""
#: cps/templates/edit_book.html:31 cps/templates/layout.html:131
msgid "Series"
msgstr ""
#: cps/templates/edit_book.html:35
msgid "Series id"
msgstr ""
#: cps/templates/edit_book.html:39
msgid "Rating"
msgstr ""
#: cps/templates/edit_book.html:43
msgid "Cover URL (jpg)"
msgstr ""
#: cps/templates/edit_book.html:48 cps/templates/user_edit.html:27
msgid "Language"
msgstr ""
#: cps/templates/edit_book.html:59
msgid "Yes"
msgstr ""
#: cps/templates/edit_book.html:60
msgid "No"
msgstr ""
#: cps/templates/edit_book.html:102
msgid "view book after edit"
msgstr ""
#: cps/templates/edit_book.html:105 cps/templates/email_edit.html:30
#: cps/templates/login.html:19 cps/templates/search_form.html:33
#: cps/templates/shelf_edit.html:15 cps/templates/user_edit.html:93
msgid "Submit"
msgstr ""
#: cps/templates/email_edit.html:7 cps/templates/user_list.html:36
msgid "SMTP hostname"
msgstr ""
#: cps/templates/email_edit.html:11
msgid "SMTP port (usually 25 for plain SMTP and 587 for SSL)"
msgstr ""
#: cps/templates/email_edit.html:15
msgid "Server uses SSL (StartTLS)"
msgstr ""
#: cps/templates/email_edit.html:19 cps/templates/user_list.html:39
msgid "SMTP login"
msgstr ""
#: cps/templates/email_edit.html:23 cps/templates/user_list.html:40
msgid "SMTP password"
msgstr ""
#: cps/templates/email_edit.html:27
msgid "From e-mail"
msgstr ""
#: cps/templates/feed.xml:14
msgid "Next"
msgstr ""
#: cps/templates/index.html:5
msgid "Discover (Random Books)"
msgstr ""
#: cps/templates/index.xml:8
msgid "Start"
msgstr ""
#: cps/templates/index.xml:12 cps/templates/layout.html:59
msgid "Search"
msgstr ""
#: cps/templates/index.xml:23 cps/templates/layout.html:122
msgid "Hot Books"
msgstr ""
#: cps/templates/index.xml:28
msgid "Popular publications from this catalog based on Rating."
msgstr ""
#: cps/templates/index.xml:32 cps/templates/layout.html:120
msgid "New Books"
msgstr ""
#: cps/templates/index.xml:37
msgid "The latest Books"
msgstr ""
#: cps/templates/index.xml:46
msgid "Show Random Books"
msgstr ""
#: cps/templates/index.xml:49 cps/templates/layout.html:133
msgid "Authors"
msgstr ""
#: cps/templates/index.xml:54
msgid "Books ordered by Author"
msgstr ""
#: cps/templates/index.xml:62
msgid "Books ordered by category"
msgstr ""
#: cps/templates/index.xml:70
msgid "Books ordered by series"
msgstr ""
#: cps/templates/layout.html:46
msgid "Toggle navigation"
msgstr ""
#: cps/templates/layout.html:61
msgid "Go!"
msgstr ""
#: cps/templates/layout.html:64
msgid "Advanced Search"
msgstr ""
#: cps/templates/layout.html:74 cps/templates/user_list.html:13
msgid "Upload"
msgstr ""
#: cps/templates/layout.html:81 cps/templates/user_list.html:11
msgid "Admin"
msgstr ""
#: cps/templates/layout.html:85
msgid "Logout"
msgstr ""
#: cps/templates/layout.html:89 cps/templates/login.html:4
msgid "Login"
msgstr ""
#: cps/templates/layout.html:90 cps/templates/register.html:18
msgid "Register"
msgstr ""
#: cps/templates/layout.html:119
msgid "Browse"
msgstr ""
#: cps/templates/layout.html:125
msgid "Discover"
msgstr ""
#: cps/templates/layout.html:128
msgid "Categories"
msgstr ""
#: cps/templates/layout.html:135
msgid "Languages"
msgstr ""
#: cps/templates/layout.html:138
msgid "Public Shelves"
msgstr ""
#: cps/templates/layout.html:142
msgid "Your Shelves"
msgstr ""
#: cps/templates/layout.html:147
msgid "Create a Shelf"
msgstr ""
#: cps/templates/layout.html:150
msgid "About"
msgstr ""
#: cps/templates/login.html:7 cps/templates/login.html:8
#: cps/templates/register.html:7 cps/templates/user_edit.html:8
msgid "Username"
msgstr ""
#: cps/templates/login.html:11 cps/templates/login.html:12
#: cps/templates/register.html:11 cps/templates/user_edit.html:18
msgid "Password"
msgstr ""
#: cps/templates/login.html:16
msgid "Remember me"
msgstr ""
#: cps/templates/register.html:4
msgid "Register a new account"
msgstr ""
#: cps/templates/register.html:8
msgid "Choose a username"
msgstr ""
#: cps/templates/register.html:12
msgid "Choose a password"
msgstr ""
#: cps/templates/register.html:15 cps/templates/user_edit.html:13
msgid "Email address"
msgstr ""
#: cps/templates/register.html:16
msgid "Your email address"
msgstr ""
#: cps/templates/search.html:6
msgid "No Results for:"
msgstr ""
#: cps/templates/search.html:7
msgid "Please try a diffrent Search"
msgstr ""
#: cps/templates/search.html:9
msgid "Results for:"
msgstr ""
#: cps/templates/search_form.html:23
msgid "Exclude Tags"
msgstr ""
#: cps/templates/shelf.html:6
msgid "Delete this Shelf"
msgstr ""
#: cps/templates/shelf_edit.html:7
msgid "Title"
msgstr ""
#: cps/templates/shelf_edit.html:12
msgid "should the shelf be public?"
msgstr ""
#: cps/templates/stats.html:4
msgid "Books in this Library"
msgstr ""
#: cps/templates/stats.html:5
msgid "Authors in this Library"
msgstr ""
#: cps/templates/stats.html:6
msgid "Version"
msgstr ""
#: cps/templates/user_edit.html:23
msgid "Kindle E-Mail"
msgstr ""
#: cps/templates/user_edit.html:35
msgid "Show books with language"
msgstr ""
#: cps/templates/user_edit.html:37
msgid "Show all"
msgstr ""
#: cps/templates/user_edit.html:46
msgid "Show random books"
msgstr ""
#: cps/templates/user_edit.html:50
msgid "Show hot books"
msgstr ""
#: cps/templates/user_edit.html:54
msgid "Show language selection"
msgstr ""
#: cps/templates/user_edit.html:58
msgid "Show Series Selection"
msgstr ""
#: cps/templates/user_edit.html:62
msgid "Show Category Selection"
msgstr ""
#: cps/templates/user_edit.html:67
msgid "Admin user"
msgstr ""
#: cps/templates/user_edit.html:71
msgid "Allow Downloads"
msgstr ""
#: cps/templates/user_edit.html:75
msgid "Allow Uploads"
msgstr ""
#: cps/templates/user_edit.html:79
msgid "Allow Edit"
msgstr ""
#: cps/templates/user_edit.html:83
msgid "Allow Changing Password"
msgstr ""
#: cps/templates/user_edit.html:89
msgid "Delete this user"
msgstr ""
#: cps/templates/user_edit.html:97
msgid "Recent Downloads"
msgstr ""
#: cps/templates/user_list.html:7
msgid "Nickname"
msgstr ""
#: cps/templates/user_list.html:8
msgid "Email"
msgstr ""
#: cps/templates/user_list.html:9
msgid "Kindle"
msgstr ""
#: cps/templates/user_list.html:10
msgid "DLS"
msgstr ""
#: cps/templates/user_list.html:14
msgid "Edit"
msgstr ""
#: cps/templates/user_list.html:15
msgid "Passwd"
msgstr ""
#: cps/templates/user_list.html:33
msgid "SMTP mail settings"
msgstr ""
#: cps/templates/user_list.html:37
msgid "SMTP port"
msgstr ""
#: cps/templates/user_list.html:38
msgid "SSL"
msgstr ""
#: cps/templates/user_list.html:41
msgid "From mail"
msgstr ""
#: cps/templates/user_list.html:53
msgid "Change SMTP settings"
msgstr ""

22
vendor/LICENSE_flask_login vendored Normal file
View File

@ -0,0 +1,22 @@
Copyright (c) 2011 Matthew Frazier
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

22
vendor/LICENSE_flask_principal vendored Normal file
View File

@ -0,0 +1,22 @@
Copyright (c) 2012 Ali Afshar
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

31
vendor/LICENSE_itsdangerous vendored Normal file
View File

@ -0,0 +1,31 @@
Copyright (c) 2011 by Armin Ronacher and the Django Software Foundation.
Some rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* The names of the contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

1
vendor/_version.py vendored Normal file
View File

@ -0,0 +1 @@
__version__ = '5.0.6'

28
vendor/babel/AUTHORS vendored Normal file
View File

@ -0,0 +1,28 @@
Babel is written and maintained by the Babel team and various contributors:
Maintainer and Current Project Lead:
- Armin Ronacher <armin.ronacher@active-4.com>
Contributors:
- Christopher Lenz <cmlenz@gmail.com>
- Alex Morega <alex@grep.ro>
- Felix Schwarz <felix.schwarz@oss.schwarz.eu>
- Pedro Algarvio <pedro@algarvio.me>
- Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
- Philip Jenvey <pjenvey@underboss.org>
- Tobias Bieniek <Tobias.Bieniek@gmx.de>
- Jonas Borgström <jonas@edgewall.org>
- Daniel Neuhäuser <dasdasich@gmail.com>
- Nick Retallack <nick@bitcasa.com>
- Thomas Waldmann <tw@waldmann-edv.de>
- Lennart Regebro <regebro@gmail.com>
Babel was previously developed under the Copyright of Edgewall Software. The
following copyright notice holds true for releases before 2013: "Copyright (c)
2007 - 2011 by Edgewall Software"
In addition to the regular contributions Babel includes a fork of Lennart
Regebro's tzlocal that originally was licensed under the CC0 license. The
original copyright of that project is "Copyright 2013 by Lennart Regebro".

29
vendor/babel/LICENSE vendored Normal file
View File

@ -0,0 +1,29 @@
Copyright (C) 2013 by the Babel Team, see AUTHORS for more information.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

24
vendor/babel/__init__.py vendored Normal file
View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
"""
babel
~~~~~
Integrated collection of utilities that assist in internationalizing and
localizing applications.
This package is basically composed of two major parts:
* tools to build and work with ``gettext`` message catalogs
* a Python interface to the CLDR (Common Locale Data Repository), providing
access to various locale display names, localized number and date
formatting, etc.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
from babel.core import UnknownLocaleError, Locale, default_locale, \
negotiate_locale, parse_locale, get_locale_identifier
__version__ = '1.3'

51
vendor/babel/_compat.py vendored Normal file
View File

@ -0,0 +1,51 @@
import sys
PY2 = sys.version_info[0] == 2
_identity = lambda x: x
if not PY2:
text_type = str
string_types = (str,)
integer_types = (int, )
unichr = chr
text_to_native = lambda s, enc: s
iterkeys = lambda d: iter(d.keys())
itervalues = lambda d: iter(d.values())
iteritems = lambda d: iter(d.items())
from io import StringIO, BytesIO
import pickle
izip = zip
imap = map
range_type = range
cmp = lambda a, b: (a > b) - (a < b)
else:
text_type = unicode
string_types = (str, unicode)
integer_types = (int, long)
text_to_native = lambda s, enc: s.encode(enc)
unichr = unichr
iterkeys = lambda d: d.iterkeys()
itervalues = lambda d: d.itervalues()
iteritems = lambda d: d.iteritems()
from cStringIO import StringIO as BytesIO
from StringIO import StringIO
import cPickle as pickle
from itertools import izip, imap
range_type = xrange
cmp = cmp
number_types = integer_types + (float,)

941
vendor/babel/core.py vendored Normal file
View File

@ -0,0 +1,941 @@
# -*- coding: utf-8 -*-
"""
babel.core
~~~~~~~~~~
Core locale representation and locale data access.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
import os
from babel import localedata
from babel._compat import pickle, string_types
__all__ = ['UnknownLocaleError', 'Locale', 'default_locale', 'negotiate_locale',
'parse_locale']
_global_data = None
def _raise_no_data_error():
raise RuntimeError('The babel data files are not available. '
'This usually happens because you are using '
'a source checkout from Babel and you did '
'not build the data files. Just make sure '
'to run "python setup.py import_cldr" before '
'installing the library.')
def get_global(key):
"""Return the dictionary for the given key in the global data.
The global data is stored in the ``babel/global.dat`` file and contains
information independent of individual locales.
>>> get_global('zone_aliases')['UTC']
u'Etc/GMT'
>>> get_global('zone_territories')['Europe/Berlin']
u'DE'
.. versionadded:: 0.9
:param key: the data key
"""
global _global_data
if _global_data is None:
dirname = os.path.join(os.path.dirname(__file__))
filename = os.path.join(dirname, 'global.dat')
if not os.path.isfile(filename):
_raise_no_data_error()
fileobj = open(filename, 'rb')
try:
_global_data = pickle.load(fileobj)
finally:
fileobj.close()
return _global_data.get(key, {})
LOCALE_ALIASES = {
'ar': 'ar_SY', 'bg': 'bg_BG', 'bs': 'bs_BA', 'ca': 'ca_ES', 'cs': 'cs_CZ',
'da': 'da_DK', 'de': 'de_DE', 'el': 'el_GR', 'en': 'en_US', 'es': 'es_ES',
'et': 'et_EE', 'fa': 'fa_IR', 'fi': 'fi_FI', 'fr': 'fr_FR', 'gl': 'gl_ES',
'he': 'he_IL', 'hu': 'hu_HU', 'id': 'id_ID', 'is': 'is_IS', 'it': 'it_IT',
'ja': 'ja_JP', 'km': 'km_KH', 'ko': 'ko_KR', 'lt': 'lt_LT', 'lv': 'lv_LV',
'mk': 'mk_MK', 'nl': 'nl_NL', 'nn': 'nn_NO', 'no': 'nb_NO', 'pl': 'pl_PL',
'pt': 'pt_PT', 'ro': 'ro_RO', 'ru': 'ru_RU', 'sk': 'sk_SK', 'sl': 'sl_SI',
'sv': 'sv_SE', 'th': 'th_TH', 'tr': 'tr_TR', 'uk': 'uk_UA'
}
class UnknownLocaleError(Exception):
"""Exception thrown when a locale is requested for which no locale data
is available.
"""
def __init__(self, identifier):
"""Create the exception.
:param identifier: the identifier string of the unsupported locale
"""
Exception.__init__(self, 'unknown locale %r' % identifier)
#: The identifier of the locale that could not be found.
self.identifier = identifier
class Locale(object):
"""Representation of a specific locale.
>>> locale = Locale('en', 'US')
>>> repr(locale)
"Locale('en', territory='US')"
>>> locale.display_name
u'English (United States)'
A `Locale` object can also be instantiated from a raw locale string:
>>> locale = Locale.parse('en-US', sep='-')
>>> repr(locale)
"Locale('en', territory='US')"
`Locale` objects provide access to a collection of locale data, such as
territory and language names, number and date format patterns, and more:
>>> locale.number_symbols['decimal']
u'.'
If a locale is requested for which no locale data is available, an
`UnknownLocaleError` is raised:
>>> Locale.parse('en_DE')
Traceback (most recent call last):
...
UnknownLocaleError: unknown locale 'en_DE'
For more information see :rfc:`3066`.
"""
def __init__(self, language, territory=None, script=None, variant=None):
"""Initialize the locale object from the given identifier components.
>>> locale = Locale('en', 'US')
>>> locale.language
'en'
>>> locale.territory
'US'
:param language: the language code
:param territory: the territory (country or region) code
:param script: the script code
:param variant: the variant code
:raise `UnknownLocaleError`: if no locale data is available for the
requested locale
"""
#: the language code
self.language = language
#: the territory (country or region) code
self.territory = territory
#: the script code
self.script = script
#: the variant code
self.variant = variant
self.__data = None
identifier = str(self)
if not localedata.exists(identifier):
raise UnknownLocaleError(identifier)
@classmethod
def default(cls, category=None, aliases=LOCALE_ALIASES):
"""Return the system default locale for the specified category.
>>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LC_MESSAGES']:
... os.environ[name] = ''
>>> os.environ['LANG'] = 'fr_FR.UTF-8'
>>> Locale.default('LC_MESSAGES')
Locale('fr', territory='FR')
The following fallbacks to the variable are always considered:
- ``LANGUAGE``
- ``LC_ALL``
- ``LC_CTYPE``
- ``LANG``
:param category: one of the ``LC_XXX`` environment variable names
:param aliases: a dictionary of aliases for locale identifiers
"""
# XXX: use likely subtag expansion here instead of the
# aliases dictionary.
locale_string = default_locale(category, aliases=aliases)
return cls.parse(locale_string)
@classmethod
def negotiate(cls, preferred, available, sep='_', aliases=LOCALE_ALIASES):
"""Find the best match between available and requested locale strings.
>>> Locale.negotiate(['de_DE', 'en_US'], ['de_DE', 'de_AT'])
Locale('de', territory='DE')
>>> Locale.negotiate(['de_DE', 'en_US'], ['en', 'de'])
Locale('de')
>>> Locale.negotiate(['de_DE', 'de'], ['en_US'])
You can specify the character used in the locale identifiers to separate
the differnet components. This separator is applied to both lists. Also,
case is ignored in the comparison:
>>> Locale.negotiate(['de-DE', 'de'], ['en-us', 'de-de'], sep='-')
Locale('de', territory='DE')
:param preferred: the list of locale identifers preferred by the user
:param available: the list of locale identifiers available
:param aliases: a dictionary of aliases for locale identifiers
"""
identifier = negotiate_locale(preferred, available, sep=sep,
aliases=aliases)
if identifier:
return Locale.parse(identifier, sep=sep)
@classmethod
def parse(cls, identifier, sep='_', resolve_likely_subtags=True):
"""Create a `Locale` instance for the given locale identifier.
>>> l = Locale.parse('de-DE', sep='-')
>>> l.display_name
u'Deutsch (Deutschland)'
If the `identifier` parameter is not a string, but actually a `Locale`
object, that object is returned:
>>> Locale.parse(l)
Locale('de', territory='DE')
This also can perform resolving of likely subtags which it does
by default. This is for instance useful to figure out the most
likely locale for a territory you can use ``'und'`` as the
language tag:
>>> Locale.parse('und_AT')
Locale('de', territory='AT')
:param identifier: the locale identifier string
:param sep: optional component separator
:param resolve_likely_subtags: if this is specified then a locale will
have its likely subtag resolved if the
locale otherwise does not exist. For
instance ``zh_TW`` by itself is not a
locale that exists but Babel can
automatically expand it to the full
form of ``zh_hant_TW``. Note that this
expansion is only taking place if no
locale exists otherwise. For instance
there is a locale ``en`` that can exist
by itself.
:raise `ValueError`: if the string does not appear to be a valid locale
identifier
:raise `UnknownLocaleError`: if no locale data is available for the
requested locale
"""
if identifier is None:
return None
elif isinstance(identifier, Locale):
return identifier
elif not isinstance(identifier, string_types):
raise TypeError('Unxpected value for identifier: %r' % (identifier,))
parts = parse_locale(identifier, sep=sep)
input_id = get_locale_identifier(parts)
def _try_load(parts):
try:
return cls(*parts)
except UnknownLocaleError:
return None
def _try_load_reducing(parts):
# Success on first hit, return it.
locale = _try_load(parts)
if locale is not None:
return locale
# Now try without script and variant
locale = _try_load(parts[:2])
if locale is not None:
return locale
locale = _try_load(parts)
if locale is not None:
return locale
if not resolve_likely_subtags:
raise UnknownLocaleError(input_id)
# From here onwards is some very bad likely subtag resolving. This
# whole logic is not entirely correct but good enough (tm) for the
# time being. This has been added so that zh_TW does not cause
# errors for people when they upgrade. Later we should properly
# implement ICU like fuzzy locale objects and provide a way to
# maximize and minimize locale tags.
language, territory, script, variant = parts
language = get_global('language_aliases').get(language, language)
territory = get_global('territory_aliases').get(territory, territory)
script = get_global('script_aliases').get(script, script)
variant = get_global('variant_aliases').get(variant, variant)
if territory == 'ZZ':
territory = None
if script == 'Zzzz':
script = None
parts = language, territory, script, variant
# First match: try the whole identifier
new_id = get_locale_identifier(parts)
likely_subtag = get_global('likely_subtags').get(new_id)
if likely_subtag is not None:
locale = _try_load_reducing(parse_locale(likely_subtag))
if locale is not None:
return locale
# If we did not find anything so far, try again with a
# simplified identifier that is just the language
likely_subtag = get_global('likely_subtags').get(language)
if likely_subtag is not None:
language2, _, script2, variant2 = parse_locale(likely_subtag)
locale = _try_load_reducing((language2, territory, script2, variant2))
if locale is not None:
return locale
raise UnknownLocaleError(input_id)
def __eq__(self, other):
for key in ('language', 'territory', 'script', 'variant'):
if not hasattr(other, key):
return False
return (self.language == other.language) and \
(self.territory == other.territory) and \
(self.script == other.script) and \
(self.variant == other.variant)
def __ne__(self, other):
return not self.__eq__(other)
def __repr__(self):
parameters = ['']
for key in ('territory', 'script', 'variant'):
value = getattr(self, key)
if value is not None:
parameters.append('%s=%r' % (key, value))
parameter_string = '%r' % self.language + ', '.join(parameters)
return 'Locale(%s)' % parameter_string
def __str__(self):
return get_locale_identifier((self.language, self.territory,
self.script, self.variant))
@property
def _data(self):
if self.__data is None:
self.__data = localedata.LocaleDataDict(localedata.load(str(self)))
return self.__data
def get_display_name(self, locale=None):
"""Return the display name of the locale using the given locale.
The display name will include the language, territory, script, and
variant, if those are specified.
>>> Locale('zh', 'CN', script='Hans').get_display_name('en')
u'Chinese (Simplified, China)'
:param locale: the locale to use
"""
if locale is None:
locale = self
locale = Locale.parse(locale)
retval = locale.languages.get(self.language)
if self.territory or self.script or self.variant:
details = []
if self.script:
details.append(locale.scripts.get(self.script))
if self.territory:
details.append(locale.territories.get(self.territory))
if self.variant:
details.append(locale.variants.get(self.variant))
details = filter(None, details)
if details:
retval += ' (%s)' % u', '.join(details)
return retval
display_name = property(get_display_name, doc="""\
The localized display name of the locale.
>>> Locale('en').display_name
u'English'
>>> Locale('en', 'US').display_name
u'English (United States)'
>>> Locale('sv').display_name
u'svenska'
:type: `unicode`
""")
def get_language_name(self, locale=None):
"""Return the language of this locale in the given locale.
>>> Locale('zh', 'CN', script='Hans').get_language_name('de')
u'Chinesisch'
.. versionadded:: 1.0
:param locale: the locale to use
"""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.languages.get(self.language)
language_name = property(get_language_name, doc="""\
The localized language name of the locale.
>>> Locale('en', 'US').language_name
u'English'
""")
def get_territory_name(self, locale=None):
"""Return the territory name in the given locale."""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.territories.get(self.territory)
territory_name = property(get_territory_name, doc="""\
The localized territory name of the locale if available.
>>> Locale('de', 'DE').territory_name
u'Deutschland'
""")
def get_script_name(self, locale=None):
"""Return the script name in the given locale."""
if locale is None:
locale = self
locale = Locale.parse(locale)
return locale.scripts.get(self.script)
script_name = property(get_script_name, doc="""\
The localized script name of the locale if available.
>>> Locale('ms', 'SG', script='Latn').script_name
u'Latin'
""")
@property
def english_name(self):
"""The english display name of the locale.
>>> Locale('de').english_name
u'German'
>>> Locale('de', 'DE').english_name
u'German (Germany)'
:type: `unicode`"""
return self.get_display_name(Locale('en'))
#{ General Locale Display Names
@property
def languages(self):
"""Mapping of language codes to translated language names.
>>> Locale('de', 'DE').languages['ja']
u'Japanisch'
See `ISO 639 <http://www.loc.gov/standards/iso639-2/>`_ for
more information.
"""
return self._data['languages']
@property
def scripts(self):
"""Mapping of script codes to translated script names.
>>> Locale('en', 'US').scripts['Hira']
u'Hiragana'
See `ISO 15924 <http://www.evertype.com/standards/iso15924/>`_
for more information.
"""
return self._data['scripts']
@property
def territories(self):
"""Mapping of script codes to translated script names.
>>> Locale('es', 'CO').territories['DE']
u'Alemania'
See `ISO 3166 <http://www.iso.org/iso/en/prods-services/iso3166ma/>`_
for more information.
"""
return self._data['territories']
@property
def variants(self):
"""Mapping of script codes to translated script names.
>>> Locale('de', 'DE').variants['1901']
u'Alte deutsche Rechtschreibung'
"""
return self._data['variants']
#{ Number Formatting
@property
def currencies(self):
"""Mapping of currency codes to translated currency names. This
only returns the generic form of the currency name, not the count
specific one. If an actual number is requested use the
:func:`babel.numbers.get_currency_name` function.
>>> Locale('en').currencies['COP']
u'Colombian Peso'
>>> Locale('de', 'DE').currencies['COP']
u'Kolumbianischer Peso'
"""
return self._data['currency_names']
@property
def currency_symbols(self):
"""Mapping of currency codes to symbols.
>>> Locale('en', 'US').currency_symbols['USD']
u'$'
>>> Locale('es', 'CO').currency_symbols['USD']
u'US$'
"""
return self._data['currency_symbols']
@property
def number_symbols(self):
"""Symbols used in number formatting.
>>> Locale('fr', 'FR').number_symbols['decimal']
u','
"""
return self._data['number_symbols']
@property
def decimal_formats(self):
"""Locale patterns for decimal number formatting.
>>> Locale('en', 'US').decimal_formats[None]
<NumberPattern u'#,##0.###'>
"""
return self._data['decimal_formats']
@property
def currency_formats(self):
"""Locale patterns for currency number formatting.
>>> print Locale('en', 'US').currency_formats[None]
<NumberPattern u'\\xa4#,##0.00'>
"""
return self._data['currency_formats']
@property
def percent_formats(self):
"""Locale patterns for percent number formatting.
>>> Locale('en', 'US').percent_formats[None]
<NumberPattern u'#,##0%'>
"""
return self._data['percent_formats']
@property
def scientific_formats(self):
"""Locale patterns for scientific number formatting.
>>> Locale('en', 'US').scientific_formats[None]
<NumberPattern u'#E0'>
"""
return self._data['scientific_formats']
#{ Calendar Information and Date Formatting
@property
def periods(self):
"""Locale display names for day periods (AM/PM).
>>> Locale('en', 'US').periods['am']
u'AM'
"""
return self._data['periods']
@property
def days(self):
"""Locale display names for weekdays.
>>> Locale('de', 'DE').days['format']['wide'][3]
u'Donnerstag'
"""
return self._data['days']
@property
def months(self):
"""Locale display names for months.
>>> Locale('de', 'DE').months['format']['wide'][10]
u'Oktober'
"""
return self._data['months']
@property
def quarters(self):
"""Locale display names for quarters.
>>> Locale('de', 'DE').quarters['format']['wide'][1]
u'1. Quartal'
"""
return self._data['quarters']
@property
def eras(self):
"""Locale display names for eras.
>>> Locale('en', 'US').eras['wide'][1]
u'Anno Domini'
>>> Locale('en', 'US').eras['abbreviated'][0]
u'BC'
"""
return self._data['eras']
@property
def time_zones(self):
"""Locale display names for time zones.
>>> Locale('en', 'US').time_zones['Europe/London']['long']['daylight']
u'British Summer Time'
>>> Locale('en', 'US').time_zones['America/St_Johns']['city']
u'St. John\u2019s'
"""
return self._data['time_zones']
@property
def meta_zones(self):
"""Locale display names for meta time zones.
Meta time zones are basically groups of different Olson time zones that
have the same GMT offset and daylight savings time.
>>> Locale('en', 'US').meta_zones['Europe_Central']['long']['daylight']
u'Central European Summer Time'
.. versionadded:: 0.9
"""
return self._data['meta_zones']
@property
def zone_formats(self):
"""Patterns related to the formatting of time zones.
>>> Locale('en', 'US').zone_formats['fallback']
u'%(1)s (%(0)s)'
>>> Locale('pt', 'BR').zone_formats['region']
u'Hor\\xe1rio %s'
.. versionadded:: 0.9
"""
return self._data['zone_formats']
@property
def first_week_day(self):
"""The first day of a week, with 0 being Monday.
>>> Locale('de', 'DE').first_week_day
0
>>> Locale('en', 'US').first_week_day
6
"""
return self._data['week_data']['first_day']
@property
def weekend_start(self):
"""The day the weekend starts, with 0 being Monday.
>>> Locale('de', 'DE').weekend_start
5
"""
return self._data['week_data']['weekend_start']
@property
def weekend_end(self):
"""The day the weekend ends, with 0 being Monday.
>>> Locale('de', 'DE').weekend_end
6
"""
return self._data['week_data']['weekend_end']
@property
def min_week_days(self):
"""The minimum number of days in a week so that the week is counted as
the first week of a year or month.
>>> Locale('de', 'DE').min_week_days
4
"""
return self._data['week_data']['min_days']
@property
def date_formats(self):
"""Locale patterns for date formatting.
>>> Locale('en', 'US').date_formats['short']
<DateTimePattern u'M/d/yy'>
>>> Locale('fr', 'FR').date_formats['long']
<DateTimePattern u'd MMMM y'>
"""
return self._data['date_formats']
@property
def time_formats(self):
"""Locale patterns for time formatting.
>>> Locale('en', 'US').time_formats['short']
<DateTimePattern u'h:mm a'>
>>> Locale('fr', 'FR').time_formats['long']
<DateTimePattern u'HH:mm:ss z'>
"""
return self._data['time_formats']
@property
def datetime_formats(self):
"""Locale patterns for datetime formatting.
>>> Locale('en').datetime_formats['full']
u"{1} 'at' {0}"
>>> Locale('th').datetime_formats['medium']
u'{1}, {0}'
"""
return self._data['datetime_formats']
@property
def plural_form(self):
"""Plural rules for the locale.
>>> Locale('en').plural_form(1)
'one'
>>> Locale('en').plural_form(0)
'other'
>>> Locale('fr').plural_form(0)
'one'
>>> Locale('ru').plural_form(100)
'many'
"""
return self._data['plural_form']
def default_locale(category=None, aliases=LOCALE_ALIASES):
"""Returns the system default locale for a given category, based on
environment variables.
>>> for name in ['LANGUAGE', 'LC_ALL', 'LC_CTYPE']:
... os.environ[name] = ''
>>> os.environ['LANG'] = 'fr_FR.UTF-8'
>>> default_locale('LC_MESSAGES')
'fr_FR'
The "C" or "POSIX" pseudo-locales are treated as aliases for the
"en_US_POSIX" locale:
>>> os.environ['LC_MESSAGES'] = 'POSIX'
>>> default_locale('LC_MESSAGES')
'en_US_POSIX'
The following fallbacks to the variable are always considered:
- ``LANGUAGE``
- ``LC_ALL``
- ``LC_CTYPE``
- ``LANG``
:param category: one of the ``LC_XXX`` environment variable names
:param aliases: a dictionary of aliases for locale identifiers
"""
varnames = (category, 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'LANG')
for name in filter(None, varnames):
locale = os.getenv(name)
if locale:
if name == 'LANGUAGE' and ':' in locale:
# the LANGUAGE variable may contain a colon-separated list of
# language codes; we just pick the language on the list
locale = locale.split(':')[0]
if locale in ('C', 'POSIX'):
locale = 'en_US_POSIX'
elif aliases and locale in aliases:
locale = aliases[locale]
try:
return get_locale_identifier(parse_locale(locale))
except ValueError:
pass
def negotiate_locale(preferred, available, sep='_', aliases=LOCALE_ALIASES):
"""Find the best match between available and requested locale strings.
>>> negotiate_locale(['de_DE', 'en_US'], ['de_DE', 'de_AT'])
'de_DE'
>>> negotiate_locale(['de_DE', 'en_US'], ['en', 'de'])
'de'
Case is ignored by the algorithm, the result uses the case of the preferred
locale identifier:
>>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at'])
'de_DE'
>>> negotiate_locale(['de_DE', 'en_US'], ['de_de', 'de_at'])
'de_DE'
By default, some web browsers unfortunately do not include the territory
in the locale identifier for many locales, and some don't even allow the
user to easily add the territory. So while you may prefer using qualified
locale identifiers in your web-application, they would not normally match
the language-only locale sent by such browsers. To workaround that, this
function uses a default mapping of commonly used langauge-only locale
identifiers to identifiers including the territory:
>>> negotiate_locale(['ja', 'en_US'], ['ja_JP', 'en_US'])
'ja_JP'
Some browsers even use an incorrect or outdated language code, such as "no"
for Norwegian, where the correct locale identifier would actually be "nb_NO"
(Bokmål) or "nn_NO" (Nynorsk). The aliases are intended to take care of
such cases, too:
>>> negotiate_locale(['no', 'sv'], ['nb_NO', 'sv_SE'])
'nb_NO'
You can override this default mapping by passing a different `aliases`
dictionary to this function, or you can bypass the behavior althogher by
setting the `aliases` parameter to `None`.
:param preferred: the list of locale strings preferred by the user
:param available: the list of locale strings available
:param sep: character that separates the different parts of the locale
strings
:param aliases: a dictionary of aliases for locale identifiers
"""
available = [a.lower() for a in available if a]
for locale in preferred:
ll = locale.lower()
if ll in available:
return locale
if aliases:
alias = aliases.get(ll)
if alias:
alias = alias.replace('_', sep)
if alias.lower() in available:
return alias
parts = locale.split(sep)
if len(parts) > 1 and parts[0].lower() in available:
return parts[0]
return None
def parse_locale(identifier, sep='_'):
"""Parse a locale identifier into a tuple of the form ``(language,
territory, script, variant)``.
>>> parse_locale('zh_CN')
('zh', 'CN', None, None)
>>> parse_locale('zh_Hans_CN')
('zh', 'CN', 'Hans', None)
The default component separator is "_", but a different separator can be
specified using the `sep` parameter:
>>> parse_locale('zh-CN', sep='-')
('zh', 'CN', None, None)
If the identifier cannot be parsed into a locale, a `ValueError` exception
is raised:
>>> parse_locale('not_a_LOCALE_String')
Traceback (most recent call last):
...
ValueError: 'not_a_LOCALE_String' is not a valid locale identifier
Encoding information and locale modifiers are removed from the identifier:
>>> parse_locale('it_IT@euro')
('it', 'IT', None, None)
>>> parse_locale('en_US.UTF-8')
('en', 'US', None, None)
>>> parse_locale('de_DE.iso885915@euro')
('de', 'DE', None, None)
See :rfc:`4646` for more information.
:param identifier: the locale identifier string
:param sep: character that separates the different components of the locale
identifier
:raise `ValueError`: if the string does not appear to be a valid locale
identifier
"""
if '.' in identifier:
# this is probably the charset/encoding, which we don't care about
identifier = identifier.split('.', 1)[0]
if '@' in identifier:
# this is a locale modifier such as @euro, which we don't care about
# either
identifier = identifier.split('@', 1)[0]
parts = identifier.split(sep)
lang = parts.pop(0).lower()
if not lang.isalpha():
raise ValueError('expected only letters, got %r' % lang)
script = territory = variant = None
if parts:
if len(parts[0]) == 4 and parts[0].isalpha():
script = parts.pop(0).title()
if parts:
if len(parts[0]) == 2 and parts[0].isalpha():
territory = parts.pop(0).upper()
elif len(parts[0]) == 3 and parts[0].isdigit():
territory = parts.pop(0)
if parts:
if len(parts[0]) == 4 and parts[0][0].isdigit() or \
len(parts[0]) >= 5 and parts[0][0].isalpha():
variant = parts.pop()
if parts:
raise ValueError('%r is not a valid locale identifier' % identifier)
return lang, territory, script, variant
def get_locale_identifier(tup, sep='_'):
"""The reverse of :func:`parse_locale`. It creates a locale identifier out
of a ``(language, territory, script, variant)`` tuple. Items can be set to
``None`` and trailing ``None``\s can also be left out of the tuple.
>>> get_locale_identifier(('de', 'DE', None, '1999'))
'de_DE_1999'
.. versionadded:: 1.0
:param tup: the tuple as returned by :func:`parse_locale`.
:param sep: the separator for the identifier.
"""
tup = tuple(tup[:4])
lang, territory, script, variant = tup + (None,) * (4 - len(tup))
return sep.join(filter(None, (lang, script, territory, variant)))

1181
vendor/babel/dates.py vendored Normal file

File diff suppressed because it is too large Load Diff

BIN
vendor/babel/global.dat vendored Normal file

Binary file not shown.

209
vendor/babel/localedata.py vendored Normal file
View File

@ -0,0 +1,209 @@
# -*- coding: utf-8 -*-
"""
babel.localedata
~~~~~~~~~~~~~~~~
Low-level locale data access.
:note: The `Locale` class, which uses this module under the hood, provides a
more convenient interface for accessing the locale data.
:copyright: (c) 2013 by the Babel Team.
:license: BSD, see LICENSE for more details.
"""
import os
import threading
from collections import MutableMapping
from babel._compat import pickle
_cache = {}
_cache_lock = threading.RLock()
_dirname = os.path.join(os.path.dirname(__file__), 'localedata')
def exists(name):
"""Check whether locale data is available for the given locale. Ther
return value is `True` if it exists, `False` otherwise.
:param name: the locale identifier string
"""
if name in _cache:
return True
return os.path.exists(os.path.join(_dirname, '%s.dat' % name))
def locale_identifiers():
"""Return a list of all locale identifiers for which locale data is
available.
.. versionadded:: 0.8.1
:return: a list of locale identifiers (strings)
"""
return [stem for stem, extension in [
os.path.splitext(filename) for filename in os.listdir(_dirname)
] if extension == '.dat' and stem != 'root']
def load(name, merge_inherited=True):
"""Load the locale data for the given locale.
The locale data is a dictionary that contains much of the data defined by
the Common Locale Data Repository (CLDR). This data is stored as a
collection of pickle files inside the ``babel`` package.
>>> d = load('en_US')
>>> d['languages']['sv']
u'Swedish'
Note that the results are cached, and subsequent requests for the same
locale return the same dictionary:
>>> d1 = load('en_US')
>>> d2 = load('en_US')
>>> d1 is d2
True
:param name: the locale identifier string (or "root")
:param merge_inherited: whether the inherited data should be merged into
the data of the requested locale
:raise `IOError`: if no locale data file is found for the given locale
identifer, or one of the locales it inherits from
"""
_cache_lock.acquire()
try:
data = _cache.get(name)
if not data:
# Load inherited data
if name == 'root' or not merge_inherited:
data = {}
else:
parts = name.split('_')
if len(parts) == 1:
parent = 'root'
else:
parent = '_'.join(parts[:-1])
data = load(parent).copy()
filename = os.path.join(_dirname, '%s.dat' % name)
fileobj = open(filename, 'rb')
try:
if name != 'root' and merge_inherited:
merge(data, pickle.load(fileobj))
else:
data = pickle.load(fileobj)
_cache[name] = data
finally:
fileobj.close()
return data
finally:
_cache_lock.release()
def merge(dict1, dict2):
"""Merge the data from `dict2` into the `dict1` dictionary, making copies
of nested dictionaries.
>>> d = {1: 'foo', 3: 'baz'}
>>> merge(d, {1: 'Foo', 2: 'Bar'})
>>> items = d.items(); items.sort(); items
[(1, 'Foo'), (2, 'Bar'), (3, 'baz')]
:param dict1: the dictionary to merge into
:param dict2: the dictionary containing the data that should be merged
"""
for key, val2 in dict2.items():
if val2 is not None:
val1 = dict1.get(key)
if isinstance(val2, dict):
if val1 is None:
val1 = {}
if isinstance(val1, Alias):
val1 = (val1, val2)
elif isinstance(val1, tuple):
alias, others = val1
others = others.copy()
merge(others, val2)
val1 = (alias, others)
else:
val1 = val1.copy()
merge(val1, val2)
else:
val1 = val2
dict1[key] = val1
class Alias(object):
"""Representation of an alias in the locale data.
An alias is a value that refers to some other part of the locale data,
as specified by the `keys`.
"""
def __init__(self, keys):
self.keys = tuple(keys)
def __repr__(self):
return '<%s %r>' % (type(self).__name__, self.keys)
def resolve(self, data):
"""Resolve the alias based on the given data.
This is done recursively, so if one alias resolves to a second alias,
that second alias will also be resolved.
:param data: the locale data
:type data: `dict`
"""
base = data
for key in self.keys:
data = data[key]
if isinstance(data, Alias):
data = data.resolve(base)
elif isinstance(data, tuple):
alias, others = data
data = alias.resolve(base)
return data
class LocaleDataDict(MutableMapping):
"""Dictionary wrapper that automatically resolves aliases to the actual
values.
"""
def __init__(self, data, base=None):
self._data = data
if base is None:
base = data
self.base = base
def __len__(self):
return len(self._data)
def __iter__(self):
return iter(self._data)
def __getitem__(self, key):
orig = val = self._data[key]
if isinstance(val, Alias): # resolve an alias
val = val.resolve(self.base)
if isinstance(val, tuple): # Merge a partial dict with an alias
alias, others = val
val = alias.resolve(self.base).copy()
merge(val, others)
if type(val) is dict: # Return a nested alias-resolving dict
val = LocaleDataDict(val, base=self.base)
if val is not orig:
self._data[key] = val
return val
def __setitem__(self, key, value):
self._data[key] = value
def __delitem__(self, key):
del self._data[key]
def copy(self):
return LocaleDataDict(self._data.copy(), base=self.base)

BIN
vendor/babel/localedata/aa.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/aa_DJ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/aa_ER.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/aa_ET.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (Umin_daysqKU weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq }q!Uvariantsq"}q#Ucurrency_namesq$}q%U unit_patternsq&}q'u.

BIN
vendor/babel/localedata/af.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/af_NA.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/af_ZA.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (Umin_daysqKU weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq }q!Uvariantsq"}q#Ucurrency_namesq$}q%U unit_patternsq&}q'u.

BIN
vendor/babel/localedata/agq.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/agq_CM.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ak.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ak_GH.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/am.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/am_ET.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (Umin_daysqKU weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq }q!Uvariantsq"}q#Ucurrency_namesq$}q%U unit_patternsq&}q'u.

BIN
vendor/babel/localedata/ar.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_001.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_AE.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}q Uvariantsq!}q"Ucurrency_namesq#}q$U unit_patternsq%}q&u.

4
vendor/babel/localedata/ar_BH.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}q Uvariantsq!}q"Ucurrency_namesq#}q$U unit_patternsq%}q&u.

BIN
vendor/babel/localedata/ar_DJ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_DZ.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_EG.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (Umin_daysqKU weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq }q!Uvariantsq"}q#Ucurrency_namesq$}q%U unit_patternsq&}q'u.

BIN
vendor/babel/localedata/ar_EH.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_ER.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_IL.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}q Uvariantsq!}q"Ucurrency_namesq#}q$U unit_patternsq%}q&u.

BIN
vendor/babel/localedata/ar_IQ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_JO.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_KM.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_KW.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}q Uvariantsq!}q"Ucurrency_namesq#}q$U unit_patternsq%}q&u.

BIN
vendor/babel/localedata/ar_LB.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_LY.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_MA.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_MR.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_OM.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}q Uvariantsq!}q"Ucurrency_namesq#}q$U unit_patternsq%}q&u.

BIN
vendor/babel/localedata/ar_PS.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_QA.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_SA.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_SD.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (Umin_daysqKU weekend_startqKU first_dayqKU weekend_endqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq }q!Uvariantsq"}q#Ucurrency_namesq$}q%U unit_patternsq&}q'u.

BIN
vendor/babel/localedata/ar_SO.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_SY.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/ar_TD.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q U zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}qUvariantsq}qUcurrency_namesq }q!U unit_patternsq"}q#u.

BIN
vendor/babel/localedata/ar_TN.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ar_YE.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/as.dat vendored Normal file

Binary file not shown.

4
vendor/babel/localedata/as_IN.dat vendored Normal file
View File

@ -0,0 +1,4 @@
}q(Ucurrency_symbolsq}qUscientific_formatsq}qUpercent_formatsq}qUnumber_symbolsq}q Ucurrency_names_pluralq
}q U week_dataq }q (U weekend_startqKU first_dayqKuU zone_formatsq}qUcurrency_formatsq}qU_versionqM5 U languagesq}qU territoriesq}U
time_zonesq}qUscriptsq}qUdecimal_formatsq}qU
meta_zonesq}qUvariantsq }q!Ucurrency_namesq"}q#U unit_patternsq$}q%u.

BIN
vendor/babel/localedata/asa.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/asa_TZ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ast.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/ast_ES.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/az.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/az_Cyrl.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/az_Cyrl_AZ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/az_Latn.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/az_Latn_AZ.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/bas.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/bas_CM.dat vendored Normal file

Binary file not shown.

BIN
vendor/babel/localedata/be.dat vendored Normal file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More