i18n
This commit is contained in:
parent
00c02da766
commit
f0fba98124
11
bouquins.js
11
bouquins.js
@ -6,6 +6,7 @@ var cookieParser = require('cookie-parser');
|
|||||||
var bodyParser = require('body-parser');
|
var bodyParser = require('body-parser');
|
||||||
var sqlite3 = require('sqlite3').verbose();
|
var sqlite3 = require('sqlite3').verbose();
|
||||||
var _ = require('underscore');
|
var _ = require('underscore');
|
||||||
|
var i18n = require('i18next');
|
||||||
|
|
||||||
var home = require('./routes/home');
|
var home = require('./routes/home');
|
||||||
var author = require('./routes/author');
|
var author = require('./routes/author');
|
||||||
@ -13,6 +14,11 @@ var book = require('./routes/book');
|
|||||||
var tag = require('./routes/tag');
|
var tag = require('./routes/tag');
|
||||||
var serie = require('./routes/serie');
|
var serie = require('./routes/serie');
|
||||||
|
|
||||||
|
i18n.init({
|
||||||
|
saveMissing: false,
|
||||||
|
debug: true
|
||||||
|
});
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
// view engine setup
|
// view engine setup
|
||||||
@ -40,7 +46,12 @@ app.use(logger('dev'));
|
|||||||
app.use(bodyParser.json());
|
app.use(bodyParser.json());
|
||||||
app.use(bodyParser.urlencoded());
|
app.use(bodyParser.urlencoded());
|
||||||
app.use(cookieParser());
|
app.use(cookieParser());
|
||||||
|
app.use(i18n.handle);
|
||||||
|
|
||||||
|
i18n.registerAppHelper(app);
|
||||||
|
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
app.use(express.static(path.join(__dirname, 'public')));
|
||||||
|
app.use('/locales',express.static(path.join(__dirname, 'locales')));
|
||||||
app.use('/calibre', express.static(app.locals.calibre_path));
|
app.use('/calibre', express.static(app.locals.calibre_path));
|
||||||
|
|
||||||
app.use('/', home);
|
app.use('/', home);
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
"jade": "~1.3.0",
|
"jade": "~1.3.0",
|
||||||
"sqlite3": "~2.2.0",
|
"sqlite3": "~2.2.0",
|
||||||
"underscore": "~1.6.0",
|
"underscore": "~1.6.0",
|
||||||
"hashmap": "~1.1.0"
|
"hashmap": "~1.1.0",
|
||||||
|
"i18next": "*"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www"
|
"start": "node ./bin/www"
|
||||||
|
@ -35,7 +35,7 @@ $.extend(ItemsCol.prototype,{
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
var HomePage = function() {
|
var HomePage = function() {
|
||||||
this.books= new ItemsCol('book', ['Titre', 'Auteur(s)', 'Serie'], [
|
this.books= new ItemsCol('book', [$.t('bouquins.cols.booktitle'), $.t('bouquins.cols.bookauthors'), $.t('bouquins.cols.bookserie')], [
|
||||||
function(elt) {
|
function(elt) {
|
||||||
return link(elt.title, '/book/'+elt.id, 'glyphicon-book');
|
return link(elt.title, '/book/'+elt.id, 'glyphicon-book');
|
||||||
},
|
},
|
||||||
@ -53,11 +53,11 @@ var HomePage = function() {
|
|||||||
return link(content, '/serie/'+elt.series_id, 'glyphicon-list');
|
return link(content, '/serie/'+elt.series_id, 'glyphicon-list');
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
this.authors= new ItemsCol('author', ['Nom', 'Livres'], [
|
this.authors= new ItemsCol('author', [$.t('bouquins.cols.authorname'), $.t('bouquins.cols.authorbooks')], [
|
||||||
function(elt){ return link(elt.name, '/author/'+elt.id,'glyphicon-user'); },
|
function(elt){ return link(elt.name, '/author/'+elt.id,'glyphicon-user'); },
|
||||||
function(elt) { return elt.count; }
|
function(elt) { return elt.count; }
|
||||||
]);
|
]);
|
||||||
this.series= new ItemsCol('serie', ['Nom', 'Auteur(s)', 'Livres'], [
|
this.series= new ItemsCol('serie', [$.t('bouquins.cols.seriename'), $.t('bouquins.cols.serieauthors'), $.t('bouquins.cols.seriebooks')], [
|
||||||
function(elt) { return link(elt.name, '/serie/'+elt.id, 'glyphicon-list'); },
|
function(elt) { return link(elt.name, '/serie/'+elt.id, 'glyphicon-list'); },
|
||||||
function(elt) {
|
function(elt) {
|
||||||
var links='';
|
var links='';
|
||||||
@ -105,6 +105,10 @@ var HomePage = function() {
|
|||||||
if (home.current)
|
if (home.current)
|
||||||
home.current.load();
|
home.current.load();
|
||||||
});
|
});
|
||||||
|
$.each([this.authors,this.books,this.series],function(i,itemsCol) {
|
||||||
|
if (window.location.hash == '#'+itemsCol.id+'s')
|
||||||
|
itemsCol.load();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
$.extend(HomePage.prototype,{
|
$.extend(HomePage.prototype,{
|
||||||
current: null,
|
current: null,
|
||||||
@ -155,12 +159,6 @@ $.extend(HomePage.prototype,{
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
var home = new HomePage();
|
|
||||||
$.each([home.authors,home.books,home.series],function(i,itemsCol) {
|
|
||||||
if (window.location.hash == '#'+itemsCol.id+'s')
|
|
||||||
itemsCol.load();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make link.
|
* Make link.
|
||||||
*/
|
*/
|
||||||
|
6
public/js/i18next.min.js
vendored
Normal file
6
public/js/i18next.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -3,9 +3,9 @@ extends layout
|
|||||||
block content
|
block content
|
||||||
ol.breadcrumb
|
ol.breadcrumb
|
||||||
li
|
li
|
||||||
a(href="/") Home
|
a(href="/")= t('bouquins.nav.home')
|
||||||
li
|
li
|
||||||
a(href="/#authors") Auteurs
|
a(href="/#authors")= t('bouquins.nav.authors')
|
||||||
li.active= title
|
li.active= title
|
||||||
div.container
|
div.container
|
||||||
div.page-header
|
div.page-header
|
||||||
@ -14,7 +14,7 @@ block content
|
|||||||
= ' '+name
|
= ' '+name
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-book
|
span.glyphicon.glyphicon-book
|
||||||
| Livres
|
= ' '+t('bouquins.author.books')
|
||||||
ul
|
ul
|
||||||
each book in books
|
each book in books
|
||||||
li
|
li
|
||||||
@ -27,14 +27,14 @@ block content
|
|||||||
if series
|
if series
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-list
|
span.glyphicon.glyphicon-list
|
||||||
| Series
|
= ' '+t('bouquins.author.series')
|
||||||
ul
|
ul
|
||||||
each serie in series
|
each serie in series
|
||||||
li: a(href='/serie/'+serie.id)= ' '+serie.name
|
li: a(href='/serie/'+serie.id)= ' '+serie.name
|
||||||
if coauthors
|
if coauthors
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-user
|
span.glyphicon.glyphicon-user
|
||||||
| Co-Auteur(s)
|
= ' '+t('bouquins.author.coauthors')
|
||||||
ul
|
ul
|
||||||
each author in coauthors
|
each author in coauthors
|
||||||
li: a(href='/author/'+author.id)= author.name
|
li: a(href='/author/'+author.id)= author.name
|
||||||
|
@ -3,9 +3,9 @@ extends layout
|
|||||||
block content
|
block content
|
||||||
ol.breadcrumb
|
ol.breadcrumb
|
||||||
li
|
li
|
||||||
a(href="/") Home
|
a(href="/")= t('bouquins.nav.home')
|
||||||
li
|
li
|
||||||
a(href="/#books") Livres
|
a(href="/#books")= t('bouquins.nav.books')
|
||||||
li.active= title
|
li.active= title
|
||||||
div.container
|
div.container
|
||||||
div.page-header
|
div.page-header
|
||||||
@ -14,33 +14,33 @@ block content
|
|||||||
= ' '+title+' '
|
= ' '+title+' '
|
||||||
a.btn.btn-success(href='/calibre/'+path+'/'+data_name+'.'+format.toLowerCase())
|
a.btn.btn-success(href='/calibre/'+path+'/'+data_name+'.'+format.toLowerCase())
|
||||||
span.glyphicon.glyphicon-download-alt
|
span.glyphicon.glyphicon-download-alt
|
||||||
= ' Telecharger ' + format
|
= ' '+t('bouquins.book.download')+' ' + format
|
||||||
div.row
|
div.row
|
||||||
div.col-md-5
|
div.col-md-5
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-user
|
span.glyphicon.glyphicon-user
|
||||||
| Auteur(s)
|
= ' '+t('bouquins.book.authors')
|
||||||
ul.list-unstyled
|
ul.list-unstyled
|
||||||
each author in authors
|
each author in authors
|
||||||
li: a(href='/author/'+author.id)= author.name
|
li: a(href='/author/'+author.id)= author.name
|
||||||
if series_name
|
if series_name
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-list
|
span.glyphicon.glyphicon-list
|
||||||
| Serie
|
= ' '+t('bouquins.book.serie')
|
||||||
div
|
div
|
||||||
a(href='/serie/'+series_id)= series_name + ' '
|
a(href='/serie/'+series_id)= series_name + ' '
|
||||||
span.badge= series_index
|
span.badge= series_index
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-globe
|
span.glyphicon.glyphicon-globe
|
||||||
| Langue
|
= ' '+t('bouquins.book.language')
|
||||||
div= lang_code
|
div= lang_code
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-tags
|
span.glyphicon.glyphicon-tags
|
||||||
| Etiquette(s)
|
= ' '+t('bouquins.book.tags')
|
||||||
div
|
div
|
||||||
each tag in tags
|
each tag in tags
|
||||||
span.label.label-info= tag.name
|
span.label.label-info= tag.name
|
||||||
|
|
|
|
||||||
div.col-md-7
|
div.col-md-7
|
||||||
if has_cover == 1
|
if has_cover == 1
|
||||||
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt="Pas de couverture")
|
img.img-rounded.img-responsive(src='/calibre/'+path+'/cover.jpg',alt=t('bouquins.book.nocover'))
|
||||||
|
@ -2,16 +2,16 @@ extends layout
|
|||||||
|
|
||||||
block content
|
block content
|
||||||
div.jumbotron
|
div.jumbotron
|
||||||
h1= title
|
h1= t('bouquins.homeTitle')
|
||||||
p Naviguez dans la bibliothèque.
|
p= t('bouquins.homeGreetings')
|
||||||
p
|
p
|
||||||
a#book.btn.btn-primary.btn-lg(href="#books",role="button") Livres
|
a#book.btn.btn-primary.btn-lg(href="#books",role="button")= t('bouquins.books')
|
||||||
|
|
||||||
a#author.btn.btn-primary.btn-lg(href="#authors",role="button") Auteurs
|
a#author.btn.btn-primary.btn-lg(href="#authors",role="button")= t('bouquins.authors')
|
||||||
|
|
||||||
a#serie.btn.btn-primary.btn-lg(href="#series",role="button") Series
|
a#serie.btn.btn-primary.btn-lg(href="#series",role="button")= t('bouquins.series')
|
||||||
|
|
||||||
a#recent.btn.btn-warning.btn-lg(href="#books",role="button") Derniers ajouts
|
a#recent.btn.btn-warning.btn-lg(href="#books",role="button")= t('bouquins.recent')
|
||||||
div#blkitems.container-fluid.hidden
|
div#blkitems.container-fluid.hidden
|
||||||
a#itemsanchor
|
a#itemsanchor
|
||||||
div.btn-group
|
div.btn-group
|
||||||
@ -21,17 +21,19 @@ block content
|
|||||||
button.btn.btn-default.initial(type="button",value=c)= c
|
button.btn.btn-default.initial(type="button",value=c)= c
|
||||||
- }
|
- }
|
||||||
ul.pager
|
ul.pager
|
||||||
li.previous.disabled: a.prev Précédent
|
li.previous.disabled: a.prev= t('bouquins.previous')
|
||||||
li.next.disabled: a.next Suivant
|
li.next.disabled: a.next= t('bouquins.next')
|
||||||
table#items.table.table-striped
|
table#items.table.table-striped
|
||||||
tr: td.disabled Vide
|
tr: td.disabled= t('bouquins.empty')
|
||||||
ul.pager
|
ul.pager
|
||||||
li.previous.disabled: a.prev Précédent
|
li.previous.disabled: a.prev= t('bouquins.previous')
|
||||||
li.next.disabled: a.next Suivant
|
li.next.disabled: a.next= t('bouquins.next')
|
||||||
div.btn-group.center-block
|
div.btn-group.center-block
|
||||||
each p in [10,20,50,100]
|
each p in [10,20,50,100]
|
||||||
button.btn.btn-default.perpage(type="button",value=p)= p
|
button.btn.btn-default.perpage(type="button",value=p)= p
|
||||||
script(src="js/jquery.min.js")
|
script
|
||||||
script(src="js/bootstrap.min.js")
|
| $(function() {
|
||||||
script(src="js/purl.js")
|
| $.i18n.init().done(function() {
|
||||||
script(src="js/home.js")
|
| home = new HomePage();
|
||||||
|
| });
|
||||||
|
| });
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
doctype html
|
doctype html
|
||||||
html(lang="fr")
|
- var lang = i18n.lng()
|
||||||
|
html(lang=lang)
|
||||||
head
|
head
|
||||||
meta(charset="utf-8")
|
meta(charset="utf-8")
|
||||||
meta(http-equiv="X-UA-Compatible",content="IE=edge")
|
meta(http-equiv="X-UA-Compatible",content="IE=edge")
|
||||||
meta(name="viewport",content="width=device-width, initial-scale=1")
|
meta(name="viewport",content="width=device-width, initial-scale=1")
|
||||||
title= title
|
title= title
|
||||||
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
link(rel='stylesheet', href='/css/bootstrap.min.css')
|
||||||
|
script(src="/js/jquery.min.js")
|
||||||
|
script(src="/js/bootstrap.min.js")
|
||||||
|
script(src="/js/i18next.min.js")
|
||||||
|
script(src="/js/purl.js")
|
||||||
|
script(src="/js/home.js")
|
||||||
body
|
body
|
||||||
block content
|
block content
|
||||||
|
@ -3,9 +3,9 @@ extends layout
|
|||||||
block content
|
block content
|
||||||
ol.breadcrumb
|
ol.breadcrumb
|
||||||
li
|
li
|
||||||
a(href="/") Home
|
a(href="/")= t('bouquins.nav.home')
|
||||||
li
|
li
|
||||||
a(href="/#series") Series
|
a(href="/#series")= t('bouquins.nav.series')
|
||||||
li.active= title
|
li.active= title
|
||||||
div.container
|
div.container
|
||||||
div.page-header
|
div.page-header
|
||||||
@ -14,7 +14,7 @@ block content
|
|||||||
= ' '+name
|
= ' '+name
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-book
|
span.glyphicon.glyphicon-book
|
||||||
| Livres
|
= ' '+t('bouquins.serie.books')
|
||||||
ul
|
ul
|
||||||
each book in books
|
each book in books
|
||||||
li
|
li
|
||||||
@ -24,7 +24,7 @@ block content
|
|||||||
if authors.length > 0
|
if authors.length > 0
|
||||||
h2
|
h2
|
||||||
span.glyphicon.glyphicon-user
|
span.glyphicon.glyphicon-user
|
||||||
| Auteur(s)
|
= ' '+t('bouquins.serie.authors')
|
||||||
ul
|
ul
|
||||||
each author in authors
|
each author in authors
|
||||||
li: a(href='/author/'+author.id)= author.name
|
li: a(href='/author/'+author.id)= author.name
|
||||||
|
Loading…
Reference in New Issue
Block a user