jenkins-bot has submitted this change and it was merged. Change subject: Specify default collection language in the metabook file. ......................................................................
Specify default collection language in the metabook file. The default collection language governs the language used for page numbers, chapter headings, etc. Change-Id: Iae02ed4680de5a5fb4c1782c3dfc0225b738ed84 --- M bin/mw-bundler M lib/metabook.js 2 files changed, 26 insertions(+), 0 deletions(-) Approvals: Cscott: Looks good to me, approved jenkins-bot: Verified diff --git a/bin/mw-bundler b/bin/mw-bundler index d51bd99..b2517a9 100755 --- a/bin/mw-bundler +++ b/bin/mw-bundler @@ -23,6 +23,8 @@ 'Parsoid API root', 'http://parsoid-lb.eqiad.wikimedia.org/') .option('-t, --toc <yes|no|auto>', 'Force presence/absence of toc [auto]', 'auto') + .option('-L, --lang <2-char lang code>', + 'Force collection to use the given default language', null) .option('--title <title>', 'Set the title of the generated collection', null) .option('-v, --verbose', diff --git a/lib/metabook.js b/lib/metabook.js index 7cc0396..b2f70be 100644 --- a/lib/metabook.js +++ b/lib/metabook.js @@ -227,6 +227,30 @@ status.report(); } }); + // add a default language for this collection (used for chapter titles, + // etc); use the language of the first article if none was specified. + p = p.then(function() { + if (options.lang) { + // cli option overrides any other language setting + metabook.lang = options.lang; + } + if (metabook.lang) { + // lang already set, nothing more to do. + return; + } + // use the language from the first item + var first = metabook.items[0]; + if (!first) { + // no first item, default to English. + metabook.lang = 'en'; + return; + } + return Siteinfo.fetch(metabook.wikis, first.wiki || 0). + then(function(siteinfo) { + // use the language specified in the siteinfo + metabook.lang = siteinfo.general.lang || 'en'; + }); + }); // done! return p.then(function() { return metabook; -- To view, visit https://gerrit.wikimedia.org/r/98542 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iae02ed4680de5a5fb4c1782c3dfc0225b738ed84 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Collection/OfflineContentGenerator/bundler Gerrit-Branch: master Gerrit-Owner: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits