parent
39362f537a
commit
2f3bc5f2fa
@ -800,7 +800,9 @@ final class NodaWikidataFetcher {
|
||||
$wikilink = $wikilinks[$lang];
|
||||
if (!empty($contents[$lang])) {
|
||||
|
||||
$descFromWiki = json_decode($contents[$lang], true)['parse']['text']['*'];
|
||||
$fromWikipedia = json_decode($contents[$lang], true)['parse'];
|
||||
$titleFromWikipedia = $fromWikipedia['title'];
|
||||
$descFromWiki = $fromWikipedia['text']['*'];
|
||||
|
||||
# Process data retrieved from wikipedia
|
||||
|
||||
@ -815,7 +817,7 @@ final class NodaWikidataFetcher {
|
||||
if ($tDescription !== '' && !empty($desc_cleaned = self::_cleanWikidataInput($tDescription))) {
|
||||
# $descs[$lang] = $tDescription;
|
||||
$output[$lang] = [
|
||||
'label' => self::_cleanWikidataInput((string)$data['labels'][$lang]['value']),
|
||||
'label' => $titleFromWikipedia,
|
||||
'description' => '"' . $desc_cleaned . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')',
|
||||
'link' => $wikilink,
|
||||
];
|
||||
|
@ -471,4 +471,21 @@ Transclusion expansion time report (%,ms,calls,template)
|
||||
$mysqli->close();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that fetching translation from Wikidata returns the title of the wikipedia page,
|
||||
* not the wikidata title.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testListTranslationsFromWikidataWikipediaReturnsWikipediaTitle():void {
|
||||
|
||||
$data = NodaWikidataFetcher::getWikidataEntity("Q33550");
|
||||
|
||||
$output = NodaWikidataFetcher::listTranslationsFromWikidataWikipedia(["de"], $data);
|
||||
self::assertNotEmpty($output['de']);
|
||||
|
||||
self::assertEquals("Friedrich II. (Preußen)", $output['de']['label']);
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user