From 393f38a281cf8d515cf2ba45816c5b74b41ca0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Sat, 5 Jan 2013 14:33:12 +0100 Subject: [PATCH] Fix some plural strings and a missing title. Reported by David Ciscar Presas. --- author.php | 4 ++-- base.php | 10 +++++++++- book.php | 2 +- serie.php | 2 +- tag.php | 2 +- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/author.php b/author.php index f65a256..eb7f666 100644 --- a/author.php +++ b/author.php @@ -53,7 +53,7 @@ order by substr (upper (sort), 1, 1)'); while ($post = $result->fetchObject ()) { array_push ($entryArray, new Entry ($post->title, Author::getEntryIdByLetter ($post->title), - str_format (localize("authorword.many"), $post->count), "text", + str_format (localize("authorword", $post->count), $post->count), "text", array ( new LinkNavigation ("?page=".parent::PAGE_AUTHORS_FIRST_LETTER."&id=". rawurlencode ($post->title))))); } return $entryArray; @@ -74,7 +74,7 @@ order by substr (upper (sort), 1, 1)'); { $author = new Author ($post->id, $post->sort); array_push ($entryArray, new Entry ($post->sort, $author->getEntryId (), - str_format (localize("bookword.many"), $post->count), "text", + str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ($author->getUri ())))); } return $entryArray; diff --git a/base.php b/base.php index 9e2fb8e..60396aa 100644 --- a/base.php +++ b/base.php @@ -43,7 +43,14 @@ function str_format($format) { * This method is based on this page * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ */ -function localize($phrase) { +function localize($phrase, $count=-1) { + if ($count == 0) + $phrase .= ".none"; + if ($count == 1) + $phrase .= ".one"; + if ($count > 1) + $phrase .= ".many"; + /* Static keyword is used to ensure the file is loaded only once */ static $translations = NULL; /* If no instance of $translations has occured load the language file */ @@ -312,6 +319,7 @@ class PageAllAuthorsLetter extends Page { global $config; + $this->title = str_format (localize ("splitByLetter.letter"), localize ("authorword.title"), $this->idGet); $this->idPage = Author::getEntryIdByLetter ($this->idGet); $this->entryArray = Author::getAuthorsByStartingLetter ($this->idGet); } diff --git a/book.php b/book.php index 20e4dda..0b41815 100644 --- a/book.php +++ b/book.php @@ -421,7 +421,7 @@ order by substr (upper (sort), 1, 1)"); while ($post = $result->fetchObject ()) { array_push ($entryArray, new Entry ($post->title, Book::getEntryIdByLetter ($post->title), - str_format (localize("bookword.many"), $post->count), "text", + str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ("?page=".parent::PAGE_ALL_BOOKS_LETTER."&id=". rawurlencode ($post->title))))); } return $entryArray; diff --git a/serie.php b/serie.php index e9b51ab..33287f8 100644 --- a/serie.php +++ b/serie.php @@ -66,7 +66,7 @@ order by series.sort'); { $serie = new Serie ($post->id, $post->sort); array_push ($entryArray, new Entry ($serie->name, $serie->getEntryId (), - str_format (localize("bookword.many"), $post->count), "text", + str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ($serie->getUri ())))); } return $entryArray; diff --git a/tag.php b/tag.php index ce6b6d7..c45df25 100644 --- a/tag.php +++ b/tag.php @@ -55,7 +55,7 @@ order by tags.name'); { $tag = new Tag ($post->id, $post->name); array_push ($entryArray, new Entry ($tag->name, $tag->getEntryId (), - str_format (localize("bookword.many"), $post->count), "text", + str_format (localize("bookword", $post->count), $post->count), "text", array ( new LinkNavigation ($tag->getUri ())))); } return $entryArray;