jenkins-bot has submitted this change and it was merged.

Change subject: Add i18n translation descriptions and clean up date display
......................................................................


Add i18n translation descriptions and clean up date display

The date display wasn't taking into account i18n, so now the years
have been moved in to become parameters for the i18n messages.

No bug in Phabricator.

Change-Id: I81545688cac514ca7f72e767fe4212de4f828cc6
---
D Genealogy.i18n.php
M i18n/en.json
A i18n/qqq.json
M src/Hooks.php
M src/Person.php
5 files changed, 37 insertions(+), 43 deletions(-)

Approvals:
  Samwilson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Genealogy.i18n.php b/Genealogy.i18n.php
deleted file mode 100644
index 9d63d97..0000000
--- a/Genealogy.i18n.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * Internationalisation for the Genealogy extension.
- *
- * @file
- * @ingroup Extensions
- */
-$messages = [];
-
-/**
- * English
- * @author Sam Wilson <[email protected]>
- */
-$messages['en'] = [
-       'genealogy' => 'Genealogy',
-       'genealogy-desc' => 'Adds a parser function for easier linking between 
genealogical records',
-       'genealogy-born' => 'b.',
-       'genealogy-died' => 'd.',
-       'genealogy-ancestor' => 'Ancestor',
-       'genealogy-ancestors' => 'Ancestors',
-       'genealogy-descendant' => 'Descendant',
-       'genealogy-descendants' => 'Descendants',
-       'genealogy-person-preload' => 'Template:Person/preload',
-       'genealogy-parser-function-not-found' => 'Genealogy parser function 
type not recognised: $1',
-       'genealogy-existing-partners' => 'This person already has the following 
'
-               .'{{PLURAL:$1|partner|partners}}: ',
-       'genealogy-person-list-item' => 'Person/list-item'
-];
diff --git a/i18n/en.json b/i18n/en.json
index 4db81df..246130e 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -6,14 +6,15 @@
        },
        "genealogy": "Genealogy",
        "genealogy-desc": "Adds a parser function for easier linking between 
genealogical records",
-       "genealogy-born": "b.",
-       "genealogy-died": "d.",
+       "genealogy-born": "(b.&nbsp;$1)",
+       "genealogy-died": "(d.&nbsp;$1)",
+       "genealogy-born-and-died": "($1&ndash;$2)",
        "genealogy-ancestor": "Ancestor",
        "genealogy-ancestors": "Ancestors",
        "genealogy-descendant": "Descendant",
        "genealogy-descendants": "Descendants",
        "genealogy-person-preload": "Template:Person/preload",
+       "genealogy-person-list-item": "Template:Person/list-item",
        "genealogy-parser-function-not-found": "Genealogy parser function type 
not recognised: $1",
-       "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: ",
-       "genealogy-person-list-item": "Person/list-item"
+       "genealogy-existing-partners": "This person already has the following 
{{PLURAL:$1|partner|partners}}: "
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..3206ebe
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,20 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Sam Wilson <[email protected]>"
+               ]
+       },
+       "genealogy": "The extension title",
+       "genealogy-desc": 
"{{desc|name=Genealogy|url=https://www.mediawiki.org/wiki/Extension:Genealogy}}";,
+       "genealogy-born": "The parenthetic abbreviation showing the year of 
birth.",
+       "genealogy-died": "The parenthetic abbreviation showing the year of 
death.",
+       "genealogy-born-and-died": "The parenthetic abbreviation showing both 
the year of birth and year of death.",
+       "genealogy-ancestor": "A singular noun referring to any parent, 
grandparent, etc. of a given person.",
+       "genealogy-ancestors": "A plural noun referring to all parents, 
grandparents, etc. of a given person.",
+       "genealogy-descendant": "A singular noun referring to any child, 
grandchild, etc. of a given person.",
+       "genealogy-descendants": "A plural noun referring to all children, 
grandchildren, etc. of a given person.",
+       "genealogy-person-preload": "A name of the MediaWiki page that contains 
the text that is preloaded when a new Person page is created.",
+       "genealogy-person-list-item": "The template that will be used (if it 
exists) to format each item in any list of people.",
+       "genealogy-parser-function-not-found": "The error message shown when 
the parser function is passed something it doesn't recognise.",
+       "genealogy-existing-partners": "The message that is shown above the 
page-editing form, alerting the user to the fact that the person they're 
editing has already got a defined partner from another page."
+}
diff --git a/src/Hooks.php b/src/Hooks.php
index b322f89..211cd72 100644
--- a/src/Hooks.php
+++ b/src/Hooks.php
@@ -166,9 +166,9 @@
                $out = '';
                $index = 1;
                $peopleCount = count( $people );
+               $templateExists = Title::newFromText( $templateName->toString() 
)->exists();
                foreach ( $people as $person ) {
-                       $exists = Title::newFromText( 'Template:' . 
$templateName->toString() )->exists();
-                       if ( $exists ) {
+                       if ( $templateExists ) {
                                $template = '{{' . $templateName
                                        . '|title=' . 
$person->getTitle()->getFullText()
                                        . '|link=' . $person->getWikiLink()
diff --git a/src/Person.php b/src/Person.php
index 8dfbb51..e9e211d 100644
--- a/src/Person.php
+++ b/src/Person.php
@@ -80,8 +80,9 @@
        }
 
        /**
-        * Get wikitext for a link to this Person; non-existant people will 
have the preload
-        * parameter added.
+        * Get wikitext for a link to this Person. Non-existent people will get 
an 'external'-style
+        * link that has the 'preload' parameter added. The dates of birth and 
death are appended,
+        * outside the link.
         * @return string The wikitext.
         */
        public function getWikiLink() {
@@ -89,23 +90,24 @@
                $deathYear = $this->getDateYear( $this->getDeathDate() );
                $dateString = '';
                if ( !empty( $birthYear ) && !empty( $deathYear ) ) {
-                       $dateString = "($birthYear&ndash;$deathYear)";
+                       $dateString = wfMessage( 'genealogy-born-and-died', 
$birthYear, $deathYear )->text();
                } elseif ( !empty( $birthYear ) && empty( $deathYear ) ) {
-                       $dateString = "(".wfMessage( 'genealogy-born' 
)->text()."&nbsp;$birthYear)";
+                       $dateString = wfMessage( 'genealogy-born', $birthYear 
)->text();
                } elseif ( empty( $birthYear ) && !empty( $deathYear ) ) {
-                       $dateString = "(".wfMessage( 'genealogy-died' 
)->text()."&nbsp;$deathYear)";
+                       $dateString = wfMessage( 'genealogy-died', $deathYear 
)->text();
                }
-               $date = ( $this->hasDates() ) ? " $dateString" : "";
                if ( $this->getTitle()->exists() ) {
-                       return "[[" . $this->getTitle()->getFullText() . 
"]]$date";
+                       $link = "[[" . $this->getTitle()->getFullText() . "]]";
                } else {
                        $query = [
                                'action' => 'edit',
                                'preload' => wfMessage( 
'genealogy-person-preload' )->text(),
                        ];
                        $url = $this->getTitle()->getFullURL( $query );
-                       return '[' . $url . ' ' . 
$this->getTitle()->getFullText() . ']';
+                       $link = '[' . $url . ' ' . 
$this->getTitle()->getFullText() . ']';
                }
+               $date = ( $this->hasDates() ) ? " $dateString" : "";
+               return $link.$date;
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I81545688cac514ca7f72e767fe4212de4f828cc6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Genealogy
Gerrit-Branch: master
Gerrit-Owner: Samwilson <[email protected]>
Gerrit-Reviewer: Samwilson <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to