Skip to content

Commit

Permalink
Merge pull request #242 from wsexport/date-format
Browse files Browse the repository at this point in the history
Switch to i18n-friendly long date format for cover
  • Loading branch information
Tpt authored Oct 5, 2020
2 parents 2e0ed30 + b4951ef commit b4895ed
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"require": {
"php": ">=7.2",
"ext-dom": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-libxml": "*",
"ext-mbstring": "*",
Expand Down
3 changes: 2 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions src/Generator/EpubGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\FontProvider;
use App\Util\Util;
use Exception;
use IntlDateFormatter;
use ZipArchive;

/**
Expand Down Expand Up @@ -50,7 +51,6 @@ public function create( Book $book ) {
$oldBookTitle = $book->title;
$css = $this->getCss( $book );
$this->i18n = Util::getI18n( $book->lang );
setlocale( LC_TIME, $book->lang . '_' . strtoupper( $book->lang ) . '.utf8' );
$wsUrl = Util::wikisourceUrl( $book->lang, $book->title );
$cleaner = new BookCleanerEpub();
$cleaner->clean( $book, Util::wikisourceUrl( $book->lang ) );
Expand Down Expand Up @@ -343,6 +343,7 @@ private function getXhtmlTitle( Book $book ) {
$footerElements[] = $book->year;
}

$formatter = new IntlDateFormatter( $book->lang, IntlDateFormatter::LONG, IntlDateFormatter::NONE );
$content = '<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . $book->lang . '" dir="' . Util::getLanguageDirection( $book->lang ) . '">
Expand All @@ -359,9 +360,9 @@ private function getXhtmlTitle( Book $book ) {
$content .= '<br />
<h5>' . implode( $footerElements, ', ' ) . '</h5>
<br />
<h6>' . str_replace( '%d', strftime( '%x' ), htmlspecialchars( $this->i18n['exported_from_wikisource_the'], ENT_QUOTES ) ) . '</h6>
<h6>' . str_replace( '%d', $formatter->format( time() ), htmlspecialchars( $this->i18n['exported_from_wikisource_the'], ENT_QUOTES ) ) . '</h6>
</body>
</html>'; // TODO: Use something better than strftime
</html>';
return $content;
}

Expand Down

0 comments on commit b4895ed

Please sign in to comment.