Mollywhite has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/76454


Change subject: Bug 51194: Localize the publication date in the metadata.
......................................................................

Bug 51194: Localize the publication date in the metadata.

This adds functionality to localize publication dates, which can
be either a year, a month and a year, or a day, month, and year.
This solution seems a bit... hacky... any suggestions would be
very welcome.

Change-Id: I21f750c3f3c66d4fbf1d6a88a13dad90beaa5dea
---
M BookManagerv2.hooks.php
M BookManagerv2.i18n.php
2 files changed, 96 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BookManagerv2 
refs/changes/54/76454/1

diff --git a/BookManagerv2.hooks.php b/BookManagerv2.hooks.php
index bed3c27..29ed8d4 100644
--- a/BookManagerv2.hooks.php
+++ b/BookManagerv2.hooks.php
@@ -165,15 +165,57 @@
                // TODO: This needs to be localized.
                $output = array();
                $output[] = Html::openElement( 'li', array() );
-               if ( $day && !$month ) {
+               if ( $month ) {
+                       switch ( $month ) {
+                       case 1:
+                               $monthLong = 'january';
+                               break;
+                       case 2:
+                               $monthLong = 'february';
+                               break;
+                       case 3:
+                               $monthLong = 'march';
+                               break;
+                       case 4:
+                               $monthLong = 'april';
+                               break;
+                       case 5:
+                               $monthLong = 'may';
+                               break;
+                       case 6:
+                               $monthLong = 'june';
+                               break;
+                       case 7:
+                               $monthLong = 'july';
+                               break;
+                       case 8:
+                               $monthLong = 'august';
+                               break;
+                       case 9:
+                               $monthLong = 'september';
+                               break;
+                       case 10:
+                               $monthLong = 'october';
+                               break;
+                       case 11:
+                               $monthLong = 'november';
+                               break;
+                       case 12:
+                               $monthLong = 'december';
+                               break;
+                       default:
+                               $month = null;
+                               break;
+                       }
+               }
+               if ( $year && !$month ) {
                        // Having a day without a month doesn't make much sense
                        $date = $year;
+               } else if ( $year && $month && !$day ) {
+                       $date = wfMessage( 
"bookmanagerv2-month-year-{$monthLong}", $year );
                } else {
-                       $date = array();
-                       $date[] = $day ? $day . "/" : "";
-                       $date[] = $month ? $month . "/" : "";
-                       $date[] = $year ? $year : "";
-                       $date = implode( $date );
+                       $date = wfMessage( 
"bookmanagerv2-day-month-year-{$monthLong}",
+                               $day, $year );
                }
                $output[] = wfMessage( 'bookmanagerv2-publication-date',
                        $date )->text();
diff --git a/BookManagerv2.i18n.php b/BookManagerv2.i18n.php
index 467569b..51b802f 100644
--- a/BookManagerv2.i18n.php
+++ b/BookManagerv2.i18n.php
@@ -40,6 +40,30 @@
        'bookmanagerv2-isbn' => 'ISBN: $1',
        'bookmanagerv2-lccn' => 'LCCN: $1',
        'bookmanagerv2-oclc' => 'OCLC: $1',
+       'bookmanagerv2-month-year-january' => 'January $1',
+       'bookmanagerv2-month-year-february' => 'February $1',
+       'bookmanagerv2-month-year-march' => 'March $1',
+       'bookmanagerv2-month-year-april' => 'April $1',
+       'bookmanagerv2-month-year-may' => 'May $1',
+       'bookmanagerv2-month-year-june' => 'June $1',
+       'bookmanagerv2-month-year-july' => 'July $1',
+       'bookmanagerv2-month-year-august' => 'August $1',
+       'bookmanagerv2-month-year-september' => 'September $1',
+       'bookmanagerv2-month-year-october' => 'October $1',
+       'bookmanagerv2-month-year-november' => 'November $1',
+       'bookmanagerv2-month-year-december' => 'December $1',
+       'bookmanagerv2-day-month-year-january' => 'January $1, $2',
+       'bookmanagerv2-day-month-year-february' => 'February $1, $2',
+       'bookmanagerv2-day-month-year-march' => 'March $1, $2',
+       'bookmanagerv2-day-month-year-april' => 'April $1, $2',
+       'bookmanagerv2-day-month-year-may' => 'May $1, $2',
+       'bookmanagerv2-day-month-year-june' => 'June $1, $2',
+       'bookmanagerv2-day-month-year-july' => 'July $1, $2',
+       'bookmanagerv2-day-month-year-august' => 'August $1, $2',
+       'bookmanagerv2-day-month-year-september' => 'September $1, $2',
+       'bookmanagerv2-day-month-year-october' => 'October $1, $2',
+       'bookmanagerv2-day-month-year-november' => 'November $1, $2',
+       'bookmanagerv2-day-month-year-december' => 'December $1, $2',
 );
 
 /** Message documentation (Message documentation)
@@ -141,6 +165,30 @@
 
 See screenshot for an example of this dropdown.
 [[File:BookManagerv2 navigation bar metadata dropdown.png]]',
+       'bookmanagerv2-month-year-january' => 'A date in January, containing 
only the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-february' => 'A date in February, containing 
only the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-march' => 'A date in March, containing only 
the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-april' => 'A date in April, containing only 
the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-may' => 'A date in May, containing only the 
month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-june' => 'A date in June, containing only the 
month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-july' => 'A date in July, containing only the 
month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-august' => 'A date in August, containing only 
the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-september' => 'A date in September, 
containing only the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-october' => 'A date in October, containing 
only the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-november' => 'A date in November, containing 
only the month and the year. $1 is the year.',
+       'bookmanagerv2-month-year-december' => 'A date in December, containing 
only the month and the year. $1 is the year.',
+       'bookmanagerv2-day-month-year-january' => 'A date in January, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-february' => 'A date in February, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-march' => 'A date in March, containing 
the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-april' => 'A date in April, containing 
the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-may' => 'A date in May, containing the 
day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-june' => 'A date in June, containing the 
day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-july' => 'A date in July, containing the 
day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-august' => 'A date in August, containing 
the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-september' => 'A date in September, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-october' => 'A date in October, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-november' => 'A date in November, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
+       'bookmanagerv2-day-month-year-december' => 'A date in December, 
containing the day, month, and year. $1 is the numerical day, $2 is the year.',
 );
 
 /** Bengali (বাংলা)

-- 
To view, visit https://gerrit.wikimedia.org/r/76454
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21f750c3f3c66d4fbf1d6a88a13dad90beaa5dea
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BookManagerv2
Gerrit-Branch: master
Gerrit-Owner: Mollywhite <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to