mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 02:23:30 +00:00
Extend Book.getLanguageBook
This commit is contained in:
+10
-6
@@ -176,14 +176,18 @@ Book.prototype.isLanguageBook = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
Return a languages book
|
||||
Returns the book for a language.
|
||||
Returns itself if matches the language itself.
|
||||
|
||||
@param {String} language
|
||||
@return {Book}
|
||||
@param {String} lang Language ID
|
||||
@return {Book | Null} Null if no such language
|
||||
*/
|
||||
Book.prototype.getLanguageBook = function(language) {
|
||||
var books = this.getBooks();
|
||||
return books.get(language);
|
||||
Book.prototype.getLanguageBook = function(lang) {
|
||||
if (this.getLanguage() === lang) {
|
||||
return this;
|
||||
} else {
|
||||
return this.getBooks().get(lang) || null;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user